0
我還在學習nginx,所以如果答案很明顯,請耐心等待:)。nginx和apache - 處理php文件時出錯
我一直在使用these instructions
nginx的設立了Apache的前面nginx的似乎是正確處理HTML文件,但任何時候我嘗試訪問一個PHP文件,我得到一個404錯誤。
這裏是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;
}
}
,這裏是我的Apache example.com的conf文件
<VirtualHost 123.45.67.89:8080>
ServerName example.com
ServerAlias www.example.com
ServerAdmin [email protected]
#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>
我一直在試圖找出在我的錯誤是現在是4小時的更好的一部分。我希望你也許能幫助:(
您是對的,我將VirtualHost更改爲並且它工作... –
tcherokee
2012-07-18 13:33:13
如果您只想監聽本地接口,那麼應該更改爲127.0.0.1:8080,這樣會更安全。 – VBart 2012-07-18 16:27:32