In this tutorial, we will show you how to install CodeIgniter on Manjaro. CodeIgniter is a powerful PHP framework that allows developers to build dynamic web applications with ease. If you’re a Manjaro Linux user, you’re in luck because in this comprehensive guide, we’ll walk you through the process of installing CodeIgniter on your Manjaro system using the Command Line Interface (CLI).
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 a Manjaro Linux.
- A server or desktop running one of the following operating systems: Manjaro, and other Arch-based distributions.
- 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.
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install CodeIgniter on Manjaro
Step 1. Before running the tutorial below, make sure that our system is up to date:
sudo pacman -Syu sudo pacman -S base-devel
Step 2. Installing Essential Dependencies.
To run CodeIgniter, you need PHP. Install PHP and its required extensions:
sudo pacman -S php php-apache
We’ve already installed PHP, but let’s confirm it’s properly set up:
Composer is a crucial tool for managing CodeIgniter dependencies. Let’s install it globally:
sudo pacman -S composer
Composer simplifies dependency management. Let’s install it globally:
We’ll use Apache as the web server for our CodeIgniter application. Install Apache with the following command:
sudo pacman -S apache
Check if Apache is running:
sudo systemctl status apache
If it’s not running, start and enable it:
sudo systemctl start apache sudo systemctl enable apache
For database support, install MariaDB (or MySQL) and related utilities:
sudo pacman -S mariadb
Start and enable MariaDB/MySQL:
sudo systemctl start mariadb sudo systemctl enable mariadb
Now, initialize and secure the database:
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql sudo systemctl start mariadb sudo mysql_secure_installation
Step 3. Configuring Apache for CodeIgniter.
Create a new virtual host configuration file for your CodeIgniter project. Replace
your_domain with your actual project directory path and domain name:
sudo nano /etc/httpd/conf/extra/httpd-your_project_directory.conf
Add the following configuration:
<VirtualHost *:80> ServerAdmin webmaster@your_domain DocumentRoot "/path/to/your_project_directory/public" ServerName your_domain <Directory "/path/to/your_project_directory/public"> AllowOverride All Require all granted </Directory> </VirtualHost>
Edit your system’s hosts file to map your domain to the localhost:
sudo nano /etc/hosts
Add the following line:
Enable the new virtual host and restart Apache:
sudo a2ensite httpd-your_project_directory.conf sudo systemctl restart apache
To ensure your configuration is correct, run:
sudo apachectl configtest
Step 4. Downloading and Installing CodeIgniter.
With your environment set up, let’s download and install CodeIgniter. Navigate to your project directory and use Composer to create a new CodeIgniter project:
composer create-project codeigniter4/appstarter .
CodeIgniter is now installed, but you might want to customize it further. Explore the
public directories to make changes according to your project requirements.
Access your CodeIgniter application via your web browser by entering your domain (e.g.,
http://your_domain). You should see the CodeIgniter welcome page, confirming a successful installation.
Step 5. Database Configuration.
Let’s configure the database for your CodeIgniter application. Open the
.env file in your CodeIgniter project root directory:
Update the database settings with your MariaDB/MySQL credentials:
database.default.hostname = localhost database.default.database = your_database_name database.default.username = your_database_username database.default.password = your_database_password
Step 6. Testing Your CodeIgniter Application.
Now that everything is set up, let’s test your CodeIgniter application to ensure it’s working as expected. Create a new controller and view to test your application:
php spark make:controller TestController php spark make:view test
TestController.php file to add a sample function and view.
Step 7. Accessing the application via the web browser.
Access your new controller via your web browser:
You should see the CodeIgniter welcome page:
Congratulations! You have successfully installed CodeIgniter. Thanks for using this tutorial to install the latest version of CodeIgniter on the Manjaro system. For additional help or useful information, we recommend you check the official CodeIgniter website.