[英]nginx and apache (php)
I've set my nginx but now every *.php file on my virtual host returns 500 internal server error. 我已经设置了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;
#}
}
Where is my error? 我的错误在哪里? My php-file is total correct!
我的php文件是完全正确的!
<?php echo("Hello!"); ?>
I am really new at nginx and need help with it. 我真的是nginx的新手,需要帮助。 After apache2 - I am confused!
apache2之后-我很困惑!
UPD: I think that nginx not successfully gives query for apache. UPD:我认为nginx无法成功提供针对Apache的查询。 I don't know how to fix it.
我不知道该如何解决。
I have been googling and testing all the tutorials for distros I came across with and none worked. 我一直在使用Google搜索和测试所有发行版教程,但都无济于事。 So I learnt that one must consult the right docs for you distro or it simply will not work.
因此,我了解到必须向您的发行版咨询正确的文档,否则它将根本无法正常工作。 So I have found this one
所以我找到了这个
I have RHE5.7 Tikanga running Apache 2.2. 我有运行Apache 2.2的RHE5.7 Tikanga。 Two sites running on port 8080 and nginx-1.0.14-1.el5.ngx 80. I mean that I have two directories smlinking to /var/www/html/site1 and /var/www/html/site2.
在端口8080和nginx-1.0.14-1.el5.ngx 80上运行的两个站点。我的意思是我有两个目录链接到/ var / www / html / site1和/ var / www / html / site2。 Both in php 5.
两者都在php 5。
For those who admin Red Hat sites, this worked for me 对于那些管理Red Hat网站的人,这对我有用
$ NameVirtualHost *:8080 $ 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 - amendments On top of this file: /etc/nginx/nginx.conf-此文件顶部的修订:
..... $worker_rlimit_nofile 20480;
.....
$worker_rlimit_nofile 20480;
.... ....
gzip_buffers 32 8k;
gzip_comp_level 6;
gzip_http_version 1.0;
gzip_min_length 1;
The line #include /etc/nginx/conf.d/*.conf has been commented as this was useless for me). #include /etc/nginx/conf.d/*.conf行已被注释,因为这对我来说是无用的。 All the remained code was unchanged but my IP and servername , in this case I put hostname ,and the root instruction remained the same the root /usr/share/nginx/html, which is different from the one in virtual conf file /var/www/html/.
其余所有代码均未更改,但我的IP和服务器名 (在本例中为主机名 )和root指令与/ usr / share / nginx / html相同,这与虚拟conf文件/ var /中的不同。 www / html等/。 My guess is that nginx as front-end does not know (and not even should) where the web files to be served are but Apache.
我的猜测是,作为前端的nginx不知道(甚至不应该)要提供Web文件的位置只是Apache。
When I go to any browser and type: 当我转到任何浏览器并键入:
ip shows nginx default page, so i guess it is listening to 80 port; ip显示nginx默认页面,所以我想它正在监听80端口; ip/site1 displays site1 ip/site2 displays site2
ip / site1显示site1 ip / site2显示site2
Any other port but 80 or 8080 displays connection error. 除80或8080以外的任何其他端口都显示连接错误。
regards. 问候。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.