Skip to content

Web serverFor advanced usersDuration around 30 min.

How to install WordPress on your own server: Nginx, PHP and MariaDB

This tutorial brings WordPress to your own server with Ubuntu: Nginx as the web server, PHP-FPM for WordPress, MariaDB as the database and a certificate from Let’s Encrypt. Finally, you will complete the setup in the browser, where you create the title and administrator.

Tested on with Ubuntu 24.04 LTS and Ubuntu 26.04 LTS

At a glance

  • Ubuntu 24.04 LTS comes with PHP 8.3 and MariaDB 10.11, Ubuntu 26.04 LTS with PHP 8.5 and MariaDB 11.8 — both meet the WordPress recommendation.
  • WordPress gets its own database and its own database user, who is only allowed to manage this single database.
  • Nginx communicates with PHP via a socket named after the PHP version: php8.3-fpm.sock on 24.04, php8.5-fpm.sock on 26.04.

Prerequisites

  • A server with Ubuntu 24.04 LTS or 26.04 LTS and a user with sudo privileges, such as a VPS. For a website with typical traffic, 2 GB memory is sufficient.
  • A domain with an A and AAAA record pointing to the server's address. In the examples, it is called blog.example.com.

There are two quicker ways: in the VPS configurator, WordPress with OpenLiteSpeed is available as a ready-to-use application, and with web hosting, we take care of the server. This tutorial is for everyone who wants to set up every layer themselves.

Step 1: install Nginx, MariaDB and PHP

In addition to PHP-FPM and the MariaDB driver, you install the PHP extensions that WordPress needs for images, languages, updates and archives. The services start automatically after installation.

Install packages
sudo apt update
sudo apt install -y nginx mariadb-server php-fpm php-mysql php-curl php-gd php-intl php-mbstring php-xml php-zip
Check versions
php -v
mariadb --version

Step 2: create database and user

On Ubuntu, root logs into MariaDB via the system account, without its own password. Open the database console:

Open MariaDB console
sudo mariadb

Enter the following lines there. Replace the password with a long, random one — you will need it again in step 6.

In the MariaDB console
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'replace-with-a-long-password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';
FLUSH PRIVILEGES;
EXIT;

utf8mb4 stores every character, including emojis. The user wordpress is only allowed to manage the database of the same name and can only log in from the server itself.

Step 3: download WordPress

Download the latest version directly from wordpress.org, extract it to /var/www/wordpress and hand over the folder to the user www-data under which PHP runs. This allows WordPress to write its configuration file and later install extensions and updates itself.

Download and set up
cd /tmp
curl -LO https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
sudo mv wordpress /var/www/wordpress
sudo chown -R www-data:www-data /var/www/wordpress

Step 4: set up Nginx for WordPress

First, check the name of the PHP socket:

Find PHP socket
ls /run/php/
Output on Ubuntu 24.04
php8.3-fpm.pid
php8.3-fpm.sock

On Ubuntu 26.04, the socket is called php8.5-fpm.sock. Enter the name from your output in line fastcgi_pass:

/etc/nginx/sites-available/wordpress
server {
    listen 80;
    listen [::]:80;
    server_name blog.example.com;
    root /var/www/wordpress;
    index index.php;
 
    client_max_body_size 64m;
 
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
 
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }
 
    location ~ /\.ht {
        deny all;
    }
}

try_files passes any address for which there is no file to WordPress — WordPress needs this for pretty permalinks. client_max_body_size allows uploads up to 64 MB. Then enable the site, disable the Nginx welcome page and check:

Enable site and check
sudo nano /etc/nginx/sites-available/wordpress
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx

Step 5: firewall and HTTPS

Set up HTTPS before you install WordPress — then WordPress will immediately enter the address with https. First the firewall, then the certificate:

Firewall
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
Certificate from Let’s Encrypt
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/local/bin/certbot
sudo certbot --nginx -d blog.example.com

What Certbot asks during this process and how the renewal works is explained in the tutorial Nginx as a reverse proxy, step 6.

Step 6: set up WordPress in the browser

Go to https://blog.example.com. The setup guides you through three pages:

  1. Select language.
  2. Enter database: name wordpress, user wordpress, the password from step 2, database host localhost. WordPress uses this to write the file wp-config.php.
  3. Enter the site title, administrator name and password, and an e-mail address, then “Install WordPress”.

No administrator named admin

Choose a unique name and a long password for the administrator account. Automated login attempts frequently try the name “admin”.

Typical errors

  • 502 Bad Gateway: The socket in fastcgi_pass does not match your PHP version. Compare it with the output of ls /run/php/.
  • “Error establishing a database connection”: The database name, user or password do not match step 2.
  • “Sorry, but I can’t write the wp-config.php file”: The folder does not belong to www-data. Repeat the last command from step 3.
  • File exceeds upload_max_filesize: By default, PHP only accepts 2 MB per file. Set the two values in /etc/php/8.3/fpm/php.ini (on 26.04 8.5) and restart PHP-FPM.
/etc/php/8.3/fpm/php.ini (Ausschnitt)
upload_max_filesize = 64M
post_max_size = 64M
Restart PHP-FPM service
sudo systemctl restart php8.3-fpm

We tested all commands in this guide on 2 December 2026 — with Ubuntu 24.04 LTS and Ubuntu 26.04 LTS. If a step changes at the manufacturer, we update it here along with the date.

Official documentation

Frequently asked questions about WordPress on your own server

Which PHP and database version does WordPress need?

WordPress recommends PHP 8.3 or higher, MariaDB 10.11 or higher, or MySQL 8.4 or higher, and HTTPS. Ubuntu 24.04 LTS comes with PHP 8.3 and MariaDB 10.11, Ubuntu 26.04 LTS with PHP 8.5 and MariaDB 11.8.

Nginx or Apache for WordPress?

WordPress lists both as recommended web servers. For pretty permalinks, Nginx requires the try_files line instead of an .htaccess file; Apache reads .htaccess rules from plugins directly.

Why does the WordPress folder belong to the www-data user?

PHP-FPM runs under www-data. If the folder belongs to this user, WordPress can create its configuration file and install updates, themes and plugins itself.

How do I keep WordPress up to date?

WordPress installs minor maintenance and security releases itself in the background; you update major versions, themes and plugins in the dashboard. You update the underlying system with apt.

Why does the PHP socket have a different name in 26.04?

The name contains the PHP version: Ubuntu 24.04 LTS provides PHP 8.3, Ubuntu 26.04 LTS PHP 8.5. A socket without a version number was missing in both systems, which is why the full name is in the server block.

Further reading

More tutorials

A server for WordPress

A VPS runs Nginx, PHP and MariaDB for a WordPress website; if you do not want to manage the server, choose web hosting.