how to install Wordpress on Ubuntu

How to Install WordPress on Ubuntu?

Content management systems today are extremely useful tools for creating sites. One such system is WordPress. It gained its popularity due to its simplicity and ease of use. This article describes how to install WordPress on Ubuntu.

Apache Installation

In order for WordPress to be visible on the Internet, you need to use a web server. Here is an example of Apache, the most popular web server.

Installing Apache and all packages dependent on it can be done with the following command:

sudo apt install apache2

Turn it on and add it to startup:

sudo systemctl start apache2

sudo systemctl enable apache2

To verify that the web server is working, send several packets to localhost. They must not be lost.

install wordpress ubuntu

Install and Configure the Database

WordPress stores information in a DB. In this case, it will be MariaDB. To install it, enter the line:

sudo apt install mariadb-server

Also, enable and add this DBMS to startup:

sudo systemctl start mariadb

sudo systemctl enable mariadb

Execute the mysql-script, answering in the affirmative to all questions:

sudo mysql_secure_installation

Next, log in to the DBMS as root:

mysql -u root -p

Input the new password that you created for root in the script above.

If a login error occurs at this point

wordpress ubuntu

then execute the lines:

sudo mysql

use mysql;

update user set plugin='' where User='root';

flush privileges;


Now log in to the DBMS again as root.

The prompt string in the terminal will change. Create a new DB with any name (for example, wp_db). Please note that at the end of each line entered here you need to write a semicolon character “;”.


Add a new user with a password to work with this database:

CREATE USER ‘wp_admin’@’localhost’

IDENTIFIED BY ‘new_admin_password’;

Give user all the privileges to interact with the database:

GRANT ALL ON wp_db.* TO ‘wp_admin’@’localhost’


Reload the permissions table:


Quit the DBMS:


install wordpress ubuntu server

PHP Installation

WordPress is written in PHP, so you need to install it. Standard repositories contain a stable version of the language.

sudo apt install php php-cli php-cgi php-gd php-mysql

Install and Configure WordPress

CMS provides a convenient link for downloading the latest version of the program:

wget -c

Unzip the archive to the current folder. The wordpress directory will be created:

tar xzvf latest.tar.gz

Copy the contents of the WordPress directory to /var/www/html/:

sudo rsync -av wordpress/* /var/www/html/

Give the user www-data ownership of all the copied files with chown command:

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

Also, overwrite file permissions:

sudo chmod -R 755 /var/www/html/

Go to the directory with CMS:

cd /var/www/html/

Rename the configuration file to make it workable:

sudo mv wp-config-sample.php wp-config.php

Open the wp-config.php file and correct the constants in accordance with the database data created earlier:

install wordpress ubuntu 18

Now restart Apache and MariaDB:

sudo systemctl restart apache2

sudo systemctl restart mariadb

It remains to delete the index.html file that was in this directory from the very beginning:

sudo rm index.html

This completes the installation of WordPress. To verify the success of the process, go to http://localhost. A welcome CMS window should appear.

install wordpress on ubuntu 18.04

It is worth noting that a similar instruction with the input data and the location of the CMS files are shown as examples. It is not recommended to be used in this form (except for the test). Details of setting up WordPress can be found on the official website.

Add Your Comment