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, which is constantly rising. This article will show you how to install WordPress on your Ubuntu server.
Table of contents
- 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, and PHP (LAMP stack) first. Provided guidance includes a free SSL certificate for handling secure HTTPS connections.
Once you’ve installed the LAMP stack, we can move forward to the WordPress installation.
In this section, we’ll do the following:
- Create the 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 the MySQL console client:
Now, you can create a WordPress database:
CREATE DATABASE wordpress_db;
As the next step, we need to create a database role for the 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 the generated password somewhere. You’ll need it soon.
Finally, we need to grant
wordpress_role role to the
wordpress user and set it as the 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 the database creation part successfully.
We need to download WordPress and make the required changes to its source code at this stage.
First of all, let’s download the WordPress distribution:
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 the required configuration steps.
WordPress initial configuration
Let’s start by creating the
.htaccess file first:
Now, create a WordPress configuration file by copying the
wp-config-sample.php file to the
cp wordpress/wp-config-sample.php wordpress/wp-config.php
Next, create a directory for upgrades:
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 the
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 you’re installing WordPress on a brand new server, so I’ll clean up the Apache server document root folder (
/var/www/html) and copy the
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 you that WordPress has been successfully installed.
To move to your site’s Admin Dashboard, click “Log in” and log in with the username and password you specified at the previous step.
The WordPress has been successfully installed!
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 an Ubuntu Linux server.
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.