Install WordPress on Ubuntu 18.04 in just a couple of steps, it will be secure and you will directly be able to make use of your freshly installed WordPress website.
We have explained two ways on how you can install WordPress on Ubuntu 18.04, the fast way, which is a list of all the commands you need to follow to install WordPress, and the second, which is a step by step guide.
We strongly recommend to make use of the step by step guide, as this will provide more details. It also contains screenshots, so that you can verify if you are getting the same results.
How to install WordPress on Ubuntu 18.04
Install WordPress on Ubuntu is easy, in this guide, we will make use of the software package LAMP, and we will install some PHP and of course, we will download and install WordPress on your Ubuntu 18.04 system.
The fast way of Installing WordPress on Ubuntu
If you do not have a lot of time left, and you want to install WordPress, then we have made this list for you. In the list below, you will find 16 commands that you need to execute, once these commands have been executed, you can enjoy your freshly Ubuntu installed WordPress website.
The 16 steps to install WordPress on Ubuntu 18.04 are:
- sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc
- sudo tasksel install lamp-server
- sudo mysql_secure_installation
- sudo ufw allow in “Apache Full”
- sudo mysql -u root -p
- create database wordpress;
- create user ‘wpdb’@’localhost’ IDENTIFIED BY ‘your-freshly-generated-password’;
- FLUSH PRIVILEGES;
- cd /var/www/html
- sudo rm index.html
- wget https://wordpress.org/latest.tar.gz
- sudo tar xpf latest.tar.gz
- sudo cp -R /var/www/html/wordpress/* /var/www/html/
- sudo rm -rf wordpress
- sudo chown -R www-data:www-data /var/www/wordpress
The step by step guide way
If you want to install WordPress step by step, then this part is for you. We have listed down the commands, and we have included the screenshots that will provide additional information so that you can verify if the installation is going as wanted.
In this part we will install the webserver software (LAMP) that will allow the WordPress website to be viewed.
LAMP stands for Linux, Apache, MariaDB/MySQL and PHP
The installation command is:
$ sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc
followed by the installation of LAMP
$ sudo tasksel install lamp-server
Time to setup MYSQL in a more secure way
Now that we have MySQL on the system, we will make sure that we have a default secure MySQL installation. In order to do this, we need to enter the command shown below.
$ sudo mysql_secure_installation
Add some rules to the Ubuntu Firewall
$ sudo ufw allow in "Apache Full"
Login to Mysql
$ sudo mysql -u root -p
Create the database for WordPress
$ create database wordpress;
Create WordPress DB user
$ create user 'wpdb'@'localhost' IDENTIFIED BY 'your-freshly-generated-password';
Flush the priviliges
$ FLUSH PRIVILEGES;
Download and install WordPress
Now we will download and install WordPress, but before we continue, we will remove all the default files that are not needed in the /var/www/html folder, afterwards, we will move WordPress to that folder.
Remove default files
Alright, let’s remove the default files by following the commands below.
$ cd /var/www/html
$ sudo rm index.html
It is time to download WordPress, we have setup the LAMP environment, we did some small security configurations, and now we need to download, install and configure WordPress.
Download the latest version
Always download the latest version from the official WordPress website.
$ wget https://wordpress.org/latest.tar.gz
The download is a tar.gz file, we need to unpack this with the tar command.
$ sudo tar xpf latest.tar.gz
Lets place WordPress in the /var/www/html folder
Instead of having the folder ‘WordPress’, we will move the content of that folder, one layer up, so we can remove the foldername WordPress.
$ sudo cp -R /var/www/html/wordpress/* /var/www/html/
$ sudo rm -rf wordpress
Make sure to set the permissions correct
$ sudo chown -R www-data:www-data /var/www/wordpress
Navigate to your website IP address or domain, and follow the WordPress installation wizard.