page-banner-shape-1
page-banner-shape-2

How to install Joomla with LEMP stack on CentOS 7 VPS (Part 1)

  • Tanuj Chugh
  • August 7, 2020

How to install Joomla with LEMP stack on CentOS 7 VPS (Part 1)

Joomla is a powerful open-source Content Management System (CMS) used by millions to build websites and applications. While often paired with Apache (the “LAMP” stack), running it on Nginx (the “LEMP” stack) can offer significant performance benefits.

In this first part of our tutorial, you will learn how to prepare your CentOS 7 server by installing and configuring the core components of the LEMP stack: Nginx, MySQL 8.0, and PHP 7.2.

Prerequisites

Before you begin, ensure you have:

  • A CentOS 7 VPS

  • SSH access as a user with sudo privileges

Let’s start by updating the system:

bash
sudo yum -y update

Step 1: Install MySQL 8.0

Joomla requires a database to store all its content. We’ll use MySQL 8.0.

1.1 Add the MySQL Repository:

bash
sudo yum localinstall -y https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

1.2 Install MySQL Server:

bash
sudo yum install -y mysql-community-server

1.3 Start and Enable MySQL:

bash
sudo systemctl start mysqld
sudo systemctl enable mysqld

1.4 Secure Your MySQL Installation:
During the initial installation, a temporary password is generated for the root user. Retrieve it with:

bash
sudo grep 'temporary password' /var/log/mysqld.log

Then, run the security script. It will prompt you to change the root password and improve security defaults.

bash
sudo mysql_secure_installation
  • Follow the prompts. It’s recommended to: (Y) Change the root password, (Y) Remove anonymous users, (Y) Disallow root login remotely, (Y) Remove test database, and (Y) Reload privilege tables.

Pro Tip: MySQL 8.0 has a strict password policy. Your new password must be strong (12+ characters, mix of upper/lower case, numbers, and symbols). Note it down in a secure place.


Step 2: Create a Database for Joomla

Log into MySQL and create a dedicated database and user for Joomla. This is a crucial security practice.

2.1 Log into MySQL:

bash
mysql -u root -p

Enter the root password you set in the previous step.

2.2 Create the Database and User:
Run these commands within the MySQL shell, replacing 'joomla_user_password' with a very strong password.

sql
CREATE DATABASE joomla_db;
CREATE USER 'joomla_user'@'localhost' IDENTIFIED BY 'joomla_user_password';
GRANT ALL PRIVILEGES ON joomla_db.* TO 'joomla_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Pro Tip: Avoid using the MySQL root user for Joomla. Creating a dedicated user with permissions only for its specific database (joomla_db.*) limits the damage if your Joomla site is ever compromised.


Step 3: Install & Configure PHP 7.2

CentOS 7 ships with an older version of PHP. We will use the Remi repository to install PHP 7.2, which is faster and fully supported by Joomla 4.

3.1 Add the Required Repositories:

bash
sudo yum install -y epel-release yum-utils
sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm

3.2 Enable the PHP 7.2 Repository:

bash
sudo yum-config-manager --enable remi-php72

3.3 Install PHP and Necessary Extensions:
Joomla requires several PHP modules. Install them all at once:

bash
sudo yum install -y php-fpm php-mysqlnd php-zip php-json php-mbstring php-curl php-gd php-xml php-pecl-imagick php-intl

3.4 Configure PHP for Joomla:
Edit the main PHP configuration file to adjust settings for better performance and compatibility.

bash
sudo vi /etc/php.ini

Find and modify the following lines (or add them if they don’t exist):

text
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

Save and close the file.

3.5 Start and Enable PHP-FPM:

bash
sudo systemctl start php-fpm
sudo systemctl enable php-fpm

Pro Tip: The default php.ini is not optimized for CMSs like Joomla. Adjusting memory_limit, upload_max_filesize, and max_execution_time prevents common errors during installation and when uploading media or extensions.


Step 4: Install Nginx

4.1 Install Nginx:
Nginx is available in the EPEL repository, which we already added.

bash
sudo yum install -y nginx

4.2 Start and Enable Nginx:

bash
sudo systemctl start nginx
sudo systemctl enable nginx

Step 5: Configure the Firewall

Allow HTTP and HTTPS traffic through the system firewall so users can access your site.

bash
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reload

What’s Next? (Teaser for Part 2)

You have now successfully installed the LEMP stack! Your server is ready for Joomla.

In Part 2 of this tutorial, we will cover:

  1. Configuring Nginx to process PHP files and serve your Joomla site.

  2. Downloading and installing the latest Joomla files.

  3. Setting correct file permissions for security.

  4. Running the Joomla web installer to connect the database and set up your site.

Stay tuned!


Tired of Complex Server Setup?

Configuring a high-performance LEMP stack from scratch is complex and time-consuming. Let us handle the server management so you can focus on building your website.

Our Optimized Joomla Hosting includes:

  • LEMP Stack Pre-Installed & Fine-Tuned

  • Free SSL Certificates

  • Daily Backups & Proactive Security

  • 24/7 Expert Support

 

To be Continued…….

Tanuj Chugh

He is the CEO and Founder with over a decade of experience in cloud infrastructure, DevOps, and server optimization. With a strong vision and hands-on leadership approach, he has built scalable, secure, and high-performance cloud solutions trusted by businesses across industries.

https://cloudminister.com/
Call Now Button