How to Install WordPress on Ubuntu 20.04 and 20.10

This post will help you install latest version of WordPress on Ubuntu desktop and server using terminal.

Here are system requirement for installing WordPress; you need to have PHP, MySQL and web server like apache2 or NGINX. I am going to user apache2 as a web server.

Install MySQL Server on Ubuntu

sudo apt update && sudo apt upgrade
sudo apt install mysql-server -y
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'XXXXX';
FLUSH PRIVILEGES;
exit
mysql -u root -p

Login with your newly created MySQL password.

Install apache2 and PHP

sudo apt install apache2

sudo apt install php libapache2-php-mod-php php-mcrypt php-mysql
sudo systemctl restart apache2

Check your web server in your preferred web browser by visiting localhost

Test PHP Script

Create a php file under /var/www/html/

touch /var/www/html/info.php
<?php  echo "hello from apache";

Visit localhost/info.php in your web browser and it should work.

Download & Install WordPress on Ubuntu

I assume that you have installed wget and unzip on your ubuntu desktop or server.

If you have not yet.

sudo apt install wget && sudo apt install unzip

To download and install WordPress

cd /var/www/html/
wget https://wordpress.org/latest.zip
unzip wordpress.zip && rm -R wordpress.zip

Give Write Permission to WordPress directory

sudo a2enmod rewrite

To give write permission to the folder
sudo chown -R username /var/www/html/

html $ sudo nano wp-config.php
define(‘FS_METHOD’, ‘direct’);

WordPress – file write permission for apache server
sudo chown -R www-data:www-data /var/www/html

Create Database for WordPress

To create database for your WordPress installation, login to your MySQL server and create a new database.

mysql -u root -p
CREATE DATABASE mywp1;
exit

Install WordPress

  1. Launch your web browser and pull up localhost/wordpress
  2. Click Let’s Go
  3. Feed Database credential
  4. Click Run Installation Script
  5. Create Admin profile
  6. Login to your admin area localhost/wordpress/wp-admin