WordPress is an open-source Content Management System and it helps users to build their websites. If you are hosting a website through your Linux VPS server, there is a high chance that you need WordPress to help you manage your websites. Before you start installing WordPress onto your VPS, you are required to install the LAMP stack. Note that you would also be required to access the VPS with a SSH and required to have sudo access for this installation. The Linux distribution used in this guide is Ubuntu version 18.04.
Step 1: Before Installation
Create an Apache configuration file called “WordPress.conf” in the directory “/etc/apache2/sites-available/”. Open the configuration file created earlier and paste the following lines into it to enable .htaccess.
<Directory /var/www/wordpress/>
AllowOverride All
</Directory>
Make save changes to the Apache configuration file and exit. Then create another directory called “wordpress” in the directory “/var/www/” using the following command.
mkdir /var/www/wordpress
To use the WordPress permalink feature, run the following command to enable the “mod_rewrite” in the system.
sudo a2enmod rewrite
Restart the Apache web server for the changes to take effect by running this command.
systemctl restart apache2
Next, go to the directory “/etc/apache2/” and open the file “apache2.conf” using the following command.
nano /etc/apache2/apache2.conf
Next, change the “ServerName” directive to your server’s IP address. Add the following line into the configuration file you had just opened.
ServerName <IP_Address>
Replace the <IP Address> with your IP address. Make save changes and exit your text editor. To verify if the Apache configuration is working, run the following command in your terminal.
apachectl configtest
You should be able to see an output printing “Syntax OK” if the configuration is working.
Step 2: Installation
After you have done the preparation, open your terminal once again and use the following command to install the “wget” option.
sudo apt install wget -y
After acquiring the “wget” option onto your server, download the official WordPress file using the following command.
wget https://wordpress.org/latest.zip
After finishing downloading the required files, use the following commands to install the unzip option onto the server.
ls sudo apt install unzip -y
After that, move all the downloaded WordPress files to the directory “/var/www/html” using the following command.
mv latest.zip /var/www/html
To navigate the directory, use the cd option, then unzip the file in the directory. Run the commands below line by line to unzip the file.
cd /var/www/html
unzip latest.zip
To move the wordpress directory, run the following command.
mv -f wordpress/*./
Finally, remove the file “index.html” from the directory by using the following command.
sudo rm -rf index.html
After removing the “index.html”, you may verify if it’s removed using the ls command. Your installation will be completed after rebooting Apache2 using the following command.
sudo systemctl restart apache2 sudo chown -R www-data:www-data /var/www/
Step 3: Setting Up
After you have completed it, you may set up your WordPress through your web browser. To access the WordPress setup page, open your web browser and type in your server’s IP address and you should be able to set up your WordPress following the instructions there.