简体   繁体   English

CodeIgniter项目加载空白网页

[英]CodeIgniter project loads blank webpage

I have a codeigniter project that I have run successfully on Mac OS X Lion. 我有一个已经在Mac OS X Lion上成功运行的codeigniter项目。 When attempting to run the same project in ubuntu, requesting localhost/project results in a blank page with no source. 尝试在ubuntu中运行同一项目时,请求localhost / project会导致空白页面没有源。

I've added AllowOverride All to apache.conf to no avail. 我已经将AllowOverride All添加到apache.conf中,但没有成功。 My latest strategy has been to put a die() statement in strategic places in the index and included files, trying to find the line on which the code fails. 我的最新策略是将die()语句放在索引和包含文件中的重要位置,试图找到代码失败的行。 Through this method, I've found in system/core/CodeIgniter.php that a die statement before the line "$CI = new $class();" 通过这种方法,我在system / core / CodeIgniter.php中发现在“ $ CI = new $ class();”行之前的一条die语句。 executes, while one after it (and presumably all ensuing code) doesn't. 执行,而后面的一个(大概所有随后的代码)则不执行。

What can I do with this information to help me run this project locally? 我可以使用这些信息做什么来帮助我在本地运行该项目?

Thank you! 谢谢!

I had the same blank page when I started working with CI. 开始使用CI时,我有相同的空白页。

For me, it was just that I forgot to install mySQL on my machine. 对我来说,只是我忘了在机器上安装mySQL。 You don't get errors because in the system files, the database connection is preceded by a "@" so no errors are displayed. 您不会收到错误,因为在系统文件中,数据库连接前面带有“ @”,因此不会显示任何错误。

If this is not the problem, check your version of PHP, or try to add a phpinfo() in the index.php file. 如果这不是问题,请检查您的PHP版本,或尝试在index.php文件中添加phpinfo()。

I've ended up with a similar issue only in reverse - worked on Ubuntu but then got nothing on OS X. I did have mysql installed and other sites running just fine on same server. 我最终遇到了一个类似的问题,只是反向运行-在Ubuntu上工作,但在OS X上却什么也没有。我确实安装了mysql,并且其他站点在同一台服务器上运行得很好。 For me there were two culprits, may be this will help you too: 对我来说,有两个罪魁祸首,也许对您也有帮助:

  1. Your logs directory isn't writable. 您的日志目录不可写。 Usually the directory is application/logs unless you have some custom config setup. 通常目录是应用程序/日志,除非您有一些自定义配置设置。 ( http://codeigniter.com/user_guide/general/errors.html ) This won't just affect all those log_message(...) function calls, it will also fail when the Loader class tries to load the Log library. http://codeigniter.com/user_guide/general/errors.html )这不仅会影响所有那些log_message(...)函数调用,而且在Loader类尝试加载日志库时也会失败。 If this is the case, changing the logging levels in the config (as often suggested) will not produce any helpful results because, well, CI can't actually write any of the errors. 如果是这种情况,更改配置中的日志记录级别(通常建议)将不会产生任何有用的结果,因为CI 实际上无法写入任何错误。

  2. You might be missing some other php library that is installed on the server where it's working. 您可能会缺少正在工作的服务器上安装的其他php库。 For me it was a missing memcached php extension so Loader class was also failing when trying to initialize the Session class (a custom extended version of it though). 对我来说,这是一个缺少的memcached php扩展,因此,在尝试初始化Session类时,Loader类也失败了(尽管是该类的自定义扩展版本)。 This one might be more difficult to debug if you don't know for certain what extensions are required (like joining in on an existing project with a lot of extras on top of basic CI install). 如果您不确定是否需要什么扩展,则可能更难调试(例如,加入现有项目并在基本CI安装的基础上添加许多其他功能)。 So, next step would be to go and try putting those die(...) statements through the Loader class to see what actually fails to load. 因此,下一步将是尝试将那些die(...)语句放入Loader类,以查看实际无法加载的内容。

Did you by any chance put any white space or new lines after ending PHP tag in some of your files? 在某些文件中结束PHP标记后,是否有任何机会在空白处或换行了吗? If so - delete them along with closing PHP tag. 如果是这样-删除它们并关闭PHP标记。

(PS In code igniter you should never close PHP tags in files which contain only PHP code - Controller, Model,...) (PS在代码点火器中,永远不要关闭仅包含PHP代码的文件中的PHP标记-控制器,模型等)。

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

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