CentOS6.8编译安装lnmp(五)- 配置Nginx支持PHP

接上文 CentOS6.8编译安装lnmp(四)- PHP

配置nginx支持php

vi /usr/local/nginx/conf/nginx.conf
修改/usr/local/nginx/conf/nginx.conf 配置文件,需做如下修改

user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php/etc/php-fpm.conf中的user,group配置相同,否则php运行出错
user www www;
worker_processes 1;
events {
	worker_connections 1024;
}
http {
	include mime.types;
	default_type application/octet-stream;
	sendfile on;
	keepalive_timeout 65;
	server {
		listen 80;
		server_name localhost;
		location / {
			root /data/www;
			index index.php index.html index.htm;
		}
		location ~ .php$ {
			root /data/www;
			fastcgi_pass 127.0.0.1:9000;
			fastcgi_index index.php;
			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #注意将··/scripts··改为··$document_root··
			include fastcgi_params;
		}
	}
}
chown www.www /data/www/ -R #设置目录所有者
chmod 700 /data/www -R #设置目录权限

#服务器相关操作命令
service nginx restart #重启nginx
service mysqld restart #重启mysql
/usr/local/php7/sbin/php-fpm #启动php-fpm
/etc/rc.d/init.d/php-fpm restart #重启php-fpm
/etc/rc.d/init.d/php-fpm stop #停止php-fpm
/etc/rc.d/init.d/php-fpm start #启动php-fpm

完(The end!)

posted @ 2017-08-12 20:31  凭栏知潇雨  阅读(207)  评论(0编辑  收藏  举报