web服务器上带有Codeigniter 4的空白页



我将我的项目上传到了web服务器,根据安全建议,我将CodeIgniter 4文件放在了服务器的非公共目录中:/home/user/codeigniter

和在公共目录中:/home/user/public_html

这是我的路:$pathsPath = FCPATH. '../codeigniter/app/Config/Paths.php';

我把所有的文件都放得很好;

|__ public_html (or your domain root folder)
| |assets
| |index.php
| |.htaccess
|
|__ codeigniter
|__ app
|__ system
|__ writable
|__ .env

但我总是收到一张空白页。你能帮我处理这个问题吗?

error.log为:

RITICAL - 2020-10-14 06:12:09 --> ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
#0 [internal function]: CodeIgniterDebugExceptions->errorHandler(2, 'ini_set(): Head...', '/home/catideko/...', 101, Array)

我已经解决了这个问题。问题的根源在于";zlib_output_compression";在我的主人。应该是";关闭";位置在cpanel上,将位置更改为";关闭";一切顺利。

这是错误的$pathsPath = FCPATH. '../codeigniter/app/Config/Paths.php';你不能像那样一起使用FCPATH..,你必须提供完整的路径,比如$pathsPath = '/home/user/codeigniter/app/Config/Paths.php';

还要确保路径/home/user/codeigniter可由php访问,或者您需要在php.ini中包含该路径,或者在index.php 中设置该路径

set_include_path(get_include_path() . PATH_SEPARATOR . '/home/user/codeigniter');

然后确认您的路径是否包括

echo get_include_path();

然后按照官方指南确认您是否正确更新了所有路径

所有设置完成后,请确保您的可写文件夹已设置了写入权限。并且您的App.php包含

public $sessionSavePath          = WRITEPATH . 'session';

虽然上面的设置会起作用,但我建议您坚持默认的composer安装和路径

composer create-project codeigniter4/appstarter project-root

这将确保CI4升级时的无缝更新,使您的应用程序更安全。限制对可写文件夹的访问,就像nginx/apache一样,您可以限制从这些文件夹打开哪种类型的文件。

最新更新