WordPress

How to install WordPress on Ubuntu 24.04 LTS with Apache, MySQL, PHP 8.3 and Let’s Encrypt

WordPress is one of the most widely used content management systems (CMS) on the Internet. In this guide we will install it from scratch on an Ubuntu Server 24.04 LTS VPS using Apache, MySQL, PHP 8.3, and free Let’s Encrypt HTTPS certificates.

October 2026 update: the original version of this article was based on Ubuntu 20.04 and used a third-party PPA to install PHP 8.2. The procedure has now been completely updated for Ubuntu 24.04 LTS, and screenshots and steps that no longer match the current process have been removed.

Requirements

WordPress currently recommends PHP 8.3 or later, MySQL 8.0 or later —or MariaDB 10.11 or later— and HTTPS. Ubuntu 24.04 provides PHP 8.3 and MySQL 8.0 from its official repositories, so no third-party PHP repository is required.

  • A VPS or server running Ubuntu Server 24.04 LTS.
  • An SSH user with sudo privileges.
  • A domain or subdomain pointing to the server’s public IP address.
  • Ports 80/TCP and 443/TCP reachable from the Internet.
  • At least 1–2 GB RAM for a small site; WooCommerce, many plugins, or heavier traffic may require more.

1. Update Ubuntu 24.04

Connect over SSH and update the system first:

sudo apt update
sudo apt full-upgrade

If the kernel or other fundamental components were upgraded, reboot before continuing:

sudo reboot

After reconnecting, verify the installed release:

lsb_release -a

Configure UFW

If you use UFW, allow SSH before enabling it so you do not lock yourself out. Then allow Apache’s full profile:

sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status

If your VPS provider also uses an external firewall or security group, allow TCP ports 80 and 443 there as well.

2. Install MySQL 8.0

Ubuntu 24.04 provides MySQL 8.0 in its official repositories:

sudo apt install mysql-server
sudo systemctl enable --now mysql
sudo systemctl status mysql --no-pager

Ubuntu normally configures the local MySQL administrative account with auth_socket authentication, so you can enter the administrative shell with:

sudo mysql

Create the WordPress database and user

Inside MySQL, create a dedicated database and user. Replace the sample password with a long, unique password:

CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'A-Very-Long-Unique-Password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Do not use the MySQL root account in WordPress. The dedicated wordpress account only needs privileges on its own database.

3. Install Apache 2

sudo apt install apache2
sudo systemctl enable --now apache2
sudo systemctl status apache2 --no-pager

Browsing temporarily to the server’s public IP over HTTP should display Apache’s default page:

Enable the rewrite module used by WordPress permalink rules:

sudo a2enmod rewrite
sudo systemctl reload apache2

4. Install PHP 8.3

Do not add the old ppa:ondrej/php repository. Ubuntu 24.04 already ships PHP 8.3, which meets the current WordPress recommendation.

Install PHP, the Apache module, and common WordPress extensions:

sudo apt install php libapache2-mod-php php-cli php-mysql php-curl php-gd php-mbstring php-xml php-zip php-intl php-imagick php-opcache php-bcmath curl

Check the version and key modules:

php -v
php -m | grep -E 'bcmath|curl|dom|exif|fileinfo|gd|imagick|intl|mbstring|mysqli|openssl|xml|zip|Zend OPcache'

Tune php.ini

With Apache and libapache2-mod-php, the main configuration file is /etc/php/8.3/apache2/php.ini:

sudo nano /etc/php/8.3/apache2/php.ini

For a general site, these are reasonable initial limits and can be adjusted later based on actual workload:

memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 120
max_input_time = 120
sudo apache2ctl configtest
sudo systemctl restart apache2

For busier servers, PHP-FPM with Apache’s event MPM may be preferable, but the Apache PHP module keeps this introductory installation simpler.

5. Create the Apache VirtualHost

Use a dedicated directory for the site. Replace example.com with your real domain:

sudo mkdir -p /var/www/example.com/public_html
sudo nano /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com

    DocumentRoot /var/www/example.com/public_html

    <Directory /var/www/example.com/public_html>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>

Enable the site and validate Apache before reloading it:

sudo a2ensite example.com.conf
sudo apache2ctl configtest
sudo systemctl reload apache2

If this is the only site on the VPS, you can disable the default VirtualHost:

sudo a2dissite 000-default.conf
sudo systemctl reload apache2

6. Download and install WordPress

Download the current stable release directly from WordPress.org. The setup wizard lets you choose the language, so separate language-specific archives are not required:

cd /tmp
curl -LO https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
sudo cp -a wordpress/. /var/www/example.com/public_html/

For this simple single-site setup, assign the files to www-data so WordPress can update from the administration panel:

sudo chown -R www-data:www-data /var/www/example.com/public_html
sudo find /var/www/example.com/public_html -type d -exec chmod 755 {} \;
sudo find /var/www/example.com/public_html -type f -exec chmod 644 {} \;

On multi-user servers or stricter security models, separate the deployment owner from the web-server user and use more granular permissions.

7. Verify DNS

Before requesting the HTTPS certificate, the domain must resolve to the VPS:

sudo apt install dnsutils
dig +short example.com
dig +short www.example.com

If an AAAA record exists, make sure it points to IPv6 that is actually configured on the server. A broken AAAA record can cause Let’s Encrypt validation to fail.

8. Enable HTTPS with Let’s Encrypt

For a current installation, use Certbot through Snap, following the method recommended by the Certbot project.

If the server has an older APT-based Certbot installation, remove it first. If those packages are not installed, APT will simply report that:

sudo apt remove certbot python3-certbot-apache
sudo apt install snapd
sudo snap install --classic certbot
sudo ln -sf /snap/bin/certbot /usr/local/bin/certbot

Request the certificate and let Certbot configure Apache automatically:

sudo certbot --apache -d example.com -d www.example.com

Test the renewal mechanism:

sudo certbot renew --dry-run

Do not recreate the old manual cron job from the original article. Current Certbot installations configure automatic renewal themselves.

9. Complete the WordPress setup wizard

Open https://example.com/. WordPress should display its web installer. The following screenshots are still useful for recognizing the setup, login, and administration screens:

When the installer asks for database access, use:

  • Database: wordpress.
  • User: wordpress.
  • Password: the password created earlier.
  • Host: localhost.
  • Table prefix: keeping wp_ is acceptable; changing it is not a substitute for other security measures.

Avoid predictable administrator usernames such as admin, use a unique password, and enable two-factor authentication once the site is operational.

10. Protect wp-config.php

After WordPress creates its configuration file, restrict its permissions:

sudo chmod 600 /var/www/example.com/public_html/wp-config.php

With the ownership model used in this guide, Apache can still read it because the file belongs to www-data. If you later change owners or groups, make sure PHP retains read access.

11. Final checks

systemctl status apache2 --no-pager
systemctl status mysql --no-pager
php -v
mysql --version
apache2ctl -v
sudo apache2ctl configtest
sudo certbot certificates

Inside WordPress, open Tools → Site Health and check HTTPS, REST API access, scheduled events, and PHP extensions.

Basic production practices

  • Keep Ubuntu, WordPress core, plugins, and themes updated.
  • Remove plugins and themes you do not use.
  • Do not expose MySQL to the Internet when the database runs on the same VPS.
  • Back up both files and the database, and periodically test restoration.
  • Use unique passwords and 2FA for administrative accounts.
  • For busier sites, consider PHP-FPM, page caching, object caching, and a CDN rather than simply raising PHP memory and time limits.

Official sources

Conclusion

Ubuntu Server 24.04 LTS provides everything needed for a modern WordPress installation directly from its official repositories: Apache, MySQL 8.0, and PHP 8.3. This removes several steps required by the old guide and reduces reliance on third-party repositories. With HTTPS, tested backups, and regular updates, this is a solid baseline for a self-managed WordPress VPS.

Yirenia HQ

Entradas recientes

PHP in 2026: The Complete PHP 8.5 Guide to Modern Web Development

Learn PHP 8.5 from scratch: syntax, databases, Composer, PSR, Laravel, Symfony, modern runtimes, APIs, security,…

1 week hace

How to Install VirtualBox Guest Additions 7.2.20 on Linux

Step-by-step guide to installing VirtualBox Guest Additions 7.2.20 on Linux: kernel headers, modules, Secure Boot,…

1 week hace

Kali Linux 2026: What It Is, What It Is Used For, and How to Learn

An introduction to Kali Linux 2026.2: authorized security testing, rolling updates, APT changes, virtual machines,…

1 week hace

Software Test Automation Tools: How to Choose the Right Framework

A practical guide to software test automation: unit, integration, API, contracts, Selenium, Playwright, Cypress, Appium,…

1 week hace

Computer networking from scratch: roadmap for future sysadmins

A complete networking roadmap for future sysadmins: Ethernet, IPv4/IPv6, subnetting, VLANs, routing, DNS, DHCP, Linux,…

2 years hace

The United Airlines reservation system designed by Evelyn Berezin

History and architecture of Evelyn Berezin’s United Airlines reservation system, distinguishing it from the earlier…

2 years hace