繁体   English   中英

Nginx和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的查询。 我不知道该如何解决。

我一直在使用Google搜索和测试所有发行版教程,但都无济于事。 因此,我了解到必须向您的发行版咨询正确的文档,否则它将根本无法正常工作。 所以我找到了这个

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

对于那些管理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服务器名 (在本例中为主机名 )和root指令与/ usr / share / nginx / html相同,这与虚拟conf文件/ var /中的不同。 www / html等/。 我的猜测是,作为前端的nginx不知道(甚至不应该)要提供Web文件的位置只是Apache。

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

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

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

问候。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM