centos6.5 nginx php配置
1:yum安装php和与之相关的软件包
yum install gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel php php-fpm
2:nginx安装参见之前写的nginx的安装
3:修改nginx配置让它支持php-fpm
[root@centos-test ~]#cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak #首先备份下nginx的配置文件,以防万一
[root@centos-test ~]#vi /usr/local/nginx/conf/nginx.conf
在修改nginx.conf之前新建一个存放php项目的文件夹,在这我新建
[root@centos-test ~]#mkdir -p /var/www/php
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/php$fastcgi_script_name;
include fastcgi_params;
}
找到以上文字的地方去掉注释,修改红色部分,主要是修改项目存放的路径。让其可以支持php-fpm
4:nginx的error.log会有报错请在/etc/php.ini中找到以下部分添加“Asia/Shanghai”
date.timezone = "Asia/Shanghai"
5:启动php-fpm
[root@centos-test ~]# service php-fpm restart