This tutorial will show you how to install WordPress on Ubuntu 20.04 using Apache, MariaDB and PHP7.4 (LAMP Stack). WordPress is the most popular CMS (Content Management System) in the world. It is estimated that more than a third of all websites today are powered by WordPress. PHP7.4 made it into the Ubuntu 20.04 repository and WordPress runs perfectly with it.
To follow this guide, you need an Ubuntu 20.04 server with at least 1GB of RAM. My WordPress installation runs on a Raspberry Pi 4 with 8GB RAM. All you need is a Raspberry Pi, a microSD card and a power supply and a case. I recommend you to buy the Raspberry Pi 4. You don’t necessarily need the 8GB version. 2 to 4GB are completely sufficient.
This tutorial assumes you already have a LAMP stack set up on Ubuntu 20.04. If not, please see the following tutorial:
Manual: LAMP stack: Install web server on Ubuntu 20.04
For this guide I have Ubuntu running on a Raspberry Pi. Have you set up your Ubuntu server? Then you can continue with the instructions.
Install WordPress on Ubuntu 20.04 with Apache, MariaDB, PHP7.4 (LAMP).
Login to your Ubuntu 20.04 server via SSH and update the software:
sudo apt update && sudo apt upgrade
Important: The setup is based on the example domain domain-eins.de, which you have to adapt to your domain accordingly.
Download and unzip WordPress
Then go to the wordpress.org download page and download the zip archive. You can copy the direct download link by right-clicking the download button and selecting “Copy link address”.
WordPress Download for Ubuntu Server (image: screenshot).
Then type wget at the command line followed by the direct download link to download WordPress to your Ubuntu 20.04 server.
Then unpack the archive with unzip into the directory /var/www/.
sudo apt install unzip sudo mkdir -p /var/www/ sudo unzip latest.zip -d /var/www/
The option -i.e specifies the target directory. The WordPress web files are extracted to /var/www/wordpress. We can rename this directory as below so that we can easily identify each directory. Replace domain-eins.de with your real domain name.
sudo mv /var/www/wordpress /var/www/domain-eins.de
Create database and users for WordPress
Login to the MariaDB shell as root with the following command.
sudo mariadb -u root
or for mySQL
sudo mysql -u root
Once you’re logged in, create a database for WordPress with the following command. In this example, the database is called wordpress. However, the database name can have any name. However, you cannot omit the semicolon.
create database wordpress;
Then enter the following command to create a database user for WordPress. This command also grants the user all WordPress database permissions. Replace wpuser and your-password with your preferred username and password. Be sure to make a note of your username and password.
grant all privileges on wordpress.* to wpuser@localhost identified by 'dein-passwort';
Clear the permissions table for the changes to take effect, then exit the MariaDB shell.
flush privileges; exit;
WordPress needs some information before starting. Go to your WordPress folder (adapt domain-eins.de to your domain):
Copy the sample configuration file and rename it to wp-config.php around:
sudo cp wp-config-sample.php wp-config.php
Now edit the new configuration file using a command line text editor like Nano:
sudo nano wp-config.php
Find the following lines and replace the highlighted texts with the database name, username, and password you created in the previous step:
/** The name of the database for WordPress */ define('DB_NAME', 'database_name_here'); /** MySQL database username */ define('DB_USER', 'username_here'); /** MySQL database password */ define('DB_PASSWORD', 'password_here');
Save and close the file. To save the file in the Nano text editor, press Ctrl+O and then press Enter to confirm. Then press Ctrl+X to exit.
Also, we need to set the Apache user (www-data) as the owner of the WordPress site directory using the following command. Change domain-eins.de to the name of your folder. Adapt domain-eins.de to your domain.
sudo chown www-data:www-data /var/www/domain-eins.de/ -R
Apache Virtual Host File for WordPress
Want to host more than just a website on your Raspberry Pi on Ubuntu? For this you need a virtual host for your Apache.
Manual: Set up a virtual host for Apache
A virtual host is only needed if you want to host more than one website on your server, otherwise you can skip this step.
Set up a free Let’s Encrypt certificate on your web server
In the meantime, not much is possible without HTTPS. Browser manufacturers block websites that do not establish an https connection. Google sees https as a ranking factor for the search engine. With Let’s Encrypt, any website can be provided with a certificate for https encryption quickly and free of charge.
Manual: Set up Let’s Encrypt certificate on Apache
All inquiries about your website are sent encrypted via https to your web server on your Raspberry Pi and answered encrypted from there.
Install WordPress on your Apache server
Your Apache server is set up and you have created a database with MariaDB. Now you can start installing WordPress. Type the following into your browser (adapt domain-eins.de to your domain):
As a result, you will see the WordPress installation page and can start setting it up.
Install WordPress (image: screenshot).
Don’t despair: The installation wizard sometimes takes almost 5 to 10 minutes. During this time, the page shown above loads first. Then a page loads with “step2” in the URL. If it loads indefinitely, simply refresh the website.
If the installation wizard doesn’t appear, then you probably need to install some PHP7 extensions.
sudo apt install php7.4-mbstring php7.4-xml php7.4-mysql php7.4-common php7.4-gd php7.4-bcmath php7.4-json php7.4-cli php7.4-curl php7.4-zip
Then restart Apache and the wizard should now appear.
sudo systemctl reload apache2
You have now successfully installed WordPress on Ubuntu 20.04 with Apache, MariaDB and PHP7.4. Here in the example the whole thing runs on a Raspberry Pi.
Geek, Blogger, Consultant & Traveller. You can find more information about Benjamin on his details page. In his free time, Benjamin prefers to write about technology topics. In addition to instructions and how-tos, Benjamin is also interested in news about IT security. If technology is not the priority, Benjamin likes to go hiking.