简体   繁体   English

Zend Framework 2 LAMP在Windows上工作时返回404错误

[英]Zend framework 2 LAMP returns 404 error while it was working on windows

I have an application running perfectly on my windows as well as CentOS server, but recently I have changed my OS from windows to Ubuntu. 我有一个可以在Windows以及CentOS服务器上完美运行的应用程序,但是最近我将操作系统从Windows更改为Ubuntu。 Now public folder is called it triggers onBootStrap where I have custom logic to check if not logged in then redirect to loginAction of default Controller. 现在public文件夹名为它触发onBootStrap在那里我有自定义的逻辑来检查,如果没有登录,然后重定向到loginAction默认控制器。 Which redirects fine but none of the controller is working they returns 404 error . 重定向正确,但没有控制器在工作,它们返回404 error

Even my public controllers are not accessible. 甚至我的公共控制器也无法访问。

Am I missing any dependent extension? 我是否缺少任何依赖扩展?

Could it be some directory separators are \\ and not / ? 可能是某些目录分隔符是\\而不是/吗? If these are hard coded in, try replacing them with PHP constant DIRECTORY_SEPARATOR anywhere you have them, like so: 如果这些是硬编码的,请尝试在任何有它们的地方用PHP常量DIRECTORY_SEPARATOR替换它们,如下所示:

require_once 'path'.DIRECTORY_SEPARATOR.'to'.DIRECTORY_SEPARATOR.'file';

instead of: 代替:

require_once 'path/to/file';

There are several issues when developing in windows, and that's just one of them. 在Windows中进行开发时存在多个问题,而这只是其中之一。 Case insensitivity and character encoding are other problems you will face. 不区分大小写和字符编码是您还将面临的其他问题。

An easier solution than re-configuring everything in your site (or wamp/xampp etc) would be a portable development server setup you can share with your team, so I recommend you try a VM! 与重新配置站点中的所有内容(或wamp / xampp等)相比,一种简单的解决方案是可以与团队共享的便携式开发服务器设置,因此建议您尝试VM!

Download Vagrant and VirtualBox first. 首先下载Vagrant和VirtualBox。 Then if you go to puphpet.com, you can fill in a form to configure your development server. 然后,如果您访问puphpet.com,则可以填写表格以配置您的开发服务器。 Make it match as closely to your production server as possible. 使它与您的生产服务器尽可能匹配。

Once you finish filling in the form, download the configuration zip, unzip it, cd into the folder, and type vagrant up . 填写完表格后,下载配置zip,解压缩,cd进入文件夹,然后输入vagrant up It takes a while first time araound, but when it's ready, you will have a full Linux server, and if you share the zip, everyone on your team will have identical setups, whether on Windows, Linux, or Mac. 第一次需要一段时间,但是准备就绪后,您将拥有完整的Linux服务器,并且如果共享zip,则团队中的每个人都将具有相同的设置,无论是在Windows,Linux还是Mac上。

Anyway, if you intend to keep devving natively in windows, check your php error_log 无论如何,如果您打算继续在Windows中进行本机开发,请检查您的php error_log

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

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