Nowadays many developers prefer the web to make their applications. Some choose Python and Django, others Ruby on Rails, but others prefer CodeIgniter and PHP. Today, I’ll show you how to install CodeIgniter on Ubuntu 18.04.
CodeIgniter is a PHP framework for web development with a focus on process simplicity. It is based on object-oriented programming but does not force you to use it, which makes it a quite versatile framework. On the other hand, CodeIgniter stands out for using many conventions so you won’t have to configure practically anything. All this without sparing efforts to be a very safe framework.
So let’s install CodeIgniter on Ubuntu 18.04.
1. Install Apache web server
Open a terminal and run:
:~$ sudo apt install apache2
Next, make Apache starts at the system boot. Then, start the service.
:~$ sudo systemctl enable apache2 :~$ sudo systemctl start apache2
If you want to check that everything is OK, open your web browser and go to
http://IP_SERVER and you should see this.
Nice. Apache web server is ready.
2. Install PHP
CodeIgniter is a PHP framework, so obviously you have to install PHP.
:~$ sudo apt install php7.2 php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-xml libapache2-mod-php7.2 php7.2-mysql php7.2-zip
In order to check if PHP is working correctly, create a file called
:~$ sudo nano /var/www/html/test.php
And add the following:
<?php phpinfo(); ?>
Finally, open it from your web browser. .
PHP is correctly installed.
3. Install MariaDB
So, the next step to install CodeIgniter on Ubuntu 18.04 is to install MariaDB. MariaDB is a database manager derived from MySQL.
:~$ sudo apt install mariadb-server
It is time to set a root password for MariaDB. You can do it using the
:~$ sudo mysql_secure_installation
Not only will you be able to define the password, but you will also be asked other questions about setting up MariaDB. I answered: Y, N, Y, Y.
Next, enable and start the MariaDB service.
:~$ sudo systemctl enable mariadb :~$ sudo systemctl start mariadb
4. Install CodeIgniter
It’s time to install CodeIgniter. Do it.
:~$ cd /var/www/html :~$ sudo wget https://github.com/bcit-ci/CodeIgniter/archive/3.1.9.zip
Next, decompress it.
:~$ sudo unzip 3.1.9.zip
Rename the folder:
:~$ sudo mv CodeIgniter-3.1.9/ codeigniter
Finally, change the permissions.
:~$ sudo chown -R www-data:www-data /var/www/html/codeigniter :~$ sudo chmod 755 -R /var/www/html/codeigniter
To configure CodeIgniter with your MariaDB database you must modify the
application/config/config.php file and add your credentials.
:~$ sudo nano application/config/database.php
Finally, open your web browser and go to http://IP_SERVER/codeigniter
And that’s it.
CodeIgniter is a great framework for web development with PHP. It is versatile, powerful and its installation is within everyone’s reach.
Please share this post with your friends.