我在ubuntu 13.04上全新安装php5-fpm和nginx时使用此配置:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ /index.html;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
error_page 404 /404.html;
location ~ \.php${
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
但是,我的网页浏览器将php视为文本而不是执行的结果.我应该在哪里寻找解决问题?
最佳答案
您的php代码正在被直接显示,因为它没有被发送到php引擎,这意味着位置块正在匹配并且php文件被提供,但php文件没有被php块捕获,所以你的问题在php块.
在该块中,您有2个fastcgi_pass,一个端口(9000),另一个连接到unix套接字,您不能同时使用,但是由于您已经用fastcgi标记了您的问题,所以我假设您正在使用fastcgi尝试评论这一行
#fastcgi_pass unix:/var/run/php5-fpm.sock;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。