ENV
CentOS 6.5 x86_64 PHP 5.6.3 httpd 2.4.10 Nginx 1.6.2 ZendFramework2.3.3
:定位
安装ZF2 Skeleton Application
立即
我配置nginx将php文件传递给apache。我将zf2框架应用程序配置到nginx或apache中的虚拟主机中。我手动安装zendframework2.3.3。我可以通过127.0.0.1:38082(由httpd配置)正常访问网站。但是,当我通过127.0.0.1:8082(由nginx配置)访问该网站时,我得到404错误,如下所示。有人可以给我一些建议吗?感谢。
我的配置
Nginx vhost
server {
listen 8082;
server_name www.eg.m;
#charset koi8-r;
access_log logs/eg.access.log main;
location / {
root /data/webapp/www/zf-app/public;
index index.php index.html index.htm Default.html Default.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ {
proxy_pass http://127.0.0.1:38082;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
httpd vhost
Listen 38082
<VirtualHost *:38082>
ServerAdmin w@gmail.com
DocumentRoot "/data/webapp/www/zf-app/public"
ServerName www.eg.m
ServerAlias eg.m
ErrorLog "logs/eg.m-error_log"
CustomLog "logs/eg.m-access_log" common
SetEnv ZF2_PATH "/data/webapp/www/ZendFramework-2.3.3/library"
SetEnv APPLICATION_ENV "development"
<Directory /data/webapp/www/zf-app/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
我收到错误
A 404 error occurred
Page not found.
The requested URL could not be matched by routing.
No Exception available
登录
apache直接从apache登录127.0.0.1:38082
错误日志
[Mon Dec 22 19:52:37.100637 2014] [authz_core:debug] [pid 17524:tid 139805499234048] mod_authz_core.c(802): [client 127.0.0.1:38934] AH01626: authorization result of Require all granted: granted
[Mon Dec 22 19:52:37.100694 2014] [authz_core:debug] [pid 17524:tid 139805499234048] mod_authz_core.c(802): [client 127.0.0.1:38934] AH01626: authorization result of <RequireAny>: granted
[Mon Dec 22 19:52:37.184903 2014] [authz_core:debug] [pid 17524:tid 139805490841344] mod_authz_core.c(802): [client 127.0.0.1:38934] AH01626: authorization result of Require all granted: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.184927 2014] [authz_core:debug] [pid 17524:tid 139805490841344] mod_authz_core.c(802): [client 127.0.0.1:38934] AH01626: authorization result of <RequireAny>: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.186510 2014] [authz_core:debug] [pid 17519:tid 139805499234048] mod_authz_core.c(802): [client 127.0.0.1:38935] AH01626: authorization result of Require all granted: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.186549 2014] [authz_core:debug] [pid 17519:tid 139805499234048] mod_authz_core.c(802): [client 127.0.0.1:38935] AH01626: authorization result of <RequireAny>: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.187952 2014] [authz_core:debug] [pid 17524:tid 139805413340928] mod_authz_core.c(802): [client 127.0.0.1:38934] AH01626: authorization result of Require all granted: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.187977 2014] [authz_core:debug] [pid 17524:tid 139805413340928] mod_authz_core.c(802): [client 127.0.0.1:38934] AH01626: authorization result of <RequireAny>: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.189887 2014] [authz_core:debug] [pid 17524:tid 139805404948224] mod_authz_core.c(802): [client 127.0.0.1:38934] AH01626: authorization result of Require all granted: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.189901 2014] [authz_core:debug] [pid 17524:tid 139805404948224] mod_authz_core.c(802): [client 127.0.0.1:38934] AH01626: authorization result of <RequireAny>: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.191484 2014] [authz_core:debug] [pid 17519:tid 139805490841344] mod_authz_core.c(802): [client 127.0.0.1:38935] AH01626: authorization result of Require all granted: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.191502 2014] [authz_core:debug] [pid 17519:tid 139805490841344] mod_authz_core.c(802): [client 127.0.0.1:38935] AH01626: authorization result of <RequireAny>: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.242167 2014] [authz_core:debug] [pid 17524:tid 139805396555520] mod_authz_core.c(802): [client 127.0.0.1:38934] AH01626: authorization result of Require all granted: granted, referer: http://127.0.0.1:38082/
[Mon Dec 22 19:52:37.242193 2014] [authz_core:debug] [pid 17524:tid 139805396555520] mod_authz_core.c(802): [client 127.0.0.1:38934] AH01626: authorization result of <RequireAny>: granted, referer: http://127.0.0.1:38082/
存取日志
127.0.0.1 - - [22/Dec/2014:19:52:37 +0800] "GET / HTTP/1.1" 200 5339
127.0.0.1 - - [22/Dec/2014:19:52:37 +0800] "GET /css/bootstrap.min.css HTTP/1.1" 200 99548
127.0.0.1 - - [22/Dec/2014:19:52:37 +0800] "GET /css/style.css HTTP/1.1" 200 1042
127.0.0.1 - - [22/Dec/2014:19:52:37 +0800] "GET /css/bootstrap-theme.min.css HTTP/1.1" 200 13135
127.0.0.1 - - [22/Dec/2014:19:52:37 +0800] "GET /js/jquery.min.js HTTP/1.1" 200 93107
127.0.0.1 - - [22/Dec/2014:19:52:37 +0800] "GET /js/bootstrap.min.js HTTP/1.1" 200 27822
127.0.0.1 - - [22/Dec/2014:19:52:37 +0800] "GET /img/zf2-logo.png HTTP/1.1" 200 738
apache从nginx访问时记录
存取日志
127.0.0.1 - - [22/Dec/2014:20:29:08 +0800] "GET /index.php HTTP/1.0" 404 2345
错误日志
[Mon Dec 22 20:29:08.387773 2014] [authz_core:debug] [pid 20897:tid 140375947659008] mod_authz_core.c(802): [client 127.0.0.1:39363] AH01626: authorization result of Require all granted: granted
[Mon Dec 22 20:29:08.387818 2014] [authz_core:debug] [pid 20897:tid 140375947659008] mod_authz_core.c(802): [client 127.0.0.1:39363] AH01626: authorization result of <RequireAny>: granted
ngnix访问日志。没有错误日志
127.0.0.1 - - [22/Dec/2014:20:29:08 +0800] "GET / HTTP/1.1" 404 2345 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" "-"
127.0.0.1 - - [22/Dec/2014:20:29:08 +0800] "GET /css/bootstrap.min.css HTTP/1.1" 200 99548 "http://127.0.0.1:8082/" "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" "-"
127.0.0.1 - - [22/Dec/2014:20:29:08 +0800] "GET /css/bootstrap-theme.min.css HTTP/1.1" 200 13135 "http://127.0.0.1:8082/" "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" "-"
127.0.0.1 - - [22/Dec/2014:20:29:08 +0800] "GET /css/style.css HTTP/1.1" 200 1042 "http://127.0.0.1:8082/" "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" "-"
127.0.0.1 - - [22/Dec/2014:20:29:08 +0800] "GET /js/jquery.min.js HTTP/1.1" 200 93107 "http://127.0.0.1:8082/" "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" "-"
127.0.0.1 - - [22/Dec/2014:20:29:08 +0800] "GET /js/bootstrap.min.js HTTP/1.1" 200 27822 "http://127.0.0.1:8082/" "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" "-"
127.0.0.1 - - [22/Dec/2014:20:29:08 +0800] "GET /img/zf2-logo.png HTTP/1.1" 200 738 "http://127.0.0.1:8082/" "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" "-"
答案 0 :(得分:0)
我认为你错过了一些标题。尝试添加这样的东西:
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:38082;
}
我注意到日志之间的区别是http版本。我添加了一条强制执行1.1(检查)的规则 - 希望它有效