How to Install Joomla 3 on CentOS 7

How to install Joomla 3 on CentOS 7

Introduction

In this post we will show you how to install Joomla 3 on CentOS 7, with MariaDB 10.2, PHP-FPM 7.1 and Nginx. Joomla is an award-winning content management system (CMS) for publishing web content and online apps. Joomla is one of the most popular CMSs and it is used all over the world to power millions of websites and applications of all shapes and sizes. Joomla is a free and open-source, php-based CMS system with wide range of features for publishing content. This guide should work on other RedHat-based systems as well but was tested and written for an CentOS 7 VPS. The process of installing Joomla 3 on CentOS 7 is fairly easy and it shouldn’t take more then 10 minutes.

Prerequisites

  • Virtual server running CentOS 7 as an operating system
  • sudo priviledges user (non-root)
  • Around 10 minutes of your time

1. Update the system and install requeired packages

sudo yum update

sudo yum install yum-utils unzip wget

2. Install MariaDB 10.2

If you already have MySQL or MariaDB installed you can skip this step and move to the next section.

To add the MariaDB repository and install the latest MariaDB server, create an new file under /etc/yum.repos.d/:

sudo nano /etc/yum.repos.d/MariaDB.repo

and add the folowing lines:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Once the repo file is created you can install MariaDB with the following command:

sudo yum install MariaDB-server MariaDB-client

During the installation YUM will prompt you to install the MariaDB GPG Signing key.

3. Secure MariaDB

When the installation is complete, run the following command to secure your installation:

mysql_secure_installation

4. Create new database

Create a new database and user for the Joomla installation using the following commands:

mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE joomla;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON joomla.* TO 'joomla'@'localhost' IDENTIFIED BY 'strongpassword';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

5. Install and configure Nginx

If you don’t have Nginx installed on your server, you can install the latest stable version from the official Nginx repositories:

First, create an new file under /etc/yum.repos.d/:

sudo nano/etc/yum.repos.d/nginx.repo

and add the following configuration:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

Once you enable the Nginx repository you can proceed and install Nginx using the following command:

sudo yum install nginx

Next, create a new Nginx server block:

sudo nano /etc/nginx/conf.d/my.joomla.site
server {
    listen 80;
    server_name my.joomla.site;
    root /var/www/my.joomla.site;

    index index.html index.htm index.php;

    charset utf-8;

    access_log /var/log/nginx/my.joomla.site.access.log;
    error_log /var/log/nginx/my.joomla.site.error.log info;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
        return 403;
        error_page 403 /403_error.html;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

Test the Nginx configuration and restart nginx:

sudo nginx -t
sudo systemctl restart nginx.service

6. Install PHP 7.1

PHP version 7.1 is not available in the default CentOS 7 repositories so we will use the Remi repository.

To install and enable both EPEL and Remi repositories run the following command:

sudo yum install epel-release
sudo rpm -Uhv https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --enable remi-php71

You can now proceed and install PHP 7.1 and all necessary PHP modules using the following commands:

sudo yum  install php-fpm php-cli php-gd php-opcache php-mysqlnd php-json php-mcrypt php-xml php-curl

During the installation YUM will prompt you to install the Remi GPG Signing key.

Once the installation you’ll need to open the PHP FPM poll configuration file and change the user from apache to nginx:

sudo nano /etc/php-fpm.d/www.conf
user = nginx
group = nginx

and fix the session and cache directories permissions:

chown -R root:nginx /var/lib/php/*

Finally, restart the PHP FPM service with:

sudo systemctl restart php-fpm.service

7. Install Joomla 3 on CentOS 7

Installing Joomla is pretty easy and straightforward, first download the Joomla zip archive from the Joomla download page:

wget https://downloads.joomla.org/us/cms/joomla3/3-8-5/Joomla_3-8-5-Stable-Full_Package.zip

Once the download is completed, unzip the archive and move the extracted files to the /var/www/my.joomla.site directory, which will be the root directory of your new Joomla site:

sudo mkdir -p /var/www/my.joomla.site
sudo unzip Joomla_3-8-5-Stable-Full_Package.zip -d /var/www/my.joomla.site

Finally change the ownership of the /var/www/my.joomla.site directory to the nginx user:

sudo chown -R nginx: /var/www/my.joomla.site

8. Complete the installation via web browser installer

Open http://my.joomla.site/ in your favorite web browser and follow the on-screen instructions to complete the Joomla installation.

That’s it. You have successfully installed Joomla on CentOS 7. For more information about how to manage your Joomla installation, please refer to the official Joomla documentation.


How to install Joomla 3 on CentOS 7Of course you don’t have to install Joomla on CentOS 7, if you use one of our managed VPS hosting services, in which case you can simply ask our expert Linux admins to install Joomla 3 CMS  on your CentOS 7  server for you. They are available 24×7 and will take care of the Joomla 3 installation  immediately.

PS. If you liked this post on how to install Joomla  3 on CentOS 7, please share it with your friends on the social networks using the buttons on the left or if you have any question, simply leave a reply below and our system administrators will reply it, as quickly as possible. Thanks.

Leave a Comment