How to setup a VPS (Ubuntu) for WordPress hosting – A to Z tutorial

VPS is being more popular day by day. Personally I prefer to use DigitalOcean, they are cheap and their support is awesome. They also have tons of tutorial guides, chat community. Also they answer your questions very quickly in their support forum.

Let’s dive into the main point. When you will have a VPS droplet, you will get an IP, login username, password that you can use to login in your VPS via command line. There are several tools like Putty in windows, but I love to work in command line in Linux or Mac OS.

Let’s assume the IP is where username is root and password is myvps. So, now connect to the VPS using terminal:
ssh root@
If you connect for the first time, the following message could be appeared:
[box type=”shadow”]The authenticity of host ‘ (’ can’t be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)?[/box]
Just type yes and press enter. It will ask for password, give the password myvps and press enter, you’re in!

You may also read:  WordPress: How to load all styles and scripts in footer

Note that, if you have connected to same VPS using other IP before, then you may see a error message like the following:
[box type=”shadow”]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:1
RSA host key for has changed and you have requested strict checking.
Host key verification failed.[/box]
Then you need to run these commands in terminal, before connecting to VPS:
$ ssh-keygen -R

You may also read:  How to make your wordpress secure, wp config tips and many more

Now we will add new user for your server, as we won’t use root user. “root” users is only for administrative purpose. Let’s create a new user:
sudo adduser sandbox
Now a user having username as ‘sandbox’ will be created, but you are not done yet. You will be asked for password immediately. Give password and press enter. Now the system will ask for additional details like name, email etc. You don’t need to provide those information if you don’t want to, just keep pressing enter until you see the following message:
[box type=”shadow”]
Is the information correct? [Y/n]
Press Y and then press enter. New user ‘sandbox’ with password (in my case it’s sandbox too) is created!

You may also read:  How to enable php mail() in your ubuntu

Now we need to give root privileges to sandbox user:
sudo /usr/sbin/visudo
A text file will be opened in the terminal, add the following lines:
sandbox ALL=(ALL:ALL) ALL
Press ‘cntrl x’ to exit the file and then ‘Y’ to save the file.

[box type=”shadow”]
If you want to delete any user from your system, use the following command:
sudo userdel sandbox
And then you need to delete the user’s home directory:
sudo rm -rf /home/sandbox
To change user:
su sandbox

You may also like...

Leave a Reply

%d bloggers like this: