Welcome Guest, Not a member yet? Register   Sign In
Install CodeIgniter 4 on shared hosting

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?

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

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.

Check for .htaccess in the public directory

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 !mod_rewrite.c>
    ErrorDocument 404 index.php

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.

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

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.

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

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]

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.

Theme © iAndrew 2016 - Forum software by © MyBB