In the realm of PHP frameworks, CodeIgniter stands out as a robust tool designed for developers who value simplicity and elegance without compromising on functionality. When used with Linux Mint 21, a user-friendly yet powerful interface, it offers an optimal environment for web development. This article will guide you through the process of installing CodeIgniter on Linux Mint 21.

Preparing for Installation

Before you begin, ensure you meet the following prerequisites:

  1. You are operating on a server running Linux Mint 21.
  2. It’s recommended to start with a fresh OS install to avoid potential issues.
  3. You should have a basic understanding of command line operations. If you’re new to this, consider familiarizing yourself with essential commands.
  4. An active internet connection is needed.
  5. You need administrative rights for installing and configuring software on your system.

Getting Started

The installation process is relatively simple, and it’s assumed that you are running in the root account. If not, you may need to add ‘sudo’ to the commands to obtain root privileges.

sudo apt update
sudo apt upgrade

Installing the LAMP Stack

CodeIgniter requires a web server, database server, and PHP to function properly. Install the LAMP (Linux, Apache, MySQL, PHP) stack using the following commands:

sudo apt update
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql

Setting Up Composer

Next, install Composer, a PHP dependency manager required for installing CodeIgniter:

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

Installing CodeIgniter

Navigate to the directory where you wish to install CodeIgniter and use Composer to create a new project:

composer create-project codeigniter4/appstarter codeigniter-project

This command creates a new CodeIgniter project in the codeigniter-project directory.

Configuring CodeIgniter

After creating your project, you’ll need to configure CodeIgniter for your specific environment. Copy the env file to .env and customize it accordingly. Specifically, set the CI_ENVIRONMENT variable to development to enable development settings:

cd codeigniter-project
cp env.env
nano.env

Setting Up the Database

Create a new database and user for your CodeIgniter application. Then, configure the app/Config/Database.php file with the correct database credentials. If your application requires initial database migrations, execute them using CodeIgniter’s CLI command:

php spark migrate

Running CodeIgniter

For development purposes, use CodeIgniter’s built-in server by executing the following command in your project root:

php spark serve

Access the application via http://localhost:8080 in your web browser. You should now see the default CodeIgniter welcome page.

While installing CodeIgniter can be a straightforward process, managing a VPS might not be everyone’s cup of tea. If you’re seeking a professional service to handle your VPS needs, consider Shape.host. Offering Linux SSD VPS, Shape.host provides efficient, scalable, and secure cloud hosting solutions. With their expertise, you can focus on what you do best – developing great web applications.