Welcome Guest, Not a member yet? Register   Sign In
Install CodeIgniter 4 on Shared Hosting (cPanel)

cPanel is a Linux-based web hosting control panel that provides a powerful set of automation tools in an easy and
straightforward interface, allowing a simplified process for hosting websites.

The contents of CodeIgniter's public folder should be placed in your domain's Document Root, in cPanel's case it's
called public_html for your Main Domain. Here is an example of a directory structure that are created by cPanel:


All other Default Directories should be placed in your Home Directory /home/username/ referred to as / above. But this will just turn into a mess as it's difficult to see what folder/files belong to cPanel and/or CodeIgniter.

Therefor it's recommended to create another folder named after your domain name in your home directory,
and place all other folders and files (refer to ... below) in it. This makes the final structure look like this:


Since we changed the directory structure we have to tell CodeIgniter about it. Open /public_html/index.php
in a text editor and change the following line to match your domain name directory that we previously created.

PHP Code:
$pathsPath FCPATH '../example.com/app/Config/Paths.php'

The next step are to make sure you have the correct PHP version and dependencies activated. Under Software you will find Select PHP Version - on this page we are going to change Current PHP version into 7.2 or later. At the creation of this thread, 7.4 are the latest version, so select that one.

We also need to make sure that we have the correct PHP extensions enabled, based on Server Requirements in the user guide.

pdo_mysql (if available)

nd_pdo_mysql (if available)

Optional - Image Manipulation (only need one)

Optional - cURL
Should already be enabled, and you generally don't have an option to disable/enable it. If it dosen't work, contact your web hosting provider.

The requirements are named a little differently from the user guide, as cPanel works from PHP 4.4 and above, so they have had to rename them.

(This post was last modified: 03-20-2024, 04:04 PM by kenjis.)

Since v4.2.0, the following line in public/index.php has been changed:

PHP Code:
$pathsConfig FCPATH '../app/Config/Paths.php';

require FCPATH '../app/Config/Paths.php'

Theme © iAndrew 2016 - Forum software by © MyBB