天天看點

nginx支援php5,配置nginx支援php

配置nginx支援php

vi /usr/local/nginx/conf/nginx.conf      #編輯配置檔案

user   www  www;          #首行user去掉注釋,修改Nginx運作組為www www;必須與/usr/local/php5/etc/php-fpm.conf中的user,group配置相同,否則php運作出錯

php-fpm.conf下的使用者

index  ind

nginx支援php5,配置nginx支援php

ex.php  index.html index.htm;    #添加index.php

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location / {

root   html;

index  index.html index.htm;

}

location ~ \.php$ {

root /usr/local/nginx/html/;     ##切記要加絕對路徑

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name;   ##切記要加絕對路徑

include fastcgi_params;

}

最後檢查php和nginx啟動的使用者是否都為www,如無問題重新開機服務,web通路測試

php-cgi -b 127.0.0.1:9000 -c /usr/local/php5/etc/php.ini       #php配置檔案的路徑

/etc/init.d/nginx restart  #重新開機nginx