Install WordPress with Nginx on Debian 13 with SSL

Debian is known for its stability and lightweight setup. This is the reason why many people prefer using it on their servers. In this tutorial, I will guide you through installing WordPress with Nginx on Debian 13 Trixie.

We will install and setup Nginx, MariaDB, PHP8.5 and Let’s Encrypt SSL for WordPress where Nginx will be our web server, Mariadb will be the database server and Let’s Encrypt SSL will allow users to securly access our WordPress website. If you have Rocky Linux on your server, you can check out my tutorial to install WordPress with Nginx on Rocky Linux 10.

So without talking much, let’s begin

Prerequisite

  • A server with Debian 13 trixie installed
  • A user with sudo privileges

Step 1 – Updating the system

The first step is to update our server to the latest

sudo apt update -y
sudo apt upgrade -y

Step 2 – Installing and Securing MariaDB

Now let’s install and set up MariaDB, which will store all the data for our WordPress website.

sudo apt install mariadb-server -y

Now lets secure it

sudo mariadb-secure-installation
Enter current password for root (enter for none): (Just hit enter key)
Switch to unix_socket authentication [Y/n]: (Press N and hit enter key)
Change the root password? [Y/n]: (Press Y and hit enter key)
Enter New Password:
Confirm New Password: 
Note:- Make sure to enter a strong and memorable password here

Remove anonymous users? [Y/n]: (Press Y and hit enter key)
Disallow root login remotely? [Y/n]: (Press Y and hit enter key)
Remove test database and access? [Y/n]: (Press Y and hit enter key)
Reload privilege tables now? [Y/n]: (Press Y and hit enter key)

Step 3 – Create Database

Now let’s create database and its user

sudo mysql -u root -p

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Note:- Make sure to change the given below as per your need

wordpress” – This is the name of your WordPress database. You can change it as per your wish
wordpressuser” – This is the user name of your database user who will have access to your database. You can change it as per your wish
password” – This is database’s password. Change it to something stronger

Step 4 – Installing Nginx

Now lets install Nginx which is our web server

sudo apt install nginx -y

Step 5 – Installing PHP 8.5

Now lets install PHP 8.5 on our setup. Although i have already published a tutorial to install php 8.5 on Debian 13 Trixie here.

Lets first add the Ondřej Surý’s Repository for PHP

sudo apt install curl -y
sudo apt install ca-certificates gnupg lsb-release -y
curl -fsSL https://packages.sury.org/php/apt.gpg -o /usr/share/keyrings/sury-php.gpg

echo "deb [signed-by=/usr/share/keyrings/sury-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Now lets install PHP 8.5

sudo apt update -y
sudo apt install php8.5-fpm php8.5-mysql php8.5-mysqlnd php8.5-bcmath php8.5-xml php8.5-intl php8.5-curl php8.5-gd php8.5-imagick php8.5-mbstring php8.5-zip -y

Now lets check the PHP version

php8.5-fpm -v

Step 6 – Configuring Nginx

Now lets configure Nginx to use our setup. For this lets first create our nginx configuration file using

sudo nano /etc/nginx/sites-available/your_domain
Note: Make sure to change "your_domain" to your real domain name.

Now copy and paste this

server {
    listen 80;
    listen [::]:80;

    root /var/www/html/your_domain;
    index index.php index.html index.htm;

    server_name your_domain www.your_domain;

    location / {
	try_files $uri $uri/ /index.php$is_args$args;
    }
    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png|svg|webp|avif|woff|woff2)$ {
        expires max;
        log_not_found off;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.5-fpm.sock;
    }
}
Note: Make sure to change "your_domain" to your real domain name.

Now save the file and exit

Now we will have to link the nginx configuration file in sites-enabled and delink the default configuration file

sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled
sudo unlink /etc/nginx/sites-enabled/default

Now lets test our nginx

sudo nginx -t
sudo systemctl reload nginx

Step 7 – Downloading WordPress

Now lets download WordPress

cd /var/www/html
sudo curl -LO https://wordpress.org/latest.tar.gz

Now lets extract it

sudo tar xzvf latest.tar.gz

Step 8 – Configure WordPress

Lets configure WordPress to use our database. First rename the wordpress folder to your_domain

sudo mv wordpress/ your_domain
Note: Make sure to change "your_domain" to your real domain name.

Now lets setup WordPress configuration file

cd /var/www/html/your_domain
sudo cp wp-config-sample.php wp-config.php

sudo nano wp-config.php

Fill the database details that your have entered in step 3 in the given below field

define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password');

...

define('FS_METHOD', 'direct');

Save the file and exit

Step 9 – Assigning permission

Now lets assign the correct permission to the folder that contains WordPress files

sudo chown -R www-data:www-data /var/www/html/your_domain
Note: Make sure to change "your_domain" to your real domain name.

Step 10 – Configuring Firewall

A firewall helps protect your server by controlling incoming network connections. Let’s configure UFW to allow SSH and HTTP/HTTPS traffic.

sudo apt install ufw -y
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw reload

Step 11 – Install Let’s Encrypt SSL

Lets secure our setup using Let’s Encrypt SSL. To add more securiy you can change SSH port or configure Fail2ban.

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d your_domain -d www.your_domain
Note: Make sure to change "your_domain" to your real domain name.

Let’s Encrypt SSL will be renewd automatically, but if you want you can check by executing this

sudo certbot renew --dry-run

Step 12 – Finalize the setup

Now open any browser and enter your_domain and finalize the setup.

Conclusion

With this, we have successfully installed WordPress with Nginx on Debain 13 with Let’s Encrypt SSL.

Frequently asked questions

Is Nginx better than Apache for WordPress?

Nginx is an excellent choice for WordPress, especially on VPS servers. It is lightweight, efficient, and can handle a large number of concurrent connections with relatively low resource usage.

Do I need a separate SSL certificate for WordPress?

Yes, your website should use an SSL/TLS certificate so visitors can access it securely over HTTPS. You can obtain a free certificate from Let’s Encrypt and configure it with Nginx.

Can I install WordPress on Debian without a control panel?

Yes. WordPress can be installed completely from the command line without using a hosting control panel. This gives you greater control over Nginx, PHP, MariaDB, SSL, and server configuration.

Can I host multiple WordPress websites on the same Nginx server?

Yes. Nginx supports multiple websites on the same server using separate server blocks. Each WordPress installation can have its own domain, document root, database, and SSL configuration.

Leave a Comment

Sourabh Verma

Hi, I'm Sourabh Verma, an IT professional with 12+ years of experience. At BeginnersBox, I share practical, well-tested how-to guides on Windows, Linux, WordPress, web hosting, and other tech topics. My goal is to provide simple, reliable solutions that actually work. Hope you like my work. Thanks

Discover more from BeginnersBox

Subscribe now to keep reading and get access to the full archive.

Continue reading