我在ubuntu上安装php运行环境。之前已经装好nginx的,所以新装了php7.1.
根据网上教程需要改下nginx的配置文件:如下配置:
ocation ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}
当我保存重启时提示找不到snippets/fastcgi-php.conf;这个文件,然后我去目录也看了,确实没有这个文件,只有如下文件
/usr/local/nginx/conf# ls
fastcgi.conf koi-win scgi_params.default
fastcgi.conf.default mime.types uwsgi_params
fastcgi.cong mime.types.default uwsgi_params.default
fastcgi_params nginx.conf win-utf
fastcgi_params.default nginx.conf.default
koi-utf scgi_params
我把snippets/fastcgi-php.conf; 换成 fastcgi.conf 读不了php。求助!
完整配置:
server {
listen 80;
root /var/www/weiqing; #网站目录
index index.php index.html index.htm index.nginx-debian.html;
server_name wq.callmesoul.cn; #绑定网站域名
location / {
try_files $uri $uri/ /index.php?$query_string; #配置转发
规则
}
# 解析php
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.1-fpm.sock; #利用php-fpm套接字解析php
}
location ~ /\.ht {
deny all;
}
}