【发布时间】:2012-02-18 21:38:03
【问题描述】:
我已经设置了我的 nginx,但现在我的虚拟主机上的每个 *.php 文件都返回 500 内部服务器错误。
server {
listen tucnak.dev:80; ## listen for ipv4; this line is default and implied
root /home/tucnak/Web/Lab;
index index.php index.html;
server_name tucnak.dev;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
}
location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
location /images {
root /usr/share;
autoindex off;
}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ \.php$ {
proxy_pass http://127.0.0.1;
}
location ~ \.php$ {
set $php_root /home/tucnak/Web/Lab;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
我的错误在哪里?我的 php 文件完全正确!
<?php echo("Hello!"); ?>
我是 nginx 的新手,需要帮助。在 apache2 之后 - 我很困惑!
UPD:我认为 nginx 没有成功查询 apache。我不知道如何解决它。
【问题讨论】:
-
你为什么同时使用
proxy_pass和fastcgi_pass? -
没有它(proxy_pass)他提供我下载.php文件)
-
您可能需要删除其中一个位置 location ~ \.php$ 不清楚,您使用的是 apache 后端还是 fastcgi。我认为 nginx 也无法解决这个问题
-
我很困惑。我已经在新机器上安装了 nginx 和 apache2。没有 apache2 配置。那么,我该怎么办?
-
您收到
error 500,因为您的位置不明确。而且,没有proxy_pass,它正在下载你的php文件,因为我认为你的apache没有启用fast_cgi。