配置nginx支持php
配置nginx支持php
vi /usr/local/nginx/conf/nginx.conf ? ? ?#編輯配置文件 ? ?
user ? www ?www; ? ? ? ? ?#首行user去掉注釋,修改Nginx運(yùn)行組為www www;必須與/usr/local/php5/etc/php-fpm.conf中的user,group配置相同,否則php運(yùn)行出錯(cuò) ?
php-fpm.conf下的用戶
index ?index.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/; ? ? ##切記要加絕對(duì)路徑
?
? ? ? ? ? ?fastcgi_pass 127.0.0.1:9000;
? ? ? ? ? ?fastcgi_index index.php;
? ? ? ? ? ?fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name; ? ##切記要加絕對(duì)路徑
? ? ? ? ? ?include fastcgi_params;
? ? ? ? ? ? ? ? ? ? }
?
最后檢查php和nginx啟動(dòng)的用戶是否都為www,如無(wú)問(wèn)題重啟服務(wù),web訪問(wèn)測(cè)試
php-cgi -b 127.0.0.1:9000 -c /usr/local/php5/etc/php.ini ? ? ? #php配置文件的路徑
/etc/init.d/nginx restart ?#重啟nginx
轉(zhuǎn)載于:https://blog.51cto.com/chentianwang/1699587
總結(jié)
以上是生活随笔為你收集整理的配置nginx支持php的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 存图利器——链式前向星
- 下一篇: docker安装并运行ElasticSe