Today I got a new Linux VPS, therefore I decided to show you all the steps I took to migrate to my WordPress site to the new server.
So let’s get started.
Firstly, it is always good practice to update the OS.
apt update
apt upgrade
Install apache2
apt install apache2
Install php7.3. By default, version 7.3 will not be detected. The repository PPA must be added. You might need the first command if the “add-apt-repository” is not available.
apt install software-properties-common
add-apt-repository ppa:ondrej/apache2
apt-get install php7.3
You should see the Apache2 default site if you enter the IP address in your browser:
Now enable the MySQL extension in the PHP config file:
nano /etc/php/7.3/apache2/php.ini
Remove the comment (semicolon) at extension=pdo_mysql. You can search with CTRL+W in Nano GNU editor.
CTRL+X saves the file.
Now install php7.3-mysql
apt-get install php7.3-mysql
The root directory of your WordPress files can be created:
mkdir -p /var/www/website
Make a config file for Apache2 from the default config.
It was very cheap (4$ or 3.75€ annually), but with a lot of gotchas.
One of them is Ubuntu 18.04 Minimal, which means a lot of packages will not be pre-installed, causing a lot of pain when installing services like in my example OpenVPN.
Here is how I managed to install OpenVPN on Ubuntu 18.04 Minimal.
The first problem occurs with the root CA certificates:
Install the root certificates in order to trust them:
apt-get install ca-certificates
After re-running the command, another error shows up:
Install the next package (iptables):
apt-get install iptables
And finally, the OpenVPN setup can be run:
I had to set a custom port, because only specific ones were NAT’d to my server. You might leave the port to default. I am also using 1.1.1.1 for DNS.
After the setup is finished, a configuration file will be created. This file contains the public certificates and private key that are mandatory for the connection. It can be imported into the OpenVPN client (Windows) through the GUI.
On Linux, a simple
openvpn configfile.ovpn
does the trick.
If you are looking for a VPS with good performance, check out Evolution Host at https://evolution-host.com/vps-hosting.php. They offer virtual servers starting at 5€ per month.
By default, Linux systems allow both password-based and key-based authentication over SSH. If you have a server with SSH open to the world, password-based authentication shouldn’t be allowed at all.
To disable password-based authentication, edit the SSH config file:
nano /etc/ssh/sshd_config
Add the following lines:
PasswordAuthentication no
PubkeyAuthentication yes
Now generate a new private/public key pair:
ssh-keygen
id_rsa is your private key
id_rsa.pub is the public certificate thumbprint that must be added to ~/.ssh/authorized_keys
nano ~/.ssh/authorized_keys
The SSH service must be restarted.
service ssh restart
Now you can connect to your server with key-based authentication only. If connecting from a Linux system the file’s permissions must be set to 600.
chmod 600 id_rsa
ssh -i id_rsa ip@username
If you like using Putty, you’ll have to load the file with PuttyGen and save the private key as .ppk.
Today I stumbled upon this very useful site that helps you find very cheap virtual private servers (VPS) around the globe. The public IPv4 address is shared and NAT’d across multiple servers. If that’s no problem for you, the cheapest servers are 0.15€ a month with 128MB RAM and 1 vCPU.
Also, some public IP addresses are blocked in China and/or Russia.