我刚刚创建了一个 codeigniter4 项目,我想将其上传到 sharehosting 上。但我的网站无法访问,它给出了服务器错误。
小智 5
出于安全原因,codeigniter4 文件夹的创建方式使得所有库和代码文件夹都位于公共文件夹之外。通过 url 只能访问公共文件夹。要将其托管在共享托管上,您的目录结构应如下所示。
--home/root (sharehosting root directory)
|__ public_html (or your domain root folder)
| |__assets
| |__ index.php
| |__ .htaccess
|
|__ codeigniter (create a folder with any name you like)
|__ app(all the files and folder in app folder)
|__ system
|__ writable
|__ .env (dot env file here)
Run Code Online (Sandbox Code Playgroud)
现在您需要更改一些值来启动并运行您的 codeigniter4 项目
在public_html文件夹中的index.php文件更改$pathsPath = FCPATH . '../app/Config/Paths.php';为$pathsPath = FCPATH . '../codeigniter/app/Config/Paths.php';
在app/Config文件夹中App.php文件更改$baseURL = 'http://192.168.0.111/';为 $baseURL = 'http://yourdomain.com/';.
在此更改后,您的网站将启动并运行。要在子域中部署,如果您的子域根文件夹位于 public_html 中,那么您应该更改$pathsPath = FCPATH . '../app/Config/Paths.php';为$pathsPath = FCPATH . '../../codeigniter/app/Config/Paths.php';inpublic_html/yourdomain文件index.php夹文件,然后目录结构保持不变。重要提示:公用文件夹内容应放置在您的子域文件夹中。
| 归档时间: |
|
| 查看次数: |
6797 次 |
| 最近记录: |