How To Install CodeIgniter on Rocky Linux 9
In this tutorial, we will show you how to install CodeIgniter on Rocky Linux 9. For those of you who didn’t know, CodeIgniter, a powerful PHP framework, provides developers with a robust platform for building dynamic and feature-rich web applications. When paired with the stability and security of Rocky Linux 9, a leading enterprise-level operating system, you can create cutting-edge web projects.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the CodeIgniter on Rocky Linux 9 or RHEL-based.
Prerequisites
- A server running one of the following operating systems: Rocky Linux 9.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for CodeIgniter.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install CodeIgniter on Rocky Linux 9
Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:
sudo dnf update
Step 2. Installing LAMP Stack
The LAMP stack (Linux, Apache, MySQL, PHP) forms the backbone of many web applications. You can follow our guide here.
Step 3. Configure Apache for CodeIgniter.
Setting up virtual hosts for CodeIgniter ensures a clean URL structure and enhances the application’s performance:
cd /etc/httpd/conf.d/ sudo nano codeigniter.conf
Add the Following Configuration:
<VirtualHost *:80> ServerAdmin webmaster@example.com DocumentRoot /var/www/html/codeigniter ServerName your_domain.com <Directory /var/www/html/codeigniter> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog /var/log/httpd/codeigniter_error.log CustomLog /var/log/httpd/codeigniter_access.log combined </VirtualHost>
Enable the Virtual Host and Restart Apache:
sudo a2ensite codeigniter.conf sudo systemctl restart httpd
Step 4. Downloading and Installing CodeIgniter.
Now visit the official CodeIgniter website to download the latest version. Alternatively, use wget
or curl
to download the package directly:
cd /tmp wget https://codeload.github.com/codeigniter4/framework/legacy.zip/refs/tags/v4.3.6
Extract the downloaded archive and move the files to the web server’s root directory:
unzip codeigniter4-framework-v4.3.6-0-ge392123.zip sudo mv ccodeigniter4-framework-v4.3.6-0-ge392123 /var/www/html/codeigniter
Ensure the correct permissions and ownership for CodeIgniter files and directories:
sudo chown -R apache:apache /var/www/html/codeigniter sudo chmod -R 755 /var/www/html/codeigniter
Step 5. Verifying the Installation
Let’s validate the successful installation of CodeIgniter on Rocky Linux 9:
cd /var/www/html/codeigniter/application/controllers sudo nano Welcome.php
Add the following code to the file:
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Welcome extends CI_Controller { public function index() { $this->load->view('welcome_message'); } }
Create a Sample View:
cd /var/www/html/codeigniter/application/views sudo nano welcome_message.php
Add the following HTML to the file:
<!DOCTYPE html> <html> <head> <title>Welcome to CodeIgniter Idroot.Us</title> </head> <body> <h1>Hello, CodeIgniter!</h1> </body> </html>
Save the file, then open your web browser and enter your server’s IP address or domain name in the address bar. You should see the welcome message, confirming that CodeIgniter is successfully installed.
Congratulations! You have successfully installed CodeIgniter. Thanks for using this tutorial for installing the CodeIgniter PHP framework on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official CodeIgniter website.