目录

Lnmp Linux+nginx+mysql+php

系统及软件版本:linux 6.5_x64 nginx1.6.2 php5.4.37 mysql5.1.73

首先安装Mysql-请参考文档:Mysql5.1二进制免编译安装

安装PHP5.4.37

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
[root@lnmp mysql]# cd /usr/local/src/
[root@lnmp src]# wget http://cn2.php.net/distributions/php-5.4.37.tar.bz2
[root@lnmp src]# tar jxf php-5.4.37.tar.bz2
[root@lnmp src]# useradd -s /sbin/nologin php-fpm
[root@lnmp php-5.4.37]# cd php-5.4.37
[root@lnmp php-5.4.37]# yum install -y epel-release
[root@lnmp php-5.4.37]# yum install -y gcc libxml2-devel curl-devel libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt-devel
[root@lnmp php-5.4.37]# ./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  --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    --disable-ipv6     --with-curl
[root@lnmp php-5.4.37]# make && make install
[root@lnmp php-5.4.37]# cp php.ini-production /usr/local/php/etc/php.ini
[root@lnmp php-5.4.37]# cp /usr/local/src/php-5.4.37/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@lnmp php-5.4.37]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@lnmp php-5.4.37]# chmod 755 /etc/init.d/php-fpm
[root@lnmp php-5.4.37]# chkconfig --add php-fpm
[root@lnmp php-5.4.37]# service php-fpm start
[root@lnmp php-5.4.37]# chkconfig php-fpm on
[root@lnmp php-5.4.37]# ps aux | grep php-fpm
[root@lnmp php-5.4.37]# netstat -lnp | grep 9000

安装Nginx

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@lnmp php-5.4.37]# cd /usr/local/src/
[root@lnmp src]# wget http://nginx.org/download/nginx-1.6.2.tar.gz
[root@lnmp src]# tar zxvf nginx-1.6.2.tar.gz
[root@lnmp nginx-1.6.2]# cd nginx-1.6.2
[root@lnmp nginx-1.6.2]# yum install -y pcre-devel
[root@lnmp nginx-1.6.2]# ./configure   --prefix=/usr/local/nginx   --with-pcre
[root@lnmp nginx-1.6.2]# make && make install
[root@lnmp nginx-1.6.2]# /usr/local/nginx/sbin/nginx
[root@lnmp nginx-1.6.2]# ps aux | grep nginx
[root@lnmp nginx-1.6.2]# vi /usr/local/nginx/conf/nginx.conf	#把下面的配置,前面的#删除
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;	#修改网站根目录为/usr/local/nginx/html
            include        fastcgi_params;
        }
[root@lnmp nginx-1.6.2]# /usr/local/nginx/sbin/nginx -t
[root@lnmp nginx-1.6.2]# /usr/local/nginx/sbin/nginx -s reload
[root@lnmp nginx-1.6.2]# cat /usr/local/nginx/html/info.php
<?php
phpinfo();
?>