Table of contents
WordPress is a multi-platform content management system (CMS) for managing and creating websites, internet-shops and blogs. WordPress is used by small businesses, individual bloggers, educational institutions, nonprofit organizations, and even giant organizations, implying that it is suitable for everyone, regardless of who you are or what you want to achieve with your website. According to w3techs.com WordPress consumes more than 63% of the CMS market, and that percentage is constantly rising. In this article we’ll show you how you can install WordPress on your Ubuntu server.
Prerequisites
- You must have root access to your system or have sudo privileges (more information about sudo) to continue the installation.
- You need to install Apache, MySQL, PHP (LAMP stack) first. Provided guidance includes free SSL certificate for handling secure HTTPS connections.
Installing WordPress
As soon as you’ve installed the LAMP stack, we can move forward to the WordPress installation itself.
Creating database
In this section we’ll do the following:
- Create WordPress database
- Create WordPress role – defines permissions to access the database
- Create WordPress user
- Attach WordPress role to WordPress user
- Test user connection to the database
Let’s open MySQL console client:
sudo mysql

Now, you can create a WordPress database:
CREATE DATABASE wordpress_db;

As the next step, we need to create a database role for WordPress user:
CREATE ROLE wordpress_role;

And grant WordPress role access to WordPress database:
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_role';

Now, we can create a database user for WordPress:
CREATE USER wordpres@localhost IDENTIFIED BY RANDOM PASSWORD;

Note: save generated password somewhere, you’ll need it soon.
Finally, we need to grant wordpress_role
role to the wordpress
user and set it as default role:
GRANT 'wordpress_role' TO 'wordpress_user'@'%';
SET DEFAULT ROLE 'wordpress_role' to 'wordpress_user'@'%';

Now, exit from the MySQL client by pressing Ctrl+d and test that the WordPress user can connect to the database:
mysql -u wordpress_user -p

We have finished a database creation part successfully.
Downloading WordPress
At this stage we need to download WordPress and make required changes with its source code.
First of all, let’s download the WordPress distribution:
wget https://wordpress.org/latest.tar.gz

Now, let’s extract the downloaded archive (for more information on using tar
, read How to extract .gz and .tar.gz files in Linux):
tar xzvf latest.tar.gz

We will copy these files into our Apache document root folder as soon as we finish required configuration steps.
WordPress initial configuration
Let’s start from creating a .htaccess file first:
touch wordpress/.htaccess

Now, create a WordPress configuration file by copying the wp-config-sample.php file to the wp-config.php:
cp wordpress/wp-config-sample.php wordpress/wp-config.php

Next, create an upgrade directory:
mkdir wordpress/wp-content/upgrade

Use the curl command to get random keys required for WordPress to function (save them somewhere, we’ll use them in a second):
curl -s https://api.wordpress.org/secret-key/1.1/salt/

Now, let’s edit wp-config.php file:
nano wordpress/wp-config.php
Make required changes to specify WordPress database connection:

Scroll down the file and edit random WordPress keys:

Once the database credentials and WordPress random secure keys and salts are added, save your file by pressing CTRL+x, y, and Enter.
Important: I’m assuming, that you’re installing WordPress on a brand new server, so, I’ll clean up Apache server document root folder (/var/www/html) and copy wordpress folder content there.
rm -Rf /var/www/html/*
sudo cp -R wordpress/* /var/www/html/

Now, we’re ready to finalize WordPress deployment in Web UI.
WordPress installation (web interface)
Launch your browser and enter the server IP address or DNS hostname in a search bar.
Now, set all credentials to manage the content and press “Install WordPress“.

After a couple of seconds, you’ll see a screen telling that WordPress has been successfully installed.

To move to your site’s Admin Dashboard, click “Log in” and login with the username and password you specified at the previous step.

Congratulations!
The WordPress has been successfully installed!
Summary
WordPress is a free and open-source content management system that can be used to build everything from simple websites to blogs, large portals, and enterprise websites. In this article, we have described how to install WordPress on Ubuntu Linux server.
Related articles
- How To Use Terraform Kubernetes Provider
- How to install Apache, MySQL, PHP (LAMP stack) on Ubuntu
- CloudFormation: How to create DMS infrastructure for DB migration
- CloudFormation – How to validate ACM SSL certificate
How useful was this post?
Click on a star to rate it!
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?
I’m a passionate Cloud Infrastructure Architect with more than 15 years of experience in IT.
Any of my posts represent my personal experience and opinion about the topic.