0

我刚刚创建了一个 codeigniter4 项目,我想将它上传到共享主机上。但是我的网站无法访问,它给出了服务器错误。

4

1 回答 1

1

出于安全原因,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)

现在您需要更改一些值以启动并运行您的 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';public_html/yourdomain文件夹index.php文件中,然后该目录结构保持不变。重要提示:公用文件夹内容应放在您的子域文件夹中。

于 2020-05-14T22:56:24.003 回答