• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run codeigniter4 in shared hosting ?

#11
(03-25-2020, 01:40 PM)jreklund Wrote: That's correct. If you upload everything as is (renaming /public into /public_html), you will end up with the following structure in Cpanel, based upon /.
/public_html are always your main domains document root, and that can't be changed. Only subdomain and addon domains have that ability (through Cpanel itself).


Code:
|  .gitignore
|  composer.json
|  contributing.md
|  env
|  LICENSE
|  license.txt
|  phpunit.xml.dist
|  README.md
|  spark

+---app             
+---public_html
|      .htaccess
|      favicon.ico
|      index.php
|      robots.txt
|     
+---system
+---tests
+---writable


And that can also cause som clutter, if you want to have another website later on (subdomains / addon domains) with different Document root.
And here you can actually create /subdomain.domain.com/public as the document root. And upload the CI folder into /subdomain.domain.com and it will work out of the box.

My recommendation are always placing codeigniter4 files inside another folder, so that you don't clutter /, the folder name codeigniter4 can be whatever you want. May be the domain name.


Code:
+---codeigniter4
|  |  .gitignore
|  |  composer.json
|  |  contributing.md
|  |  env
|  |  LICENSE
|  |  license.txt
|  |  phpunit.xml.dist
|  |  README.md
|  |  spark
|  | 
|  +---app
|  +---system
|  +---tests           
|  +---writable
|             
\---public_html
        .htaccess
        favicon.ico
        index.php
        robots.txt


But for this trick to work, you need to open your /public_html/index.php and change into the following:
PHP Code:
$pathsPath FCPATH '../codeigniter4/app/Config/Paths.php'

Thanks Buddy! its working  Smile
Reply

#12
(03-25-2020, 01:53 PM)shahadathossain Wrote: Thanks Buddy! its working  Smile

Great! Will add this to the to-do list of tutorials for the new "learning center" in the userguide/website.
Reply

#13
(03-25-2020, 12:15 PM)captain-sensible Wrote: If i have done anything to mislead @shahadathossain or if i have not understood his issue i have no problem in being told in what way. Where i am coming from is from a point of using shared hosting and successfully having codeigniter 4.0.0-rc3 work on live hosting with https.

In this case, your post had the most correct answer. But you will need to take OP knowledge and question into account. In this particular case it where how to deal with the contents of /public/ on shared hosting. And depending on control panel, you can't do everything the same way. So that's something that needs to be established first, or give them all options. In this case your suggestion on redirecting document root don't work (in Cpanel) and other steps are needed.

Your answer also somewhat scope creeped a little as you provided Lets Encrypt into the mix, as that are a different subject. Setting a baseURL are good, but for getting the first welcome message, it's not needed.
Reply

#14
(03-25-2020, 02:23 PM)jreklund Wrote:
(03-25-2020, 12:15 PM)captain-sensible Wrote: If i have done anything to mislead @shahadathossain or if i have not understood his issue i have no problem in being told in what way. Where i am coming from is from a point of using shared hosting and successfully having codeigniter 4.0.0-rc3 work on live hosting with https.

In this case, your post had the most correct answer. But you will need to take OP knowledge and question into account. In this particular case it where how to deal with the contents of /public/ on shared hosting. And depending on control panel, you can't do everything the same way. So that's something that needs to be established first, or give them all options. In this case your suggestion on redirecting document root don't work (in Cpanel) and other steps are needed.

Your answer also somewhat scope creeped a little as you provided Lets Encrypt into the mix, as that are a different subject. Setting a baseURL are good, but for getting the first welcome message, it's not needed.
ok thanks for clarification
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.