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 111.111.111.111 where username is root and password is myvps. So, now connect to the VPS using terminal:
[html]
ssh root@111.111.111.111
[/html]
If you connect for the first time, the following message could be appeared:
[box type=”shadow”]The authenticity of host ‘111.111.111.111 (111.111.111.111)’ 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:  Enable css for HTML5 tags in Older Internet Explorer: HTML5 – The Beautiful Butterfly! Part 3

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”]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
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
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
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 ras.mydomain.com 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:
[html]
$ ssh-keygen -R 111.111.111.111
[/html]

You may also read:  How to add extra field in the wordpress user profile

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:
[html]
sudo adduser sandbox
[/html]
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]
[/box]
Press Y and then press enter. New user ‘sandbox’ with password (in my case it’s sandbox too) is created!

You may also read:  Defer parsing of javascript to improve performance in wordpress

Now we need to give root privileges to sandbox user:
[html]
sudo /usr/sbin/visudo
[/html]
A text file will be opened in the terminal, add the following lines:
[html]
root ALL=(ALL:ALL) ALL
sandbox ALL=(ALL:ALL) ALL
[/html]
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:
[html]
sudo userdel sandbox
[/html]
And then you need to delete the user’s home directory:
[html]
sudo rm -rf /home/sandbox
[/html]
To change user:
[html]
su sandbox
[/html]
[/box]

You may also like...

Leave a Reply

%d bloggers like this: