How to Install CodeIgniter 4 on Ubuntu 18.04

How to Install CodeIgniter 4 on Ubuntu 18.04

CodeIgniter is one of the most popular PHP frameworks that was first released in 2006. The first developer of CodeIgniter was EllisLab which was then continued by the British Columbia Institute of Technology.

CodeIgniter 4 was just released on February 24, 2020. The date was chosen as a tribute to Jim Parry who was the project lead of CodeIgniter who died on January 15, 2020.

Hosts Configuration

Configure the /etc/hosts file to define hosts. With this file we can simulate a local domain on a computer without having to use an internet domain or install a DNS server.

Add myci.local host

Install Apache

Install Apache web server

Apache service status must be active (running)

apache2 service status
apache2 service status

Install PHP

Install PHP with the extensions

Test the results of installing PHP by creating a PHP Info file

Call the phpinfo () function

Browse http://myci.local/info.php

PHP Info
PHP Info

Install MariaDB

Install MariaDB database

The mariadb service must be active (running)

mariadb service status

Secure the MariaDB installation

Answer the questions given

Login MariaDB and create a database and user for myci

Install CodeIgniter

CodeIgniter can be installed in 3 ways, manual installation, composer installation, and git installation. The method used in this tutorial is manual installation.

Download CodeIgniter 4 latest release

Extract CodeIgniter

Move the extracted folder and rename to myci.local

Change the owner and folder permissions

Configure the Apache virtual host for myci.local

Enter the virtual host configuration

Activate virtual host and restart apache2 service

Browse http://myci.local

Welcome to CodeIgniter 4
Welcome to CodeIgniter 4

Database Connection Configuration

Open the database connection configuration file using a text editor. The configuration file is /var/www/myci.local/app/Config/Database.php.

Fill in a database connection

Command Line Tool

CodeIgniter 4 has a command line tool called spark, run it in the project’s root folder.

CodeIgniter spark command line tool
CodeIgniter spark command line tool

Showing help from the command

spark help
spark help

5 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *