How to Install & Configure WordPress on Ubuntu 20.04 LTS.

WordPress is a free and open-source content management system written in PHP and Mysql database.Using wordpress we can create own website or blog.

WordPress is the most popular blogging system on the web and allows updating, customizing and managing the website from its back-end CMS and components.

Install the required services for wordpress like apache2,Mysql & PHP.

Install Apache2 Web Service

Update the System.

apt-get update

Install apche2 web service.

apt-get install apache2

Start & Enable Apache2 service.

systemctl start apache2
systemctl enable apache2


Install Mysql database.

Update the System.

apt-get update

Install Mysql database.

apt-get install mysql-server

Start & Enable Mysql service.

systemctl start mysql
systemctl enable mysql

Login to Mysql database.

mysql -u root

Press Enter.

Here is the command output.

Fig 1


Create MySQL user & set the password on MySQL user.

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

Create Database & provide the CHARSET.

CREATE DATABASE wordpress_database charset=utf8mb4;

Flush the privileges.


Here is the command output.

Fig 2


If we want to create MySQL user,database & Set the password without MySQL Login.Run the Following commands.

mysql -u root -e "CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';"
mysql -u root -e "CREATE DATABASE wordpress_database charset=utf8mb4;"
mysql -u root -e "GRANT ALL PRIVILEGES ON wordpress_database.* TO'user'@'localhost';"
mysql -u root -e "FLUSH PRIVILEGES;"


Install PHP8.0

Update the system

apt-get update

Enable PHP PPA repository

add-apt-repository ppa:ondrej/php 

Install PHP8.0

apt-get install php8.0 

Installing PHP Extensions

apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
apt-get install php-cli php-mysql php8.0-common php8.0-opcache php-gmp php-imagick

Check PHP version.

php -v


Install WordPress

Go to /var/www/html directory.

cd /var/www/html

Download the compressed file of WordPress.

curl -O

Extract the compressed file.

tar xzvf latest.tar.gz

Go to WordPress directory.

cd wordpress

Copy wp-config-sample.php to new file wp-config.php that WordPress actually reads.

cp wp-config-sample.php wp-config.php

Open the wp-config.php file & mention the following values:

define('DB_NAME', 'wordpress_database');

/** MySQL database username */
define('DB_USER', 'user');

/** MySQL database password */
define('DB_PASSWORD', 'password');

. . .

define('FS_METHOD', 'direct');

Here is the output.

Fig. 3

GIve the following permissions to WordPress folder.

chown -R www-data:www-data /var/www/html/wordpress/*
chmod 775 -R /var/www/html/wordpress/*


Configure the apache2 web service.

Create a new configure file.

vim /etc/apache2/sites-available/example.conf

Mention the following values:

<VirtualHost *:80>
    ServerAdmin server-admin-name@localhost
    ServerAlias www.server-alias-name
    DocumentRoot /var/www/html/wordpress/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /var/www/html/wordpress/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted

Enable the config file.

a2ensite example.conf

Disable the default config file.

a2dissite 000-default.conf

Enable the rewrite mode

a2enmod rewrite

Restart the apache2 web service.

systemctl restart apache2

Access WordPress Web Interface.

  • Access WordPress Web Interface by using the URL.
  • Select the Language.
  • Click on Continue.

Fig. 3


  • Provide Site Title.
  • Provide Username & Password.
  • Provide Email-Id.
  • Click on Install WordPress.

Fig. 4


  • Click on Log In.

Fig. 5


  • Provide Username & Password.
  • Click on Login.

Fig. 6


  • Now,WordPress Dashboard is ready.

Fig. 7




Leave a Reply