Website Vidya
Linux & ServersStep-by-Step Guide

How to Install WordPress on Ubuntu 24.04

Complete guide on how to install WordPress on Ubuntu 24.04 LTS with Apache, MariaDB, PHP 8.3, and free Let's Encrypt SSL certificates.

RR
Rajesh RayLead Systems Educator
Published:
6 min read
PDF Cheat Sheet
How to Install WordPress on Ubuntu 24.04
AI Executive SummaryWebsiteVidya AI

6 min read

Complete guide on how to install WordPress on Ubuntu 24.04 LTS with Apache, MariaDB, PHP 8.3, and free Let's Encrypt SSL certificates.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Installing the Apache Web Server and MariaDB Database
  • Step 2: Installing PHP 8.3 and Required WordPress Extensions
Grounded in full engineering runbookWebsiteVidya AI Engine

WordPress is the most popular Content Management System (CMS) in the world, powering over 40% of all websites on the internet. From personal tech blogs and corporate portals to enterprise news organizations and high-volume WooCommerce storefronts, WordPress provides an unmatched ecosystem of open-source plugins, responsive themes, and visual page-building tools.

While managed WordPress hosting services are widely available, deploying WordPress on your own unmanaged Ubuntu server delivers superior performance, total database control, customizable PHP caching engines (such as Redis and OPcache), and significant long-term hosting cost reductions. Learning how to install wordpress on ubuntu 24.04 allows you to launch high-performance web applications on enterprise-grade Linux infrastructure.

In this step-by-step tutorial, we demonstrate how to install WordPress on Ubuntu 24.04 LTS (Noble Numbat) using the production-hardened LAMP stack (Linux, Apache, MariaDB, and PHP 8.3). We cover database provisioning, security hardening, Apache Virtual Host creation with URL rewrites, automated Let's Encrypt SSL configuration with Certbot, and initial dashboard setup.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A virtual private server (VPS) or cloud instance running Ubuntu 24.04 LTS.
  • A non-root user with administrative sudo privileges.
  • A registered domain name (e.g., example.com) pointed to your server's public IP address.
  • Inbound traffic on ports 80 (HTTP) and 443 (HTTPS) allowed through your firewall.

Step 1: Installing the Apache Web Server and MariaDB Database

WordPress requires a web server and a relational database backend. In this tutorial, we configure the Apache HTTP server and MariaDB.

Update your local APT repository index and install apache2, mariadb-server, and standard file retrieval tools.

Advertisement

Verify that both services start successfully and are set to launch at system boot.

# Update package index and apply system upgrades
sudo apt update && sudo apt upgrade -y

# Install Apache web server and MariaDB database server
sudo apt install -y apache2 mariadb-server mariadb-client curl wget unzip

# Enable and verify services
sudo systemctl enable --now apache2 mariadb
sudo systemctl status apache2 mariadb --no-pager

Step 2: Installing PHP 8.3 and Required WordPress Extensions

WordPress is built on PHP and requires several PHP extensions to generate thumbnails, communicate with databases, process HTTP requests, and handle ZIP archives.

Ubuntu 24.04 includes PHP 8.3 in its main repositories. Install PHP along with the required modules: libapache2-mod-php, php-mysql, php-curl, php-gd, php-intl, php-mbstring, php-xml, php-zip, and php-imagick.

Restart the Apache web server so it loads the new PHP processing modules.

Advertisement
# Install PHP 8.3 and required extensions
sudo apt install -y php libapache2-mod-php php-mysql php-curl php-gd php-intl php-mbstring php-xml php-zip php-imagick php-opcache

# Restart Apache
sudo systemctl restart apache2

Step 3: Creating the WordPress Database and Dedicated User

WordPress stores all posts, user accounts, comments, and theme options inside a relational database. Set up a dedicated database and unprivileged database user in MariaDB.

Log into the MariaDB root prompt.

Create a database named wordpress_db with utf8mb4 encoding, create user wordpress_user, grant full privileges on the database, and flush privileges.

Ensure you replace StrongWordPressPass123! with a randomized, secure password.

-- Access MariaDB root shell
sudo mariadb

-- Create WordPress database with full Unicode support
CREATE DATABASE wordpress_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- Create dedicated database user
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'StrongWordPressPass123!';

-- Grant privileges to the database
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';

-- Flush privileges and exit
FLUSH PRIVILEGES;
EXIT;

Step 4: Downloading and Extracting WordPress

Download the latest stable release archive of WordPress directly from WordPress.org into your temporary folder.

Extract the archive into your document root at /var/www/wordpress.

WordPress distributes clean, ready-to-run files directly within the extracted wordpress folder.

# Navigate to /tmp and download latest WordPress tarball
cd /tmp
wget https://wordpress.org/latest.tar.gz

# Extract into /var/www/
sudo tar -xzf latest.tar.gz -C /var/www/

# Clean up archive
rm -f latest.tar.gz

Step 5: Configuring File Permissions and Security Salts

To allow WordPress to automatically install plugins, update core files, and handle media uploads, assign ownership of the files to the www-data web server user.

Set directory permissions to 0755 and file permissions to 0644.

Create the initial wp-config.php file from the sample, and inject secure cryptographic authentication keys and salts generated from the official WordPress salt generator.

# Assign web server ownership
sudo chown -R www-data:www-data /var/www/wordpress

# Apply secure standard permissions
sudo find /var/www/wordpress/ -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 644 {} \;

# Create wp-config.php from template
sudo cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php
sudo chown www-data:www-data /var/www/wordpress/wp-config.php

Step 6: Configuring Apache Virtual Host and URL Rewriting

Create a dedicated Apache Virtual Host configuration file for your website domain to support SEO-friendly permalinks.

Create /etc/apache2/sites-available/wordpress.conf and specify the document root, domain name, and directory overrides.

Enable the Apache rewrite module, activate the WordPress site configuration, and reload Apache.

# Create Apache Virtual Host configuration
sudo bash -c 'cat <<EOF > /etc/apache2/sites-available/wordpress.conf
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/wordpress
    ServerName example.com
    ServerAlias www.example.com

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

    ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
    CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined
</VirtualHost>
EOF'

# Enable rewrite module and activate configuration
sudo a2enmod rewrite headers
sudo a2ensite wordpress.conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2

Step 7: Securing WordPress with Let's Encrypt SSL

Encrypting user login sessions, administrative cookies, and visitor data with SSL/TLS is critical for security and search engine ranking.

Install Certbot and the Apache plugin, then issue a free Let's Encrypt SSL certificate for your domain.

Certbot will automatically configure HTTPS redirects and renew certificates via systemd timers.

# Install Certbot and Apache plugin
sudo apt install -y certbot python3-certbot-apache

# Obtain and apply SSL certificate
sudo certbot --apache -d example.com -d www.example.com

Step 8: Completing the Web Installation Wizard

Open your web browser and navigate to your domain: https://example.com.

Select your language and click Continue.

Enter your database connection details (Database Name: wordpress_db, Username: wordpress_user, Password: StrongWordPressPass123!, Database Host: localhost).

Set your Site Title, create your administrative username, password, and email address, and click Install WordPress.

Log into your brand-new WordPress dashboard at https://example.com/wp-admin.

Database Name: wordpress_db
User Name: wordpress_user
Password: <secure_password>
Database Host: localhost
Table Prefix: wp_

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

Error establishing a database connection

Resolution: Confirm that MariaDB is running with sudo systemctl status mariadb. Test the database user credentials manually from the terminal: mariadb -u wordpress_user -p wordpress_db.

WordPress asks for FTP credentials when installing plugins

Resolution: This indicates that the web server user does not own the WordPress files. Resolve this by executing sudo chown -R www-data:www-data /var/www/wordpress.

Resolution: Ensure mod_rewrite is enabled with sudo a2enmod rewrite and verify that AllowOverride All is set inside /etc/apache2/sites-available/wordpress.conf.

Security Best Practices and Hardening

Never use 'admin' as your WordPress administrator username. Use a unique identifier and enforce strong, randomly generated passwords.

Disable XML-RPC in .htaccess if you do not use mobile publishing apps to prevent automated brute-force amplification attacks.

Disable file editing from the dashboard by adding define('DISALLOW_FILE_EDIT', true); to /var/www/wordpress/wp-config.php.

Keep WordPress core, plugins, and themes continuously updated and maintain regular automated database backups using mysqldump.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

3 FAQs
Yes! WordPress runs exceptionally fast on Nginx with PHP-FPM (the LEMP stack). However, Apache with mod_rewrite is widely popular due to its native support for .htaccess configuration files.
You can increase the WordPress memory limit by adding define('WP_MEMORY_LIMIT', '256M'); directly inside your /var/www/wordpress/wp-config.php file.
Backing up requires dumping the database using mysqldump -u wordpress_user -p wordpress_db > backup.sql and creating a tarball archive of the web root at /var/www/wordpress.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout