• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Install CodeIgniter 4 on shared hosting

#1
Hi everybody, I'm new to programming with CodeIgniter and am having trouble installing it in a production environment on shared hosting. I know the subject has been dealt with on other posts but still have not found a solution.

I'm trying to install the news sample app used on the CodeIgniter tutorial. I own the domain jordivid.com, where I'm building a portfolio. My root folder is /usr/home/jordivid.me, and documents are placed under /web folder, here I have files for my site and some folders where subdomains are located, the /test folder holds the sample app.

So I created the subdomain test.jordivid.com to test a production install that points to the physical folder /usr/home/jordivid.me/web/test/. After investigating the way to install the app in production here's what  did:
  • Install all files and folders under the root folder of the subdomain (/usr/home/jordivid.me/web/test/).
  • Modify the .env file like this:
          CI_ENVIRONMENT = production   
             ...
           database.default.hostname = test.jordivid.me
  • Move the contents of the /public folder to the document root folder (/test).
     
  • As index.php had moved one folder upwards, I modified the $pathsPath var inside and left it like this:
    $pathsPath = realpath(FCPATH . 'app/Config/Paths.php');
  • Modified $baseURL var in app/Config/App.php:
    public $baseURL = 'http://test.jordivid.me/';
Home page of the app appears ok at the address test.jordivid.me, but when I try any route I get an internal server error, looking at the errors log it displays:

"AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace."

After reading the thread https://forum.codeigniter.com/thread-759...ed+hosting I made a the folder /test.jordivid.me one level up from /test and changed the $pathsPath var to:

     $pathsPath = FCPATH . '../test.jordivid.me/app/Config/Paths.php';

The result is the same. I must be doing something wrong or either there's some step I've left. My guess is that I should modify the .htaccess file, which currently is that in the tutorial unmodified, but after looking for some info on it I don't find the solution. Could anyone please help?
Reply

#2
The easy way

Don't move content from /public to /test. Set document root for the test.jordivid.com domain as /usr/home/jordivid.me/web/test/public
Reply

#3
Thanks for your answer, I did that.
Unfortunately the result is the same, I keep getting "AH00124: Request exceeded the limit of 10 internal redirects ...." when trying any route.
Reply

#4
Check for .htaccess in the public directory
Reply

#5
It's there, it's the .htaccess unmodified that comes with CI when installed with composer, that is:

Options All -Indexes

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

        RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^(.*)/$ /$1 [L,R=301]

        RewriteCond %{HTTPS} !=on
       RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
       RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

        RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 index.php
</IfModule>

My guess is that the solution would be a rule in .htaccess. In development I use XAMMP, I have set up a virtual host whose document root points to /public folder, just as in production the subdomain points to that folder too, in development the app runs ok, so I think the problem is in the server config. But I have not found which rule I could use in this case.
Reply

#6
As an experiment, can you create a subdomain outside the web directory and install clean CI there?
Reply

#7
It is not possible, that is the root folder for the hosting. When I create a subdomain it is placed under jordivid.me/web folder.
Reply

#8
Could it be that your hosting does not support .htaccess?
Reply

#9
Finally I've found the solution. Now .htaccess is like this:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

I had the idea to use same settings that a couple Laravel apps on other subdomains are using, since the operations they do are similar, and it works. Now the problem is I can't access database, but if I cant't solve that I guess it would be a subject for another thread.

Thanks for your help.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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