How to Install WordPress on Ubuntu 18.04

r00t May 21, 2018

Install WordPress on Ubuntu 18.04

In this tutorial we’ll learn how to install WordPress on Ubuntu 18.04. We will also install and configure its prerequisites. WordPress is a strong, free and open-source, exceptionally pluggable and customizable CMS that is used by millions across the globe to run blogs and fully functional sites. With a massive repository of plugins and also an ever-growing number of highly elastic themes, WordPress is utilized for e-commerce, content management, and so much more.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 18.04 LTS minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install WordPress on Ubuntu 18.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y

Step 2. Installing LAMP on Ubuntu 18.04 LTS.

You should check out this LAMP stack install tutorial for Ubuntu 18.04, if you haven’t installed LAMP yet. Once it’s installed, come back here and read on. We also will install the required packages for LAMP stack and the important PHP extension that WordPress CMS relies on:

apt-get install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip

Step 3. Installing WordPress on Ubuntu 18.04.

First we are ready to download and unzip WordPress into webserver’s root directory. Start by downloading the latest WordPress package using curl command:

curl --output /tmp/wordpress.zip https://wordpress.org/latest.zip

Extract the archive into the location where you want your web root:

unzip wordpress.zip -d /var/www/
mv /var/www/wordpress/ /var/www/html

Then run the commands below to set the correct permissions for WordPress directories:

chown -R www-data.www-data /var/www/html

Step 4. Create a database for WordPress.

Next, we need to create a database for the WordPress installation:

mysql -uroot -p

Run the following command to create a database for WordPress:

MariaDB> CREATE DATABASE wordpress;
MariaDB> CREATE USER `wp_admin`@`localhost` IDENTIFIED BY 'yourpass';
MariaDB> GRANT ALL ON wordpress.* TO `wp_admin`@`localhost`;
MariaDB> FLUSH PRIVILEGES;

Step 5. Configure Apache web server for WordPress.

For this you can take the default config as a template:

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/wordpress.conf

Now edit the currently created Config as follows:

nano /etc/apache2/sites-available/wordpress.conf

Modify the virtual host file for your WordPress site to resemble the example below:

<VirtualHost *:80>
 ServerAdmin admin@example.com
 DocumentRoot /var/www/html
 ServerName example.com
 ServerAlias www.example.com

<Directory /var/www/html/>
 Options FollowSymlinks
 AllowOverride All
 Require all granted
 </Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Finally, reload the web server as suggested, for the changes to take effect:

a2ensite wordpress.conf
a2enmod rewrite
systemctl restart apache2.service

Step 6. Accessing WordPress.

Now you can access the WordPress web install wizard in your browser by entering the domain name or http://yourdomain/ to continue your WordPress installation.

Congratulation’s! You have successfully install and configured WordPress on your Ubuntu 18.04 Bionic Beaver server. Thanks for using this tutorial installing WordPress on Ubuntu 18.04 LTS (Bionic Beaver) system.

The Tags:

Leave a Comment

Comments are closed.