Considering you are well familiar with the pros of VPS hosting and How To Choose The Best Server for A Small Business In 2021, I’ve decided to pen down this tutorial which teaches you a simple 10-step technique of setting up VPS(Virtual Private Server) for your WordPress enriched site/blog. Here’s hoping by the end of this tutorial, all your doubts/misconceptions regarding the DIY approach of web hosting would cease to exist. However, before we begin the discussion, it is important that you understand that you must only seek the services of some reputable web hosting services, like Candidhost Web India, if you are to keep up with the myriad requirements of your business website.
And now, let’s discuss the steps that you are supposed to follow for setting your WordPress VPS:
Step 1- Get to know about the Pre-requisites
Since the traditional point-and-click approach doesn’t work well for performing advanced tasks during web hosting, it is recommended to opt for VPS hosting. Therefore, in order to set up VPS for your WordPress site/blog, it becomes mandatory for you to know command line inside out. Since this tutorial involves the use of Ubuntu-based server, you need to have a good understanding of Linux, SSH, FTP(File Transfer Protocol) and databases. Last, but definitely not the least, you are also supposed to have an active account with a reputed cloud hosting service provider like icedrive. In this tutorial, I’ve gone for DigitalOcean.
Step 2- Create a VPS server
Once you have created an account with DigitalOcean, simply login to the DigitalOcean dashboard and click on ‘Create Droplet’ link(here, Droplet refers to the virtual server). After this, you’ll be required to enter a Hostname for the virtual server. This can be the site’s domain name, a sub-domain name or simply a randomly chosen word like “my-server”. Also, you’ll be required to choose a region that is in close proximity to your target audience. You can get experts at Web Hosting Canada to help you out.
Step 3- Generate an SSH key
SSH key serves as a handy option for logging in to your VPS server without the need for entering a password every time. An SSH key comprises of two encrypted files viz: a public and a private one. If you have chosen to upload your private file to a specific location, then upon logging onto the server, you won’t be asked to enter your password because the same would be compared with the two encrypted files, allowing you to login automatically. Follow the below mentioned steps for generating a SSH Key:
- Go to the terminal and enter the below mentioned commands:
$ cd ~/.ssh
$ ssh-keygen -t rsa -C “your.email@your-domain.com”
- Once you’ve entered the two commands, you’ll be asked to enter the name of key along with a pass phrase. You can leave these two fields empty and simply click on “Enter” key. One important thing that you need to pay attention to is that leaving the key name as it is will result in overwriting the default key.
Step 4- Add SSH key to the created VPS(already explained in step 2 above)
Now that you have a SSH key, simply go back to the Drop creation screen(explained in step no.1)-> click on “Add SSH Key”-> Copy paste the public part(file with extension as .pub) of the SSH key into the displayed text-area. You can fetch the contents of this .pub file by running $ cat playground.pub in the terminal. With successful uploading of the SSH key, again click on “Create Droplet” button and wait until the VPS has been created.
Step 5- Create a user
Performing advanced server actions as a root user is perhaps not a good approach when it comes to assuring complete security of your WordPress website/blog. Thus, it is essential to create a normal user for logging into the Virtual Private Server(VPS). Moreover, you can assign this user to the admin group for being able to undertake actions that are authorized just to the administrators. So, simply run the below commands on your server for assigning a normal user to admin group.
$ groupadd admin
$ adduser webmaster –ingroup admin
Once you’re done with running the above two commands, you’ll be asked to enter a password in addition to some other details. The group ‘admin’ doesn’t exist by itself and hence you need to create it first. Just run the following commands for moving the SSH key from root to the newly created user:
$ mkdir /home/webmaster/.ssh
$ mv /root/.ssh/authorized_keys /home/webmaster/.ssh/
$ chown -R webmaster:admin /home/webmaster/.ssh/
The first command mentioned above creates a directory, the second one shifts the SSH authorized keys file from the root to the created user. Finally, the third command allows the administrator to access the SSH authorized keys file.
Step 6-Create a config file
Config file plays a vital role in the successful execution of various server processes. Here, as well, you can save an incredible amount of typing time and effort by creating a config file. For this, simply go to the .ssh folder and create a file that is named as config(with no extension) and add the below lines in it:
Host Playground
HostName 102.121.51.124
Port 20
User root
IdentityFile /Users/Tomaz/.ssh/playground
In the above, make sure to replace the HostName with the IP(the one provided during creation of VPS server) and IdentityFile with the private key generated in step no. 3. After including the above lines in the config file, save it and close the editor.
Step 7- Ensure the hacker-proof status of SSH login process
Hacking the SSH login credentials has been considered as one of the most common attacks faced by servers. Now, since we have a SSH key pair comprising of public and private encrypted files, we can easily do away with the need for entering any passwords or usernames.
You can opt for editing the configuration file that you created in step no.6. Here is the command used for the same:
$ sudo nano /etc/ssh/sshd_config
Upon running the above command, you’ll be asked to enter the password that was being set for the webmaster user(as explained in step no. 5). Some additional tweaks that must be made to the config file include:
PermitRootLogin no
PasswordAuthentication no
Once you have made the above changes, simply save the config file and close the editor. Finally, for making the changes effective, just restart the program by running the below command:
$ sudo service ssh restart
Step 8- Set up PHP- an open source language in which WordPress is written
Since you need to install VPS for your WordPress website, it is important to set up PHP on the server too. You can do this by simply running the following command:
$ sudo apt-get install -y php5-fpm php5-cli
Here, I would recommend you to avoid the Apache module because Apache will be using ample number of server resources, making the hosting in-effective.
Step 9- Set up the database
Well, you can choose to set up the database using any one of the following approaches:
- Using MySQL
- Using MariaDB
Here, I am using the latter one. You just need to run the following command for setting up the database for your WordPress website:
$ sudo apt-get install -y mariadb-server mariadb-client
Step 10- Set up the FTP(File Transfer Protocol)
There’s no doubt on the fact that WordPress runs best with FTP. Therefore, I recommend setting up FTP for your VPS(Virtual Private Server) as well. For this, you can start off by creating the FTP server using vsftpd- a renowned FTP server. To install it, just run the following command on your current server:
$ sudo apt-get install -y vsftpd
Conclusion
Here’s hoping by now you’d have understood the procedure of setting up VPS for your WordPress website/blog. If you feel that your current server isn’t working for your WordPress site/blog then you can freely choose to set up self-managed hosting in the form of a VPS(Virtual Private Server). This approach will render you complete flexibility of hosting your site in your own unique way.
Daniel @ Hosted Status Page says
Hi Edward,
Nice and simple guide for anyone starting out. Good job.