How to Install WordPress on Ubuntu 18.04


How to Install WordPress on Ubuntu 18.04 – WordPress is a content management system based on PHP and MySQL that is usually used with the MySQL or MariaDB database servers but can also use the SQLite database engine. Features include a plugin architecture and a template system, referred to inside WordPress as Themes

Why WordPress is Popular?

Why is WordPress this popular? Let’s briefly look into some of the factors that have led to the immense success of the platform.

How to Install WordPress on Ubuntu 18.04

Step 1: Install Apache

$ sudo apt install apache2

To confirm that Apache is installed on your system, execute the following command.

$ systemctl status apache2

To verify further, open your browser and go to your server’s IP address.

Apache Landing Page

Step 2: Install MySQL Server

MySQL is an open-source relational database management system. Its name is a combination of “My”, the name of co-founder Michael Widenius’s daughter, and “SQL”, the abbreviation for Structured Query Language.

Lets Install the MySQL package with the following command:

$ sudo apt install mysql-server

Once the installation is completed, the MySQL service will start automatically. To check whether the MySQL server is running.

$ sudo systemctl status mysql


● mysql.service – MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-11-20 11:30:23 PDT; 5min ago
Main PID: 17382 (mysqld)
Tasks: 27 (limit: 2321)
CGroup: /system.slice/mysql.service
`-17382 /usr/sbin/mysqld –daemonize –pid-file=/run/mysqld/

Please log on to the mysql server using below command along with the root credentials which you provided during installation

$ mysql -u root -p

Securing MySQL

Please run below command and follow screen instructions to secure the MySQL installation

$ sudo mysql_secure_installation

Step 3: Install PHP

Finally lets install PHP on Ubuntu 18.04 server

$ sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

To confirm that PHP is installed , created a info.php file at /var/www/html/ path

$ vim /var/www/html/info.php

Append the following lines:


Open your browser and try to access below URL


If you have installed PHP correctly you can see below PHP info page.

Step 4: Create WordPress Database

Now it’s time to log in to our MySQL database as root and create a database for accommodating our WordPress data.

$ mysql -u root -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 44657
Server version: 5.7.28-31 Percona Server (GPL), Release '31', Revision 'd14ef86'

Copyright (c) 2009-2019 Percona LLC and/or its affiliates
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


Create MySQL Database

CREATE DATABASE secureserver;

Create MySQL User

CREATE USER 'secureuser'@'localhost' IDENTIFIED BY 'password';

Grant database full access to the user.

GRANT ALL PRIVILEGES ON  secureserver . * TO 'secureuser'@'localhost';



Step 5: Install WordPress CMS

To install WordPress you need to create Apache virtual host for your domain, please read How To Configure Apache Virtual Hosts In Ubuntu 16.04-18.04 or simply download latest release to default document root.

Navigate to your document root and download WordPress latest release using below command.

$ sudo wget

Please extract download zip file using below command

$ sudo unzip

Please note you need to point Apache virtual host document root to “wordpress” folder

Use below commands to make necessary file system permission.

$ find . -type f -exec chmod 664 {} \;

$ find . -type d -exec chmod 775 {} \;

$ sudo chown -R www-data:www-data . or sudo chown -R :www-data

Open your browser and go to the server’s URL. In our can it can be.


You’ll be presented with a WordPress wizard and a list of credentials required to successfully set it up.

Wordpress Installation Wizard
WordPress Installation Wizard

Fill the form as shown with the credentials specified when creating the WordPress database in the MySQL database.

Please follow the screen instructions to complete the WordPress setup.

Wordpress Dashboard
WordPress Dashboard



Please enter your comment!
Please enter your name here

Share post:



More like this

How to Protect WordPress with Cloudflare

Cloudflare, Inc. is an American content delivery network and...

Facebook Outage

Mike Schroepfer - CTO @ Facebook. *Sincere* apologies to everyone...

Magento 2 One Page Checkout (One Step Checkout)

Magento 2 One Page Checkout - One Page checkout...