Install WordPress in Ubuntu 24.04

In this article, we cover how to install WordPress in Ubuntu 24.04 release. WordPress is one of the most popular web content management systems available. It is mainly used to publish blogs, create websites, etc.

At the time of writing, v6.4.2 is the latest stable release available.

Note: The following operations require Administrative rights. Contact your System Administrator if you don’t have the necessary rights to make modifications to your system.

Download WordPress

We can download WordPress from its official website:

Release Archive

Look for the .tar.gz file from the Latest release column. For us, the downloaded file was: wordpress-6.4.2.tar.gz. The filename would be different for you depending on the available version at the time.

Now, extract the .tar.gz file through the following command:

tar -xvf wordpress-6.4.2.tar.gz

This would create wordpress/ in the current directory.

Install LAMP Server

All the packages required to install the LAMP server are already available through the standard Ubuntu repository. Before installing packages, update the repository:

sudo apt update

Next, install the following packages:

sudo apt install apache2
sudo apt install php8.2
sudo apt install php8.2-mysql
sudo apt install mysql-server

However, it isn’t necessary to install the following packages. Still, we advise you to install them.

sudo apt install php8.2-curl
sudo apt install php8.2-mbstring
sudo apt install php8.2-xml

Configure database

Run the following command in the terminal to set up MySQL for WordPress:

sudo mysql_secure_installation

And, follow onscreen instructions.

Create a Database:

sudo mysql -u root -p

Enter the password we used earlier.

CREATE DATABASE wp_database;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'Pqwertyd6*';
GRANT ALL PRIVILEGES ON wp_database.* TO 'wp_user'@'localhost';

And, enter the above commands in the msql> to create a database – wp_database, user – wp_user, and password – Pqwertyd6*.

Edit Configuration file

Edit the config file: 000-default.conf

sudo nano /etc/apache2/sites-available/000-default.conf

And, append the file with:

<Directory /var/www/html/>
     AllowOverride All

Also, enable the rewrite module:

sudo a2enmod rewrite

To check if there is an issue with the configuration:

sudo apache2ctl configtest

Finally, restart the Apache service:

sudo systemctl restart apache2.service

Setup WordPress

Head to the wordpress/ directory:

cd /path/to/wordpress-directory/

Copy wp-config-sample.php as wp-config.php

cp wordpress/wp-config-sample.php wordpress/wp-config.php

Also, copy the entire wordpress/ to /var/www/html

sudo cp -a wordpress/. /var/www/html/

Use the chown command-line utility to change /var/www/html ownership:

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

Next, edit wp-config.php file:

sudo nano /var/www/html/wp-config.php
define( 'DB_NAME', 'wp_database' );
define( 'DB_USER', 'wp_user' );
define( 'DB_PASSWORD', 'Pqwertyd6*' );

Use the entries from the Configure Database section.

Remove index.html if it is there:

sudo rm /var/www/html/index.html

Lastly, restart the Apache service:

sudo systemctl restart apache2.service

Now, open a web browser and enter the following in the address bar:


And, follow onscreen instructions.

This should install WordPress in Ubuntu 24.04 release.

Similar Posts