在Ubuntu的Apache2服务器上运行CodeIgniter 4时页面显示PHP代码片段的问题求助
在Ubuntu的Apache2服务器上运行CodeIgniter 4时页面显示PHP代码片段的问题求助
大家好,我最近在Ubuntu的Apache2服务器上部署CodeIgniter 4项目时遇到了棘手的问题,想请各位帮忙排查一下:
我已经完成了以下配置操作:
- 修改了hosts文件设置虚拟主机,内容如下:
127.0.0.1 du-accurate.local 127.0.0.1 localhost 127.0.1.1 X1-Cabron - 启用了Apache的mod_rewrite模块,执行的命令是:
sudo a2enmod rewrite
但当我在本地访问du-accurate.local时,浏览器并没有正常加载网站,反而直接把index.php里的一段PHP代码当成纯文本显示出来了,具体显示的代码内容如下:
systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php'; // Load environment settings from .env files into $_SERVER and $_ENV require_once SYSTEMPATH . 'Config/DotEnv.php'; (new CodeIgniter\Config\DotEnv(ROOTPATH))->load(); // Define ENVIRONMENT if (! defined('ENVIRONMENT')) { define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production')); } // Load Config Cache // $factoriesCache = new \CodeIgniter\Cache\FactoriesCache(); // $factoriesCache->load('config'); // ^^^ Uncomment these lines if you want to use Config Caching. /* * --------------------------------------------------------------- * GRAB OUR CODEIGNITER INSTANCE * --------------------------------------------------------------- * * The CodeIgniter class contains the core functionality to make * the application run, and does all the dirty work to get * the pieces all working together. */ $app = Config\Services::codeigniter(); $app->initialize(); $context = is_cli() ? 'php-cli' : 'web'; $app->setContext($context); /* *--------------------------------------------------------------- * LAUNCH THE APPLICATION *--------------------------------------------------------------- * Now that everything is set up, it's time to actually fire * up the engines and make this app do its thang. */ $app->run(); // Save Config Cache // $factoriesCache->save('config'); // ^^^ Uncomment this line if you want to use Config Caching. // Exits the application, setting the exit code for CLI-based applications // that might be watching. exit(EXIT_SUCCESS);
这段代码完全没有被PHP解析执行,就这么直白地显示在页面上,我实在搞不懂哪里出问题了,有没有大佬能指点一下?
备注:内容来源于stack exchange,提问作者dontknowanything
相关产品推荐
相关产品推荐

