macos CodeIgniter 项目加载空白网页
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7486872/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CodeIgniter project loads blank webpage
提问by Emmett Butler
I have a codeigniter project that I have run successfully on Mac OS X Lion. When attempting to run the same project in ubuntu, requesting localhost/project results in a blank page with no source.
我有一个在 Mac OS X Lion 上成功运行的 codeigniter 项目。当尝试在 ubuntu 中运行相同的项目时,请求 localhost/project 会导致一个没有源的空白页面。
I've added AllowOverride All to apache.conf to no avail. 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. Through this method, I've found in system/core/CodeIgniter.php that a die statement before the line "$CI = new $class();" executes, while one after it (and presumably all ensuing code) doesn't.
我已将 AllowOverride All 添加到 apache.conf 无济于事。我的最新策略是在索引和包含文件的关键位置放置 die() 语句,试图找到代码失败的行。通过这种方法,我在 system/core/CodeIgniter.php 中发现了“$CI = new $class();”行之前的die语句 执行,而它之后的一个(可能是所有随后的代码)没有。
What can I do with this information to help me run this project locally?
我可以用这些信息做什么来帮助我在本地运行这个项目?
Thank you!
谢谢!
回答by Nugget
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. You don't get errors because in the system files, the database connection is preceded by a "@" so no errors are displayed.
对我来说,只是我忘记在我的机器上安装 mySQL。您不会收到错误,因为在系统文件中,数据库连接以“@”开头,因此不会显示任何错误。
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()。
回答by Goran
Did you by any chance put any white space or new lines after ending PHP tag in some of your files? If so - delete them along with closing PHP tag.
在某些文件中结束 PHP 标记后,您是否有任何机会添加任何空格或新行?如果是这样 - 删除它们并关闭 PHP 标记。
(P.S. In code igniter you should never close PHP tags in files which contain only PHP code - Controller, Model,...)
(PS 在代码点火器中,您永远不应该关闭仅包含 PHP 代码的文件中的 PHP 标记 - 控制器、模型……)
回答by Anna T
I've ended up with a similar issue only in reverse - worked on Ubuntu but then got nothing on OS X. I didhave mysql installed and other sites running just fine on same server. For me there were two culprits, may be this will help you too:
我以相反的方式结束了类似的问题 - 在 Ubuntu 上工作,但后来在 OS X 上一无所获。我确实安装了 mysql,其他站点在同一台服务器上运行得很好。对我来说有两个罪魁祸首,也许这也会对你有帮助:
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. 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 writeany of the errors.
You might be missing some other php library that is installed on the server where it's working. 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). 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). So, next step would be to go and try putting those die(...) statements through the Loader class to see what actually fails to load.
您的日志目录不可写。通常目录是应用程序/日志,除非您有一些自定义配置设置。( http://codeigniter.com/user_guide/general/errors.html) 这不仅会影响所有这些 log_message(...) 函数调用,它也会在 Loader 类尝试加载 Log 库时失败。如果是这种情况,更改配置中的日志记录级别(如通常建议的那样)不会产生任何有用的结果,因为 CI实际上无法写入任何错误。
您可能会遗漏安装在其运行的服务器上的其他一些 php 库。对我来说,这是一个缺失的 memcached php 扩展,因此在尝试初始化 Session 类(尽管是它的自定义扩展版本)时,Loader 类也失败了。如果您不确定需要哪些扩展(例如加入现有项目,并在基本 CI 安装之上添加许多附加功能),则调试这个可能会更困难。因此,下一步是尝试将这些 die(...) 语句放入 Loader 类中,以查看实际加载失败的内容。