简体   繁体   English

nginx和apache-处理php文件时出错

[英]nginx and apache - Error processing php files

I am still learning nginx, so please bear with me if the answer is obvious :). 我仍在学习nginx,因此,如果答案很明显,请忍受:)。

I have set up nginx in front of apache using these instructions 我已经按照以下说明在apache前面设置了nginx

nginx seems to be properly processing html files, however anytime I try and access a php file I get a 404 error. nginx似乎正在正确处理html文件,但是,每当我尝试访问php文件时,我都会收到404错误。

here is the nginx example.com conf file 这是nginx example.com conf文件

server {
    listen 80;
    access_log /var/www/example.com/logs/nginx.access.log;
    error_log /var/www/example.com/logs/nginx.error.log;
    root /var/www/example.com/prod;
    index index.php index.html index.htm;
    server_name www.example.com example.com;
    location \ {
            try_files $uri $uri/ index.php/$uri;
    }
    location ~* ^.*\.php$ {
            if (!-f $request_filename) {
                    return 404;
            }
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:8080;
    }
    location ~ /\.(ht|git) {
            deny all;
    }
}

and here is my apache example.com conf file 这是我的Apache example.com conf文件

<VirtualHost 123.45.67.89:8080>
    ServerName example.com
    ServerAlias www.example.com
    ServerAdmin webmaster@example.com

    #Indexes + Directory Root
    DirectoryIndex index.html index.htm index.php
    DocumentRoot /var/www/example.com/prod/

    #CGI Directory
    ScriptAlias /cgi-bin/ /var/www/example.com/prod/cgi-bin/
    <location /cgi-bin>
            Options +ExecCGI
    </location>

    #Log Files
    ErrorLog /var/www/example.com/logs/error.log
    CustomLog /var/www/example.com/logs/access.log combined

</VirtualHost>

I've been trying to figure out where my error is for the better part of 4 hours now. 我一直在尝试找出我的错误在4小时内的大部分时间内都在哪里。 I am hoping you might be able to help :( 我希望您可以提供帮助:(

proxy_pass http://127.0.0.1:8080; and <VirtualHost 123.45.67.89:8080> doesn't look the same. <VirtualHost 123.45.67.89:8080>看起来不一样。

And nginx config looks wrong. 而且nginx的配置看起来是错误的。 Maybe you will have better luck if you read the official documentation . 如果您阅读官方文档,也许会更好。

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

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