nginx and apache (php)


nginx and apache (php)

我已经设置了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提供查询。我不知道如何修复它。

我一直在谷歌上搜索和测试我遇到的所有发行版教程,但都没有成功。因此,我了解到,必须为您的发行版查阅正确的文档,否则它根本不起作用。所以我找到了这个

我有运行Apache 2.2的RHE5.7Tikanga。在8080端口和nginx-1.0.14.el5.ngx 80上运行的两个站点。我的意思是,我有两个目录smlinking到/var/www/html/site1和/var/www/html/site2。两者都在php5。

对于那些管理Red Hat网站的人,这对我有效

  1. 编辑http.conf并更改为Listen 8080
  2. 根据现场说明对nginx.conf进行相应修改
  3. 修改虚拟主机文件/etc/httpd/conf.d/httpd-vhosts.conf或其他文件,只要它可以被http.conf include指令包含,如下所示:

$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服务器名,在这种情况下,我放了主机名

当我转到任何浏览器并键入:

ip显示nginx默认页面,所以我猜它正在监听80端口;ip/site1显示site1ip/site2显示site2

除了80或8080之外的任何其他端口都显示连接错误。

问候。