How to Install WordPress on Ubuntu 24.04 LTS

In this article, we will install WordPress on Ubuntu 24.04 LTS using Nginx, MariaDB, and PHP 8.3.

What is WordPress?

WordPress is a free and open-source content management system (CMS) that allows users to create websites, blogs, and online stores. It runs on PHP and uses MariaDB or MySQL as a database. With its vast collection of themes and plugins, WordPress is highly customizable, making it a popular choice for beginners and professionals alike.

Prerequisites:

  • AWS Account with Ubuntu 24.04 LTS EC2 Instance.
  • A non-root user with sudo privileges

Step #1:Update System Packages on Ubuntu 24.04 LTS

Before installing any software, ensure your package lists are up-to-date.

sudo apt update 
image 69

Step #2:Install Nginx Web Server on Ubuntu 24.04 LTS

Install the Nginx web server using the following command.

sudo apt install nginx -y
image 70

Start the Nginx web service using systemctl command-line tool.

sudo systemctl start nginx

Enable the Nginx web service to start automatically at boot time.

sudo systemctl enable nginx

After installation, check the status of the Nginx service to ensure it’s running.

sudo systemctl status nginx
image 71

Open a web browser and access the nginx using http://<EC2-PUBLIC-IP>. You should see the default NGINX welcome page.

image 72

Step #3:Install MariaDB (Database Server) on Ubuntu 24.04 LTS

MariaDB is an open-source relational database management system that will store your WordPress data.

Install MariaDB server with apt package manager.

sudo apt install mariadb-server 
image 73

Start the MariaDB service using systemctl command-line tool.

sudo systemctl start mariadb

Enable the MariaDB service with the following commands.

sudo systemctl enable mariadb

View the MariaDB service is running by checking its status.

sudo systemctl status mariadb
image 74

Step #4:Create a WordPress Database & User on Ubuntu 24.04 LTS

Now that MariaDB is installed, we need to create a database and a user for WordPress.

1. Log in to the MariaDB Shell:

sudo mariadb -u root 
image 75

2. Create a Database for WordPress:

 CREATE DATABASE wordpress;

3. Create a User for WordPress:

CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'YourStrongPassword';

Replace YourStrongPassword with a strong password:

4. Grant Permissions to the User:

GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';

5.Flush privileges to reload the privilege tables in the database :

 FLUSH PRIVILEGES;

6. Exit MariaDB:

Exit;
image 76

Step #5:Install PHP 8.3 & Required Extensions on Ubuntu 24.04 LTS

WordPress requires PHP to function properly.

We’ll install PHP 8.3 along with the necessary extensions.

sudo apt install php php-cli php-common php-imap php-fpm php-snmp php-xml php-zip php-mbstring php-curl php-mysqli php-gd php-intl
image 77

Verify PHP Installation:

php -v
image 78

Step #6:Download and Install WordPress on Ubuntu 24.04 LTS

Let’s download and configure WordPress.

1.Navigate to the Web Directory:

cd /var/www/html/
Screenshot 2025 03 17 170150

2. Download the Latest WordPress Version:

sudo wget https://wordpress.org/latest.tar.gz
Screenshot 2025 03 17 170226

3. Extract the Downloaded WordPress Package

sudo tar -xvzf latest.tar.gz
image 79

4.Remove the Downloaded Archive to Save Space:

sudo rm latest.tar.gz
image 80

5.Change Ownership of WordPress Files

sudo chown -R www-data:www-data /var/www/html/wordpress
Screenshot 2025 03 17 170609

6.Set Proper File Permissions

sudo chmod -R 755 /var/www/html/wordpress
image 81

Step #7:Configure Nginx for WordPress on Ubuntu 24.04 LTS.

Create a new Nginx configuration file:

sudo nano /etc/nginx/sites-available/wordpress.conf
image 84

Paste the following content (replace your_server_ip with your actual IP address):

server {
listen 80;
server_name your_server_ip;

root /var/www/html/wordpress;
index index.php index.html;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Screenshot 2025 03 17 170940

Save and exit (CTRL + X, then Y, then ENTER).

Enable the WordPress Configuration in Nginx

sudo ln -s /etc/nginx/sites-available/wordpress.conf /etc/nginx/sites-enabled/
Screenshot 2025 03 17 171348

Remove the Default Nginx Configuration

sudo rm /etc/nginx/sites-enabled/default
image 89

Test the Nginx configuration:

sudo nginx -t
image 90

Restart Nginx

sudo systemctl restart nginx
image 91

Step #8:Configure WordPress to connect with database

Now that WordPress files are in place, we need to configure WordPress to connect to the database.

1. Create the wp-config.php File

WordPress provides a sample configuration file (wp-config-sample.php). We need to copy it and rename it to wp-config.php:

sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
image 92

2. Edit wp-config.php file

Next, we edit the wp-config.php file to update the database details:

sudo nano /var/www/html/wordpress/wp-config.php
image 94

Locate the following lines and update them with your database credentials:

define('DB_NAME', 'your_database');     
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');
  • DB_NAME → The database name you created in MariaDB.
  • DB_USER → The username created for the database.
  • DB_PASSWORD → The password for that database user.
  • DB_HOST → Leave as localhost if MariaDB is running on the same server.
image 95

Save and exit (CTRL + X, then Y, then ENTER).

Step #9:Complete WordPress Installation in Browser

Now that WordPress is configured, we can complete the installation through the web browser.

Open Your Browser And Go to your server’s IP address

http://EC2 _public_ip_addr

You will see the WordPress setup page. Choose your preferred language and click Continue.

image 96

Enter Site Information

Fill in the required details:

  • Site Title – Enter a name for your website.
  • Username – Create a login username for WordPress.
  • Password – Set a strong password for your WordPress admin account.
  • Your Email – Enter an email address for password recovery and notifications.

Click Install WordPress to proceed.

image 97

Once the installation is complete, click Log In.

Screenshot 2025 03 17 172954

Enter the username and password you created and click on Log In button.

Screenshot 2025 03 17 173033

After logging in, you will be redirected to the WordPress dashboard, where you can manage your website, install themes, add plugins, and customize settings.

Screenshot 2025 03 17 173054

Conclusion:

We have successfully installed WordPress on Ubuntu 24.04 using Nginx, MariaDB, and PHP 8.3. We covered setting up the necessary packages, configuring the database, downloading WordPress, and setting up Nginx as a web server. After completing the installation, you can now access the WordPress dashboard to start building and customizing your website.

Related Articles:

Setup Job Board in WordPress using WP Job Manager Plugin

Reference:

Install WordPress on Ubuntu official page






About DevOps Hint

DevOps Hint Founded in 2020 Community Site where you can find about How to Guides, Articles and Troubleshooting Tips for DevOps, SRE, Sysadmins and Developers.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.