Close Menu
Technoracle
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    TechnoracleTechnoracle
    • Home
    • AWS
      • EC2
      • Lightsail
      • RDS
      • S3
    • Ubuntu
      • Ubuntu 20.04
      • Ubuntu 22.04
    • AI Tools
    • Web Hosting
    • WordPress
    • Tech News
    Technoracle
    Home - Ubuntu - How to Install CodeIgniter on Ubuntu 20.04
    Ubuntu

    How to Install CodeIgniter on Ubuntu 20.04

    Sulagna MukherjeeBy Sulagna MukherjeeApril 2, 2023Updated:June 8, 2023No Comments4 Mins Read
    install CodeIgniter on Ubuntu 20.04

    Codeigniter is a robust PHP framework for creating full-featured apps quickly. This is a mostly used PHP Framework that is Open Source and developers create it for developers. The most recent version available for application development is Codeigniter 4.

    This guide will walk you through the process where you will learn how to install CodeIgniter on Ubuntu 20.04.

    Page Contents

    Toggle
    • Prerequisites
    • Step 1 – Installing Composer
    • Step 2 – Create CodeIgniter Application
    • Step 3 – Configure Database
    • Step 4 – Configure Codeigniter Application
    • Step 5 – Configure Apache for Codeigniter
    • Step 6 – Test Application
    • Conclusion

    Prerequisites

    On your PC, you’ll need a web server, a MySQL database server, and PHP to run the Codeigniter 4 framework. Install the LAMP stack on your Ubuntu 20.04 machine using the instructions below.

    Step 1 – Installing Composer

    This article will show you how to use PHP composer to develop a Codeigniter 4 application. PHP Composer is accessible as a binary file that may be downloaded and used directly. To install composer on your Ubuntu machine, do the steps below.

    curl -sS https://getcomposer.org/installer | php
    mv composer.phar /usr/local/bin/composer
    chmod +x /usr/local/bin/composer

    Step 2 – Create CodeIgniter Application

    To construct new apps, Codeigniter includes an application beginning composer module. The skeleton application is included in the Codeigniter application starter repository, as is the composer dependent on the most recently published version of the framework.

    To install CodeIgniter on Ubuntu 20.04 on your machine, use the following command:

    composer create-project codeigniter4/appstarter CodeApp

    This will show an output like this:

    Creating a "codeigniter4/appstarter" project at "./CodeApp"
    Installing codeigniter4/appstarter (v4.0.3)
      - Installing codeigniter4/appstarter (v4.0.3): Downloading (100%)
    Created project in /home/rahul/CodeApp
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Package operations: 35 installs, 0 updates, 0 removals
      - Installing laminas/laminas-zendframework-bridge (1.0.4): Downloading (100%)
      - Installing laminas/laminas-escaper (2.6.1): Downloading (100%)
    
      [hiding long output]
    
    sebastian/global-state suggests installing ext-uopz (*)
    phpunit/php-code-coverage suggests installing ext-xdebug (^2.7.2)
    phpunit/phpunit suggests installing phpunit/php-invoker (^2.0.0)
    phpunit/phpunit suggests installing ext-soap (*)
    phpunit/phpunit suggests installing ext-xdebug (*)
    Writing lock file
    Generating autoload files
    3 packages you are using are looking for funding.
    Use the `composer fund` command to find out more!
    Generating autoload files
    Generated autoload files

    Now Codeigniter apps are stored in the CodeApp directory.

    Step 3 – Configure Database

    Now, in MySQL, build a database for your Codeigniter application. My computer is running MySQL 5.7. Connected to MySQL as root, then used the following queries to create a database and a user.

     mysql -u root -p

    Run the following queries to establish a database and a user for your application.

    CREATE DATABASE codeigniter4;
    CREATE USER 'dbuser'@'localhost' IDENTIFIED BY '_password_';
    GRANT ALL ON codeigniter4.* to 'dbuser'@'localhost';
    FLUSH PRIVILEGES;
    quit

    Then, in a text editor, edit the database configuration file and adjust the database settings you created before. To modify a file in the application directory, use the following command:

    nano app/Config/Database.php

    Make changes to the following values.

    public $default = [
    	'DSN'      => '',
    	'hostname' => 'localhost',
    	'username' => 'dbuser',
    	'password' => 'm2n1shlko',
    	'database' => 'codeigniter4',
    	'DBDriver' => 'MySQLi',
    	'DBPrefix' => '',
    	'pConnect' => false,
    	'DBDebug'  => (ENVIRONMENT !== 'production'),
    	'cacheOn'  => false,
    	'cacheDir' => '',
    	'charset'  => 'utf8',
    	'DBCollat' => 'utf8_general_ci',
    	'swapPre'  => '',
    	'encrypt'  => false,
    	'compress' => false,
    	'strictOn' => false,
    	'failover' => [],
    	'port'     => 3306,
    ];

    Step 4 – Configure Codeigniter Application

    You must now specify your application’s base URL. I’m going to use the www.tecadmin.local domain as an example for this application in this tutorial. You may also use localhost or another domain name that you choose.

    To modify the App.php file inside a text editor, use the following command:

    vi app/Config/App.php

    Update the baseURL in App.php to that same domain name of your application:

    public $baseURL = 'http://www.technoracle.local/';

    Now you might also need to modify your application’s timezone by using the appTimezone variable.

    public $appTimezone = 'UTC';

    Save file and close.

    Step 5 – Configure Apache for Codeigniter

    On my Ubuntu machine, I’m using the Apache web server for this lesson. So, for our Codeigniter application, create an entirely new Virtual Host configuration file.

    Let’s make a new file and modify it:

    vi /etc/apache2/sites-available/codeigniter4.conf

    Add the following text with the appropriate server name and alias:

    <VirtualHost *:80>
        ServerName tecadmin.local
        ServerAlias www.tecadmin.local
        DocumentRoot /var/www/CodeApp/public
        <Directory /var/www/CodeApp>
              Allowoverride All
        </Directory>
    </VirtualHost>

    Your Apache Virtual Host file system should be saved.

    Then, run a2enmod to activate the newly built Codeigniter Virtual Host. Reboot the Apache service as well to implement the modifications.

    sudo a2ensite codeigniter4
    sudo systemctl restart apache2

    Step 6 – Test Application

    On your Ubuntu machine, the CodeIgnator 4 program is ready to use. You may use the specified domain name to access the program via a web browser.

    http://www.technoracle.local/

    By default, you will see the screen below.

    install CodeIgniter on Ubuntu 20.04

    Conclusion

    You learned how to install CodeIgniter on Ubuntu 20.04 and construct a Codeigniter application and deploy it using the Apache web server in this article. Let’s get started with Codeigniter.

    codeigniter install
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit
    Previous ArticleInstall Sublime Text on Ubuntu 22.04 Latest Version Quickly
    Next Article How to Enable PHP Zip Extension in cPanel (3 Easy Steps)
    Sulagna Mukherjee

    Sulagna is a tech enthusiastic girl, she is exploring the different fields of technology and sharing her learning through her writings with everyone . You can follow her at YouTube(Noobie Techs)

    Related Posts

    linux commands every user should know in 2025
    Ubuntu 24.04

    25 Must-Know Linux Commands Every User Should Master in 2025

    Read More
    TeamViewer and Ubuntu logos on gradient background – banner for how to install TeamViewer on Ubuntu 24.04 tutorial
    Ubuntu 24.04

    How to Install TeamViewer on Ubuntu 24.04 [Fast & Easy Steps]

    Read More
    Troubleshooting ‘Permission Denied (publickey)’ SSH error on a Linux server using secure terminal access
    Ubuntu

    Fix ‘Permission Denied (publickey)’ SSH Error on Linux [Step-by-Step Guide]

    Read More
    Add A Comment
    Leave A Reply Cancel Reply

    linux commands every user should know in 2025

    25 Must-Know Linux Commands Every User Should Master in 2025

    April 10, 2025
    TeamViewer and Ubuntu logos on gradient background – banner for how to install TeamViewer on Ubuntu 24.04 tutorial

    How to Install TeamViewer on Ubuntu 24.04 [Fast & Easy Steps]

    April 10, 2025
    Troubleshooting ‘Permission Denied (publickey)’ SSH error on a Linux server using secure terminal access

    Fix ‘Permission Denied (publickey)’ SSH Error on Linux [Step-by-Step Guide]

    April 8, 2025
    Blog banner showing Ubuntu logo, coding laptop, and icons for VS Code, Docker, and Git with the title 'Perfect Dev Setup in Ubuntu 24.04 – Step-by-step guide for developers' on a dark tech-themed background.

    How to Set Up the Perfect Development Environment on Ubuntu 24.04

    April 8, 2025

    Subscribe to Blog

    Enter your email address to subscribe to
    this blog and receive notifications of new posts by email.

    Facebook X (Twitter) Instagram Pinterest
    • Sitemap
    • Privacy Policy
    • Disclaimer
    • Term of Services
    © 2025 Technoracle

    Type above and press Enter to search. Press Esc to cancel.

    Click to Copy