Home » Linux » Install WordPress and MySQL on Ubuntu

Install WordPress and MySQL on Ubuntu

cup of coffee, notebooks, a pen and a table device

WordPress is a software which was initially designed for blogging (weblog) purposes. A blog software can be used to publish content chronologically to the internet. Over the time and with ongoing releases WordPress developed and nowadays it can be used as a basis for ordinary webpages. It can be used similar as Joomla! or Drupal or even Bootstrap (HTML and CSS).

If you want to run your own blog or a small webpage WordPress is first choice.

To customize the base system, a broad range of themes and plugins can be installed. Most of them are free and only advanced use costs money.

WordPress is popular because first successes can be achieved easily a no software development skills are required to set up a nice little web page.

The development of WordPress goes on and the current version is 6 and its sub versions. WordPress is based on PHP and runs on the Apache2 web server and on Linux. This tutorial shows the installation of WordPress on Ubuntu Linux.

1. Install Software

First of all we need to install software on our Ubuntu. Open a terminal and type the following lines to have a web server (Apache2), a database (MySQL) and PHP installed:

sudo apt-get --yes install mysql-server apache2 
sudo apt-get --yes install libapache2-mod-php php-mbstring 
sudo apt-get --yes php-xml php-intl php-mysql
sudo a2enmod php7.4

2. Create the MySQL Database

Now we need to run the MySQL Command Line Interface (CLI). Therefor we need to execute in a terminal:

sudo mysql -u root -p

We are in the MySQL CLI now. Type:

mysql> CREATE DATABASE wordpress;

As the next step, we need to create a user, grant the necessary permissions to the user and at the same time we are setting a password:

mysql> CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'secpasswd';
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';

And then we quit the MySQL CLI:

mysql> quit

3. Download WordPress to the right Directory

Now we need to download and extract WordPress in a terminal/shell with these commands:

cd /var/www/html
sudo wget https://wordpress.org/latest.zip
sudo unzip latest.zip

To not run into an error during the installation, the ownership for the WordPress directory has to be changed. On my Ubuntu system the “www-data” user and the “www-data” group need to have the ownership of the directory structure. Run the following command:

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

6. Install and Configure WordPress

Next, open an internet browser and connect to “http://localhost/wordpress”.

Select a language and click on “Let’s go!”. Now the fine tuning has to be done. Provide these settings:

Database: "wordpress" 

Username: "wordpress"

Password: "secpasswd"

Database Host: "localhost"

Click to “Submit” and on the next page “Run the installation”.

Provide now “Site Title”, the WordPress “Username”, a secure WordPress password, your email address and click to “Install WordPress”.


Congratulations! You successfully installed WordPress on your Ubuntu computer! Open a browser and connect to “http://localhost/wordpress/” and login. You can check out now the backend of WordPress and you have a basic site set up for future customization.

Continue with installing themes and plugins and the configuration of menus. It’s just easy to go on from this point.

If you are interested in other CMS, check out my Joomla!, CMSimple or Confluence tutorials!

Feel free to comment this post!

Leave a comment

Your email address will not be published. Required fields are marked *

consulting picture

WordPress Cookie Notice by Real Cookie Banner