1.系统环境
centos6.3_x64
nginx: 1.1.5
php:php-5.4.14
############################################
2.环境安装
#yum 安装系统环境所需要的软件包
yum -y install yum-fastestmirror ntp
yum -y install patch make flex bison tar
yum -y install libtool libtool-libs kernel-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel
yum -y install libtiff libtiff-devel gettext gettext-devel
yum -y install libxml2 libxml2-devel zlib-devel net-snmp
yum -y install file glib2 glib2-devel bzip2 diff* openldap-devel
yum -y install bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs
yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
yum -y install openssl openssl-devel vim-minimal unzip
# 安装PHP支持GD库模块
yum -y install freetype freetype-devel png jpeg zlib gd php-gd*
# 安装PHP 5.* 组件
yum -y install libiconv libevent mhash mcrypt
# 安装MYDSQL所需要系统库相关库文件
yum install -y gcc gcc-c++ gcc-g77 autoconf automake fiex* ncurses-devel libmcrypt* libtool-ltdl-devel*
# 安装NGINX 组件
yum -y install pcre*
####################################
3.PHP安装
php和nginx的整合是通过php-FastCGI
FastCGI 是一个可伸缩、高速的在web server和脚本语言间通迅的接口。被许多脚本语言所支持,包括 php多数流行的web server都支持 FastCGI。
正常情况下,nginx和php直接是完全不认识的,我们就是通过php-fastcgi将二者整合。
php5.3.0之前的版本,php-FastCGI 是需要单独安装的。但是在这之后,php-FastCGI 就整合在了php的源码包中,不必再去单独安装。在这里我用的就是php5.3.8的版本,内置了php-fpm ,编译时开启,并且编译后存在 php-cgi 文件了。
注意:PHP编译支持php-fpm功能就不能编译支持apache的apxs模块功能,不然报错。
tar jxf php-5.4.14.tar.bz2 && cd php-5.4.14
| 1 | ./configure |
make && make install
cp php-5.4.14/php.ini-production /usr/local/php/lib/php.ini
| 12 | date.timezone = |
# cd /usr/local/php/etc/ # 切换到安装目录下的配置文件目录
# cp php-fpm.conf.default php-fpm.conf
# vi php-fpm.conf
启用如下几行,即去掉前面的分号(;)
| 12345678910111213141516 | pid = run/php-fpm.pid |
wq保存退出
# /usr/local/php/sbin/php-fpm (启动PHP)
# netstat -antpl (如果看到9000端口,PHP-FPM配置成功)
注意:如果修改php.ini文件,则需要重启php-fpm进程使生效。
###########################################################
4.nginx安装
wget -c http://nginx.org/download/nginx-1.1.5.tar.gz
tar zxf nginx-1.1.5.tar.gz && cd nginx-1.1.5
./configure --prefix=/usr/local/nginx -- |
make && make install
NGINX 配置文件设置:这个配置只是让NGX和PHP关联起来
/usr/local/nginx/conf/nginx.conf
user nginx nginx ; (nginx 用户需要新建,注释掉也OK的) |
5.测试启动nginx
mkdir -p /tmp/nginx/proxy
cd /usr/local/nginx/sbin
./nginx -t 检测
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
./nginx 启动nginx
在/home/aixue/public_html/ 中编写Index.php文件
phpinfo();
?>
打开浏览器 http://IP/index.php,能浏览,安装成功了。



