Php 如何正确配置nginx和apache for zendframework2
环境 CentOS 6.5 x86_64 PHP 5.6.3 httpd 2.4.10 Nginx 1.6.2 ZendFramework 2.3.3 目标 安装ZF2骨架应用程序 现在 我将nginx配置为将php文件传递给apache。我在nginx或apache中将zf2骨架应用程序配置为虚拟主机。我手动安装zendframework2.3.3。我可以通过httpd配置的127.0.0.1:38082正常访问网站。然而,当我通过nginx配置的127.0.0.1:8082访问该网站时,我得到了404错误,如下所示。谁能给我一些建议?谢谢 我的配置 Nginx vhost httpd vhost 日志 直接从apache使用127.0.0.1:38082时,apache会记录日志 错误日志 从nginx访问时,apache会记录日志 访问日志 错误日志Php 如何正确配置nginx和apache for zendframework2,php,apache,nginx,zend-framework2,Php,Apache,Nginx,Zend Framework2,环境 CentOS 6.5 x86_64 PHP 5.6.3 httpd 2.4.10 Nginx 1.6.2 ZendFramework 2.3.3 目标 安装ZF2骨架应用程序 现在 我将nginx配置为将php文件传递给apache。我在nginx或apache中将zf2骨架应用程序配置为虚拟主机。我手动安装zendframework2.3.3。我可以通过httpd配置的127.0.0.1:38082正常访问网站。然而,当我通过nginx配置的127.0.0.1:8082访问该网站时,我得
我认为你遗漏了一些标题。尝试添加如下内容:
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版的检查-希望它能起作用我非常累,所以请在这里输入Spitball,但是,嗯…您可能需要$uri作为结尾:proxy_passhttp://127.0.0.1:38082$uri;我也没有在这里读到整面墙的文字,所以有点小题大做,不过还是试试吧。谢谢@Deryck,它不起作用。你为什么要使用两台web服务器?如果您需要Nginx,您可以转储Apache并使用php fpmWell,在使用zf2@michaelbn时,应该有一种方法将Nginx和Apache配置在一起。无论如何,谢谢你的考虑。嗨,你成功了吗?如果是这样的话,你能分享经验吗。我可以肯定php文件将传递给apache进行部署。实际上index.php是apache第一次部署的。但是页面的某些部分似乎找不到。是的,我可以看到它在路由上失败了。当您从Nginx访问以及直接从ApacheNot访问时,请向我展示apache日志中的相关行。第二次似乎找不到/index.php。让我们来看看。
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
[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
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
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" "-"
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;
}