How to host codeigniter4 website on sharehosting? [closed]

半城伤御伤魂 提交于 2020-05-31 04:53:10

问题


I have just created a codeigniter4 project and I want to upload it on sharehosting. But my website is not accesible, it gives server error.


回答1:


For security reason codeigniter4 folder is made suchg a way that all the libraried and code folder is outside the public folder. By url only public folder is accesible. To host it on share hosting your directory structure should look like this.

--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)

Now you need to change some values to up and running your codeigniter4 project

  • In public_html folder index.php file chnage the $pathsPath = FCPATH . '../app/Config/Paths.php'; to $pathsPath = FCPATH . '../codeigniter/app/Config/Paths.php';

  • In app/Config folder App.php file change $baseURL = 'http://192.168.0.111/'; to $baseURL = 'http://yourdomain.com/';.

After this chnage your site will be up and running. To deploy in subdomain and if your subdomain root folder lies in public_html then you should change $pathsPath = FCPATH . '../app/Config/Paths.php'; to $pathsPath = FCPATH . '../../codeigniter/app/Config/Paths.php'; in public_html/yourdomain folder index.php file, followed that directory structure remains same. Important: public folder content should be placed in your subdomain folder.



来源:https://stackoverflow.com/questions/61808444/how-to-host-codeigniter4-website-on-sharehosting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!