/*************************************************************************
* CentOS 6.6 nginx PHP 配置
* 说明:
* 在VPS上安装nginx PHP配置,以供有些时候无聊使用。
*
* 2016-11-26 深圳 南山平山村 曾剑锋
************************************************************************/
一、参考文档:
. CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
http://blog.csdn.net/lane_l/article/details/20235909
. PHP-FPM does not automatically start after reboot
http://serverfault.com/questions/459728/php-fpm-does-not-automatically-start-after-reboot
. OpenBSD.Nginx.MySQL.PHP环境搭建手册
http://www.360doc.com/content/10/1211/11/4330887_77027995.shtml
二、安装:
yum install php
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm
三、测试php-cgi:
php-cgi -b 127.0.0.1:
四、后台运行php-cgi:
. /etc/rc.d/init.d/php-fpm start
. chkconfig php-fpm on
五、nginx配置:
[root@localhost /]# cat /etc/nginx/conf.d/php.conf
server {
listen ;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /home/zengjf/www;
index index.php index.html index.htm;
}
#error_page /.html;
# redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
location ~ \.php$ {
root /home/zengjf/www;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
[root@localhost /]#