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
[[email protected] ~]#cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak #首先备份下nginx的配置文件,以防万一
[[email protected] ~]#vi /usr/local/nginx/conf/nginx.conf
在修改nginx.conf之前新建一个存放php项目的文件夹,在这我新建
[[email protected] ~]#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
[[email protected] ~]# service php-fpm restart