Installing WordPress on Ubuntu 19.04

Install LAMP Stack

To begin installation of the LAMP stack (Linux, Apache, MariaDB, PHP) we update the apt catalog. Then we select the packages to install. NOTE: We are also including the git package now so we can use it later.

sudo apt update
sudo apt install apache2 apache2-utils mariadb-server mariadb-client php7.2 php7.2-mysql libapache2-mod-php7.2 php7.2-cli php7.2-cgi php7.2-gd git

Once the packages are installed, we start them and configure them to auto-start at system bootup. Additionally, we can run the mysql_secure_installation script to secure our mariadb database

sudo systemctl enable apache2
sudo systemctl start apache2
sudo systemctl enable mariadb
sudo systemctl start mariadb

sudo mysql_secure_installation 

Setup Database

Once the database server is secured, we need to create a database for WordPress to access. To do this, we start by calling the mysql command to login as root, using the password we just specified.

sudo mysql -u root -p

Inside the mysql tool, we create the database and user with the following commands

CREATE USER wordpressuser@localhost IDENTIFIED BY 'Password01';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'Password01';

Install WordPress

Once the database is setup, we are ready to download and install the WordPress site. To do this, we change some file permissions and use git to download from

cd /var
sudo chown -R administrator www
cd /var/www/html
git clone

Configure WordPress

Now that the WordPress files are downloaded, we need to edit a file with the correct user and password information for the database. Since this is being done on an Ubuntu system, we can use the nano editor

cd WordPress
cp wp-config-sample.php wp-config.php
nano wp-config.php

Inside the file, we find the lines configuring the DB_NAME, DB_USER, and DB_PASSWORD and update them as appropriate

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'Password01');

Finally, we reset the file ownership to www-data so the apache web service can access the files correctly

sudo chown -R www-data:www-data /var/www/html

Finalize Setup

Once complete, open a web browser and go to http://localhost/WordPress (case sensitive) and finalize the setup.

Leave a Reply