LNMP安装


  1. mysql安装通LAMP(可查看LAMP的安装帖子http://zxlwz.blog.51cto.com/6952946/1716130)

  2. PHP安装(http://zxlwz.blog.51cto.com/6952946/1726720)

 cd /usr/local/src/

 wget http://am1.php.net/distributions/php-5.3.27.tar.gz

3.tar zxvf php-5.3.27.tar.gz

4.创建账号来运行php-fpm服务

useradd -s /sbin/nologin php-fpm 

5.cd php-5.3.27.tar.gz

6.进行编译

 ./configure \

--prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=php-fpm \         #这里必须要和上面创建的用户对应
--with-fpm-group=php-fpm \        #这里必须要和上面创建的用户对应
--with-mysql=/usr/local/mysql \   #mysql的安装位置
--with-mysql-sock=/tmp/mysql.sock \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--enable-zend-multibyte \
--disable-ipv6 \
--with-pear \
--with-curl \
--with-openssl

7.echo $?

8.如果出现

在这一步,阿铭遇到如下错误:

configure: error: xml2-config not found. Please check your libxml2 installation.

解决办法是:

yum install -y libxml2-devel

还有错误:

configure: error: Cannot find OpenSSL's <evp.h>

解决办法是:

yum install -y openssl openssl-devel

错误:

checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

解决办法:

yum install -y bzip2 bzip2-devel

错误:

configure: error: png.h not found.

解决办法:

yum install -y libpng libpng-devel

错误:

configure: error: freetype.h not found.

解决办法:

yum install -y freetype freetype-devel

错误:

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决办法:

rpm -ivh "http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm"
yum install -y  libmcrypt-devel
onfigure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/

解决办法:

yum install -y libcurl-devel

  configure: error: freetype.h not found.

解决办法yum install freetype-devel
checking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.
解决办法: yum install libjpeg-devel
checking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found.
解决办法:yum install libpng-devel
9.make&make install
10.拷贝文件
cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/src/php-5.3.27/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp /usr/local/php/etc/php-fpm.conf.default php-fpm.conf
11.chmod 755 /etc/init.d/php-fpm
12.chkconfig --add php-fpm
  chkconifg php-fpm on
13. service php-fpm start
14. ps aux|grep php-fpm


Nginx安装(详细资源http://zxlwz.blog.51cto.com/6952946/1726720)

15.wget http://nginx.org/download/nginx-1.4.4.tar.gz
16.tar zxvf nginx-1.4.4.tar.gz
17.cd nginx-1.4.4
18.如出现./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
解决办法:yum install -y pcre*
19.make&make install
20.启动nginx
/usr/local/nginx/sbin/nginx
21.ps aux |grep nginx
22.编写nginx的启动脚本
vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings

NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"

start() {
       echo -n $"Starting $prog: "
       mkdir -p /dev/shm/nginx_temp
       daemon $NGINX_SBIN -c $NGINX_CONF
       RETVAL=$?
       echo
       return $RETVAL
}

stop() {
       echo -n $"Stopping $prog: "
       killproc -p $NGINX_PID $NGINX_SBIN -TERM
       rm -rf /dev/shm/nginx_temp
       RETVAL=$?
       echo
       return $RETVAL
}

reload(){
       echo -n $"Reloading $prog: "
       killproc -p $NGINX_PID $NGINX_SBIN -HUP
       RETVAL=$?
       echo
       return $RETVAL
}

restart(){
       stop
       start
}

configtest(){
   $NGINX_SBIN -c $NGINX_CONF -t
   return 0
}

case "$1" in
 start)
       start
       ;;
 stop)
       stop
       ;;
 reload)
       reload
       ;;
 restart)
       restart
       ;;
 configtest)
       configtest
       ;;
 *)
       echo $"Usage: $0 {start|stop|reload|restart|configtest}"
       RETVAL=1
esac

exit $RETVAL
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
就可以service nginx strat

测试php解析
vim /usr/lcoal/nginx/conf/nginx.conf
找到 把前面的 #号去掉相应的地方,改成以下
location ~ \.php$ {
        root html;
        include fastcgi_params;
        fastcgi_pass unix:/tmp/php-fcgi.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
        
    }
重新加载
/usr/local/nginx/sbin/nginx -s reload
 
 cd /usr/local/nginx/html/
 vim 2.php
 <?php
 phpinfo()
 ?>
 
查看测试 curl localhost/2.php
 
本帖出自本人自学心得
高手勿喷!


本文出自 “Linux学习空间” 博客,转载请与作者联系!

你可能感兴趣的:(LNMP)