How to Install Wordpress on Ubuntu Server

wordpress installation guide

This WordPress installation guide helps you to install and configure the latest WordPress on an Ubuntu Linux box. It covers Apache, MariaDB, PHP and Wordpress configurations.

Wordpress Installation On Ubuntu Server

This installation guide covers the following.

  1. Installation and configuration of Apache2
  2. Installation and configuration for MariaDB
  3. Installation and configuration of PHP and Apache modules.
  4. Wordpress apache configurations with a domain name.
  5. Accessing the WordPress dashboard.

Follow the steps given below for the complete WordPress setup on Ubuntu 23.04

Install and Configure Apache 2

Step1: Login to the server and update the package repos.

sudo apt-get update -y

Step 2: Install apache2

sudo apt-get install apache2 -y

Step 3: Execute the following command to disable anonymous directory listing.

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/apache2/apache2.conf

Step 4: Start, enable and check the status of apache2

sudo systemctl stop apache2
sudo systemctl enable apache2
sudo systemctl start apache2

Install and Configure MariaDB

Step 1: Install Marais DB database server and client

sudo apt-get install mariadb-server mariadb-client -y

Step 2: Use the following commands to Start,  Stop, enable and check the status of MariaDB service.

sudo systemctl stop mysql
sudo systemctl start mysql
sudo systemctl enable mysql
sudo systemctl status mysql

Step 3: Setup the root admin password for the database using mysql_secure_installation command. It will prompt you for setting up the new password.

sudo mysql_secure_installation

Use the following options for the prompt.

Enter current password for root (enter for none): Just press the Enter
Set root password? [Y/n]: Y
New password: Enter password
Re-enter new password: Repeat password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y

Step 4: Restart the database server for the changes to take effect.

sudo systemctl restart mysql

Setup and Configure PHP

Step 1: Install PHP 8 and its related modules.

sudo apt-get install php8.2 php8.2-mysql libapache2-mod-php8.2 php8.2-cli php8.2-cgi php8.2-gd

Step 2: Open  /etc/php/8.2/apache2/php.ini file

sudo vi /etc/php/8.2/apache2/php.ini

Add the following contents to the file.

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_filesize = 150M
max_execution_time = 350
date.timezone = America/Chicago

Configure Database For Wordpress

Step 1: Login to the database using the password you set for root.

sudo mysql -u root -p

Step 2: Create a database named “wordpress-db”

CREATE DATABASE wordpress_db;

Step 3: Create a new databases user named “wordpress-admin” and set a custom password. This user will be used in the WordPress configuration.

CREATE USER 'wordpress-admin'@'localhost' IDENTIFIED BY 'your_password_here';

Step 4: Grant all privileged on wordpress-db for wordpress-admin user. Replace the password you set for wordpress-admin.

GRANT ALL ON wordpress_db.* TO 'wordpress-admin'@'localhost' IDENTIFIED BY 'your-password-here' WITH GRANT OPTION;

Step 5: Flush all privileges and exit the db shell.


Setup and Configure Wordpress

Step 1: Download latest WordPress


Step 2: Untar the WordPress files

tar -xvf latest.tar.gz

Step 3: Move the WordPress folder to /var/www/html folder.

sudo mv wordpress /var/www/html/wordpress

Step 4: Change the ownership of the wordpress folder to www-data

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

Step 5: Change the folder and file permissions using the following command. Folders should have 755 permission and files should have 644 permission.

find /var/www/html/ -type d -print0 | xargs -0 chmod 0755
find /var/www/html/ -type f -print0 | xargs -0 chmod 0644

You can check if the permissions have been applied using the following command.

stat -c "%a %n"  /var/www/html/wordpress/*

Configure Apache For Wordpress

Step 1: Create a new Apache configuration named wp-site.conf for the WordPress site.

sudo vi /etc/apache2/sites-available/wp-site.conf

Add the following configuration to the file and save it. Replace yourdomain with you custom domain name.

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/wordpress/

     <Directory /var/www/html/wordpress/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined


Step 2: Enable wp-site.conf

sudo a2ensite wp-site.conf

Step 3: Enable the apache rewrite module.

sudo a2enmod rewrite

Step 4: Restart the apache server.

sudo systemctl restart apache2

Configure Wordpress Application

Step 1: Rename the default wp-config-sample.php to wp-config.php

sudo mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php

Step 2: Open the wp-config.php file

sudo vi /var/www/html/wordpress/wp-config.php

Replace the values highlighted in the image below with database, user, and password generated in previous steps.

wp-config.php wordpress database details

Step 3: Now you have configured your site details on wp-site.conf file, try to access WordPress by browsing the domain name you used on the wp-site.conf file.

Make sure your server is mapped to the domain name you configure in the wp-site.conf file.

If you haven’t configured a domain name, you can access the installed WordPress with


Step 4: Select the preferred language and fill up the details in the configuration wizard.

wordpress configuration wizard.

Step 5: Once WordPress is installed, you can access the dashboard using the username and password.

wordpress dashboard
  1. Is the
    wp-site.conf needed for your Localhost on your own Computer?
    If so could you give an example of what ought to be written into that file please.

Leave a Reply

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

You May Also Like