29 C
Texas
angeloma
Senior Writer and partner

How to install CodeIgniter on Ubuntu 18.04?

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

The first step is to install a web server where you can run CodeIgniter. There are several, such as Nginx or Lighttpd, however, I will choose Apache web server.

- Advertisement -

Open a terminal and run:

:~$ sudo apt install apache2

1.- Installing Apache web server
1.- Installing Apache web server

Next, make Apache starts at the system boot. Then, start the service.

:~$ sudo systemctl enable apache2
:~$ sudo systemctl start apache2

2.- Working with apache service
2.- Working with apache service

If you want to check that everything is OK, open your web browser and go to http://IP_SERVER and you should see this.

3.- Apache default page
3.- Apache default page

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

4.- Install PHP
4.- Install PHP

In order to check if PHP is working correctly, create a file called test.php in /var/www/html.

:~$ sudo nano /var/www/html/test.php

And add the following:

<?php
phpinfo();
?>

5.- Testing the PHP installation
5.- Testing the PHP installation

Finally, open it from your web browser. .http://IP_SERVER/test.php

6.- PHP info
6.- PHP info

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

7.- Install MariaDB
7.- Install MariaDB

It is time to set a root password for MariaDB. You can do it using the mysql_secure_installation script.

:~$ 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.

8.- Using mysql_scure_installation script to configure MariaDB
8.- Using mysql_scure_installation script to configure MariaDB

Next, enable and start the MariaDB service.

:~$ sudo systemctl enable mariadb
:~$ sudo systemctl start mariadb

9.- Starting the MariaDB service
9.- Starting the MariaDB service

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

10.- Download and install CodeIgniter
10.- Download and install CodeIgniter

Next, decompress it.

:~$ sudo unzip 3.1.9.zip

11.- Decompressing the file
11.- Decompressing the file

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

12.- Setting the permissions
12.- Setting the permissions

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

13.- Set your database credentials
13.- Set your database credentials

Finally, open your web browser and go to http://IP_SERVER/codeigniter

14.- Codeigniter default page
14.- Codeigniter default page

And that’s it.

Conclusion

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.

 

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article