This page installs WordPress on your own server: Nginx serves the pages, PHP runs WordPress and MariaDB keeps its data. At the end, your site runs on HTTPS with short, readable links. You need a domain name that points to the address of your server, here example.com. The steps were tested on Ubuntu 26.04 LTS with WordPress 7.1, PHP 8.5, MariaDB 11.8 and Nginx; run the commands as root (connect over SSH).
1. Install Nginx, PHP and MariaDB
apt install nginx mariadb-server php-fpm php-mysql php-curl php-gd php-intl php-mbstring php-xml php-zip
More about MariaDB: MariaDB on Your Linux Server: Install, Create a Database and a User.
2. A Database for WordPress
Open mariadb and create a database and a user that only WordPress uses. Choose your own strong password and keep it for step 6:
CREATE DATABASE wordpress; CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'a-strong-password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost'; exit
3. Download WordPress
cd /tmp curl -O https://wordpress.org/latest.tar.gz tar -xzf latest.tar.gz -C /var/www/ rm latest.tar.gz chown -R www-data:www-data /var/www/wordpress
The files of your site are now in /var/www/wordpress. They belong to www-data, the user Nginx and PHP run as, so WordPress can write uploads into them.
4. An Nginx Site for WordPress
Create the file /etc/nginx/sites-available/wordpress, for example with nano, with your domain instead of example.com:
server {
listen 80;
server_name 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/php-fpm.sock;
}
}
try_filespasses every address that is not a file to WordPress; this makes the short links of step 8 work./run/php/php-fpm.sockalways points to the installed PHP version, also after an upgrade of PHP.client_max_body_size 64Mlets Nginx accept uploads up to 64 MB (step 5).
Switch the site on, switch off the default page of Nginx, test the configuration and reload Nginx:
ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/ rm /etc/nginx/sites-enabled/default nginx -t systemctl reload nginx
nginx -t must answer test is successful. If you use the ufw firewall, also open the web ports: ufw allow "Nginx Full".
5. Larger Uploads
PHP accepts only 2 MB per upload by default; WordPress shows Maximum upload file size: 2 MB. Raise it in a file of your own. Check your PHP version with ls /etc/php; on Ubuntu 26.04 it is 8.5 (on Debian 13 it is 8.4, so write 8.4 in both lines):
printf "upload_max_filesize = 64M\npost_max_size = 64M\n" > /etc/php/8.5/fpm/conf.d/99-wordpress.ini systemctl restart php8.5-fpm
After this, WordPress shows Maximum upload file size: 64 MB.
6. Run the Installation in Your Browser
Open http://example.com. WordPress asks for the language and then for the database:
- Database Name and Username:
wordpress; - Password: the password from step 2;
- Database Host:
localhost; Table Prefix: keepwp_.
Click Submit. The answer Successful database connection means that WordPress reaches its database; click Run the installation. Enter the Site Title, a Username for your administrator (better not admin), a strong Password and your e-mail address, and click Install WordPress. After Success!, click Log In: the dashboard of your site opens.
Until you have finished step 6, anyone who opens your domain can run the installation. Do it right after step 4.
7. HTTPS
Get a free certificate with Certbot as described in Website With HTTPS on a Linux Server: Nginx and Let's Encrypt:
apt install certbot python3-certbot-nginx certbot --nginx -d example.com --redirect
Certbot adds the certificate to the WordPress site of step 4 and sends visitors from http:// to https://. Then tell WordPress its new address: in the dashboard, open Settings → General, change WordPress Address (URL) and Site Address (URL) to https://example.com and click Save Changes. WordPress then asks you to log in again, which is normal after this change.
8. Short Links
By default, a post has a link such as example.com/?p=1. Under Settings → Permalinks, choose Post name and click Save Changes. The first post then opens at example.com/hello-world/.
Good to Know
- Back up both parts of your site: the database (Back Up Your MariaDB or MySQL Databases Every Night) and the files in
/var/www/wordpress, above allwp-contentandwp-config.php(Automatic Encrypted Backups of Your Server to Another Server With restic). wp-config.phpholds the database password. Keep it on the server and out of public copies.- Errors of PHP or Nginx:
tail /var/log/nginx/error.logand Find Errors in the Logs of Your Linux Server: journalctl.