How to Install WordPress on a VPS



What is WordPress?

WordPress is one of the most popular content management software that we use today to build and maintain our websites of high quality. What makes WordPress stand out in the lot and favorite among non-coders is its “Themes” feature. We do not need to write HTML scripts in order to develop our website through WordPress.


What is VPS?

VPS stands for Virtual Private Server. Also called VDS or Virtual Dedicated Server, VPS, works as a virtual machine that serves a particular organization who owns a share of it. VPS runs its own Operating System.


Installation of WordPress on VPS

We can install WordPress on a VPS running Linux Operating System in the following manner:-


  • Connecting to the VPS via SSH(Secure Shell):-

SSH is a software package that enables secure system administration and file transfers over insecure networks. To access our VPS we need to install a Secure Shell client such as Putty on our computer. After installing the software we need to open the application. Then we have to specify the destination with which we wish to connect.

Now we have to type the IP address of our VPS within the box under Host Name written, we need to give 22 as Port, then we have to choose SSH from the Connection Type field and finally, we will click open.

 A command window will appear on our screen. There we need to write Root beside “Login As” and we have to enter the password when asked to. This is done so that we can run all the commands required. We must be careful to type the password correctly as then only we will be able to see the name of our VPS and do the rest of our jobs.


  • Installing the software we need to run WordPress:-

We need three things to run WordPress on our system and they are:- 1)HTTP server, 2)a database, 3) PHP. Here we will use the Apache server, MariaDB database, and PHP 7.4. To do this we can use the command below:-

sudo yum install httpd mariadb mariadb-server php php-common php-mysql php-gd php-xml php-mbstring php-mcrypt php-xmlrpc unzip wget –y

This prompts our server to download all the required files. The process will be slow or fast depending on the speed of our server.    Once the software is ready, we need to initialize it and instruct our server to boot it up each time. The commands we need to use are:

sudo systemctl start httpd

 

sudo systemctl start mariadb

 

sudo systemctl enable httpd

 

sudo systemctl enable mariadb



  • Configuring MariaDB database:-

 

We need to “secure” our MariaDB database installation so that others can’t access it remotely. To do so we need to enter the following command:

sudo mysql_secure_installation

Then we need to give the root password, which must be blank, so we have to just hit the enter key. Then we see a new password for our root. We have to press for the rest of our settings, especially for number three, which doesn't allow logins remotely.

mysql -u root –p

By entering the above command we will be able to login to our MariaDB account, then we have to put the last set password. Finally, we have to give the following four commands:-

CREATE DATABASE WordPress;

 

GRANT ALL PRIVILEGES on wordpress.* to 'user'@'localhost' identified by 'password';

 

FLUSH PRIVILEGES;

 

exit

We must replace the “user” and “password” placeholders with the original pair to use with our database. Now our newly created database is ready to use.

  • Installing and Running WordPress:-

The final step is to download our software and install and configure it. For this, we have to set up the infrastructure by writing a series of commands to download the latest version of the WordPress platform, extract the files, and move those files to the “root” directory. The commands written below are individual commands, so we must run them separately.

wget http://wordpress.org/latest.tar.gz

 

tar -xzvf latest.tar.gz

 

sudo cp -avr wordpress/* /var/www/html/


Now we need to create an “Uploads” folder for our installation and assign the correct permissions to our files and folders. For this purpose we have to use the two commands below:

sudo mkdir /var/www/html/wp-content/uploads

 

sudo chown -R apache:apache /var/www/html/

 

sudo chmod -R 755 /var/www/html/


Finally, we will rename our WordPress wp-config-sample.php file in the following manner:-


cd /var/www/html/

 

sudo mv wp-config-sample.php wp-config.php

 

sudo nano wp-config.php


Then we will configure it so that it can be connected to our database. A nano editor will open in the command line. We need to navigate the file using arrow keys on our keyboard. Then we will replace the following fields with the same information we entered during configuring our MariaDB database.


define('DB_NAME', 'wordpress');

 

define('DB_USER', 'user');

 

define('DB_PASSWORD', 'password');


Next, we need to press CTRL+O from our keyboard to save the changes that we made to the file. Very quickly we will press CTRL+X to close the nano editor. Then we will run the following commands:-

sudo firewall-cmd --permanent --zone=public --add-service=http

 

sudo firewall-cmd --permanent --zone=public --add-service=https

 

sudo firewall-cmd –reload


That is how we will get to access the WordPress by visiting our VPS through this site http://yourvpsipgoeshere


In this manner, we will be able to install WordPress at our VPS.


Comments