WordPress is the most popular CMS in the world which is free, open source and used by millions of people for blogs, eCommerce stores, business websites and much more.

Installing WordPress on VPS can have many benefits. With a VPS , you can configure and customize it in any manner suitable to your business. In this tutorial, you will learn how to install WordPress on VPS (Virtual Private Server). Here, we use Ubuntu 18.10.

First of all, make sure you have your stack ready (either LAMP or LEMP). Next, connect to or SSH into your VPS with a sudo user. To get the latest version of WordPress from repository, run the following command:

> wget https://wordpress.org/latest.tar.gz

Now, we need to extract this file. Here, we use tar command.

> tar -xvf latest.tar.gz

This will create a folder “wordpress” where all its core files exist. Now, we will create “upgrade” directory inside of this folder which is recommended by WordPress.

> mkdir wordpress/wp-content/upgrade

Next, we will configure database and salts using “wp-config.php” file. The folder contains “wp-config-sample.php” file which we will duplicate with a new name.

> cp wordpress/wp-config-sample.php wordpress/wp-config.php

Next, we need to copy WordPress folder’s content to “public_html” (or “www”) folder where your website is served from.

> sudo cp -a wordpress/. /var/www/

Now, we will change the ownership of this folder to “www-data” using the command:

> sudo chown www-data:www-data -R /var/www

Also, to check the ownership of folder, you can use the following command:

ls -l /var/www/

WordPress Configuration

Now, create a database for WordPress. If you don’t know how to create a database and assign user, then you can read this guide: How to Install MariaDB on Ubuntu & Create Database Once, you have your database name, user and password, you need to enter them in WordPress “wp-config.php” file. Also, you will need to enter salt keys which you can generate using this link: https://api.wordpress.org/secret-key/1.1/salt/

Here, we use nano editor to edit the file.

> sudo nano /var/www/wp-config.php

Enter your database name, database user and password. And, enter your salt keys. Also, here you can change database prefix for table for security. Once, your are done editing, you need to save the file with Ctrl + X and Y (if using nano editor).

Now, go to your domain or IP address which is mapped to /var/www/ folder. If the database credentials and salt keys you entered in “wp-config.php” file is correct, then here you will need to enter your site details such as “Site Title” etc. and Super Admin’s credentials such as “Username”, “Password”, “Email” etc. Fill these details to complete the installation of WordPress.

Cleaning Up Files

If you are sure everything went smoothly, you can safely remove these files/folder:

> sudo rm -R wordpress
> sudo rm latest.tar.gz

Leave a comment

Your email address will not be published. Required fields are marked *