How to install Joomla with LEMP stack on CentOS 7 VPS (Part 2) - CloudMinister

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

5. Install Nginx

Nginx, pronounced as “Engine X” and is a very fast and lightweight web server, that can be used to support static files, used as a reverse proxy and also for load balancing.

Firstlly, update all the software packages by typing the following command:

# yum -y update
After that install EPEL repository that is required for Nginx packages by using command:

    # yum -y install epel-release 

Now install  Nginx by typing the command:

    # yum -y install nginx

 After the installation is completed you must Enable and Start Nginx server by typing command:

    # systemctl start nginx

And enable it with the command:

    # systemctl enable nginx

Also check its status with

    # systemctl status nginx

6.Configure Firewall

After completed with installation part, configure the firewall settings with the following command:

Open HTTP port by typing command with:

    # firewall-cmd –permanent –zone=public –add-service=http

If firewalld package is not available then you can install it with command:

    # yum -y install firewalld

And start firewalld service with command:

    # systemctl start firewalld

Now reload firewall configuration file by typing:

    # firewall-cmd –reload

Now verify your installation of Nginx by visiting the following URL on any browser you like with http://ip_address

7. Configure Nginx File

An Nginx server configuration file plays an important role, So you should be more careful when setting up this file.

For configuring Nginx file go inside the following path with the following command:

# cd /etc/nginx/conf.d

# vi default.conf (Creating new file)

And write the following code in the above file i.e. default.conf.    

Also change your domain in place of   ip_address       

server {

        listen       80;

        server_name  3.95.30.147;

root /usr/share/nginx/html/joomla;

        index index.php index.html index.htm;

location / {

          try_files $uri $uri/ =404;

       }

error_page 404 /404.html;

            location = /40x.html {

        root /usr/share/nginx/html/joomla;

     }

        error_page 500 502 503 504 /50x.html;

            location = /50x.html {

        root /usr/share/nginx/html/joomla;

}

        location ~* \.php$ {

        try_files $uri =404;

        fastcgi_pass unix: /var/run/php-fpm/php-fpm.sock;

        fastcgi_index index.php;

        include fastcgi_params;       

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

   

        }

}

And save it with :wq command, after that edit the configuration file of php-fpm with the following command:

    # vi /etc/php-fpm.d/www.conf

Open the file with above command and edit the following lines i.e.

user = nginx

group = nginx

Add new listen under listen  = 127.0.0.1:9000

listen = /var/run/php-fpm/php-fpm.sock

And also add 

listen.owner = nginx 

listen.group = nginx

Remove comment (;) from the above two lines and save it with :wq.

8. Install Joomla File

     You can easily download Joomla archive file from the link I provided in this blog.

First go inside /tmp directory by typing below command:

    # cd /usr/share/nginx/html

Make one directory i.e. joomla,

# mkdir joomla

Come inside the joomla directory:

    # cd joomla/

Download the latest Joomla setup by using wget command:

    # wget https://downloads.joomla.org/cms/joomla3/3-7-5/Joomla_3-7.5-Stable-Full_Package.zip  ?format=zip

And if wget command not work then you can download it with the following command:

    # yum -y install wget

Now unzip the downloaded file using below command:

    # unzip Joomla_3-7.5-Stable-Full_Package.zip

If unzip command is not work then install it first with the following command:

# yum -y install unzip

Also change the ownership of /var/www/html directory by using the following command:

    # chown -R nginx: /usr/share/nginx/html

# chmod -R 755 /usr/share/nginx/html

Note: Also change the ownership of group of /var/lib/php/session i.e. by default it is set as apache, so now change it’s ownership with:

ls -al /var/lib/php/session (It is used to check the ownership)

    chown root:nginx /var/lib/php/session (It is used to change the ownership)

9. Test Joomla

     Now for testing the server of Joomla you should restart the server for that follow the command:

    # nginx -t (If the command shows ‘successfully’ message then the changes in file are correct and else the changes are wrong in the nginx configuration file.)

    # systemctl restart php-fpm

# systemctl restart nginx

Then open any browser and type inside URL i.e http://ip_address/

After then configuration page i.e. http://ip_address/installation/ is open and then configure the following settings

CONCLUSION 

After the above installation, you will be able to manage your website by Joomla CMS in Centos VPS by using Nginx web server.

Note-: All commands are highlighted with the green color.
All links are highlighted with the blue color.
All files are highlighted with the yellow color.
All notes are highlighted with the red color.

Learn how to scale, manage, and optimize your applications with a SLB. Read our solution brief "Get More from Your Enterprise Network".

DOWNLOAD SOLUTION BRIEF

Get started with CloudMinister Today