使用 nginx Web 服务器和 php。 nginx 正在工作,我看到“欢迎使用 nginx!”但当我尝试访问 php 页面时,我收到“访问被拒绝”的消息。我还安装了 php-fastcgi。
这是我的 nginx 默认配置:
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
我激活了security.limit_extensions = .php .php3 .php4 .php5 .html
and listen = /var/run/php5-fpm.sock
在 /etc/php-fpm.d/www.conf 和cgi.fix_pathinfo = 0
在 /etc/php5/fpm/php.ini 中
我重新启动了 nginx 和 php5-fpm。
谢谢你的帮助。
在你有第二位置的地方这样做
location / {
try_files $uri $uri/ =404;
root /path/to/your/www;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
这两个参数是神奇的:
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)