我已经设置了我的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查询。我不知道如何解决它。
答案 0 :(得分:1)
我一直在谷歌搜索和测试我遇到的发行版的所有教程,没有一个工作。所以我了解到一个人必须为你的发行版咨询正确的文档,否则它根本就行不通。所以我找到了this one
我有RHE5.7 Tikanga运行Apache 2.2。两个站点在端口8080和nginx-1.0.14-1.el5.ngx 80上运行。我的意思是我有两个目录链接到/ var / www / html / site1和/ var / www / html / site2。两者都在PHP 5中。
对于那些管理Red Hat网站的人来说,这对我有用
$ NameVirtualHost *:8080
<VirtualHost *:8080>
ServerAdmin me@mydomain.com
ServerName localhost
DocumentRoot /var/www/html/
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin me@mydomain.com
ServerName site1
DocumentRoot /var/www/html/site1
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin sleepy@nightmare.com
ServerName site2
DocumentRoot /var/www/html/site2
</VirtualHost>`
/etc/nginx/nginx.conf-修正案 在这个文件的顶部:
.....
$worker_rlimit_nofile 20480;
....
gzip_buffers 32 8k;
gzip_comp_level 6;
gzip_http_version 1.0;
gzip_min_length 1;
行#include /etc/nginx/conf.d/*.conf已被评论,因为这对我来说没用。)所有剩余的代码都没有改变,但我的 IP 和 servername ,在这种情况下我把主机名,根指令保持相同的根/ usr / share / nginx / html,与虚拟配置文件/ var / www / html /中的不同。我的猜测是,作为前端的nginx不知道(甚至不应该)要提供的Web文件只是Apache。
当我去任何浏览器并输入:
ip显示nginx默认页面,所以我猜它正在收听80端口; ip / site1显示site1 ip / site2显示site2
除80或8080之外的任何其他端口都显示连接错误。
问候。