How to install CodeIgniter on VPS?

Member

by ethelyn , in category: Installation & Upgrades , 8 months ago

How to install CodeIgniter on VPS?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by georgiana.senger , 8 months ago

@ethelyn 

To install CodeIgniter on a VPS (Virtual Private Server), you can follow these steps:


Step 1: Connect to your VPS via SSH. You will need the IP address, username, and password provided by your server provider.


Step 2: Update the server software by running the following command:

1
sudo apt update


Step 3: Install Apache web server by running the command:

1
sudo apt install apache2


Step 4: Install PHP and required extensions by running the command:

1
sudo apt install php libapache2-mod-php php-mysql php-common php-cli php-json php-mbstring php-zip php-gd php-curl


Step 5: Install MySQL database server by running the command:

1
sudo apt install mysql-server


During the installation, you will be prompted to set a password for the MySQL root user.


Step 6: Create a new MySQL database and user for your CodeIgniter application. You can do this by logging into MySQL as the root user by running the command:

1
mysql -u root -p


Then, execute the following SQL commands:

1
2
3
4
5
CREATE DATABASE your_database_name;
CREATE USER 'your_username'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_username'@'localhost';
FLUSH PRIVILEGES;
EXIT;


Replace "your_database_name", "your_username", and "your_password" with your desired values.


Step 7: Download the CodeIgniter package from the official website, or you can use the following command to download directly on your server:

1
wget https://codeigniter.com/download/latest


Step 8: Extract the downloaded package by running the command:

1
unzip codeigniter-x.x.x.zip


Replace "x.x.x" with the version number of the CodeIgniter package.


Step 9: Move the extracted CodeIgniter files to the Apache web root directory by running the command:

1
sudo mv codeigniter-x.x.x /var/www/html/


Note: This assumes that your Apache web root directory is "/var/www/html/". If it's different, adjust the command accordingly.


Step 10: Configure Apache to use CodeIgniter. Open the Apache default configuration file by running the command:

1
sudo nano /etc/apache2/sites-available/000-default.conf


Add the following lines before the "" tag:

1
2
3
<Directory /var/www/html/codeigniter-x.x.x>
    AllowOverride All
</Directory>


Replace "x.x.x" with the version number of the CodeIgniter package.


Save the file and exit the editor.


Step 11: Restart Apache for the changes to take effect by running the command:

1
sudo service apache2 restart


Step 12: Finally, you can access your CodeIgniter application by entering your VPS IP address in a web browser. For example, http://your_vps_ip/codeigniter-x.x.x/ Replace "your_vps_ip" with the IP address of your VPS, and "x.x.x" with the version number of the CodeIgniter package.


That's it! You have successfully installed CodeIgniter on your VPS. You can now start developing your web application with CodeIgniter.