How to Install WordPress on Debian 12

Updated on 31 July, 2025
Learn how to install and configure WordPress on Debian 12 using the LEMP stack, SSL, and Nginx virtual hosts.
How to Install WordPress on Debian 12 header image

WordPress is a free, popular open-source content management system (CMS) used to build dynamic websites, blogs, and online stores. It is powered by PHP and uses a MySQL or MariaDB database for content storage. With its intuitive admin dashboard, WordPress allows users to manage posts, pages, themes, plugins, and users without writing any code.

In this article, you'll install WordPress on a Debian 12 server using the LEMP stack (Linux, Nginx, MariaDB, PHP). You'll configure a virtual host, secure your site with HTTPS using Let's Encrypt, and set up WordPress through its web-based installer to access the admin dashboard.

Prerequisites

Before you begin, you need to:

Install a Web Server Stack

WordPress requires a web server stack like LAMP (Linux, Apache, MariaDB, PHP) or LEMP (Linux, Nginx, MariaDB, PHP). This article uses the LEMP stack, but you can follow a different configuration if preferred.

Create a Database for WordPress

WordPress uses a database to store content such as posts, user accounts, settings, and plugin data. You need to create a database and a user account before launching the application.

Follow these steps to create a database using the default MariaDB server installed earlier:

  1. Log in to the database server.

    console
    $ sudo mysql
    
  2. Create a new database for WordPress.

    sql
    MariaDB [(none)]> CREATE DATABASE wordpressdb;
    
  3. Create a new user with a strong password.

    sql
    MariaDB [(none)]> CREATE USER 'wpadmin'@'localhost' IDENTIFIED BY 'StrongPassword';
    

    Replace StrongPassword with your own secure password.

  4. Grant the user full privileges on the WordPress database.

    sql
    MariaDB [(none)]> GRANT ALL ON wordpressdb.* TO 'wpadmin'@'localhost';
    
  5. Apply the permission changes.

    sql
    MariaDB [(none)]> FLUSH PRIVILEGES;
    
  6. Exit the database console.

    sql
    MariaDB [(none)]> EXIT;
    

Download WordPress

You can download the latest WordPress release directly from the official website and extract its contents into a custom webroot directory. This section guides you through setting up the WordPress files for deployment.

  1. Navigate to your user's home directory.

    console
    $ cd ~
    
  2. Download the latest WordPress archive.

    console
    $ wget https://wordpress.org/latest.tar.gz
    
  3. Extract the archive.

    console
    $ tar -xvf latest.tar.gz
    
  4. Confirm that the wordpress directory was extracted.

    console
    $ ls
    

    Output:

    latest.tar.gz  wordpress
  5. Create a new web root directory for your WordPress site.

    console
    $ sudo mkdir -p /var/www/www.example.com
    
  6. Move the WordPress files to the web root directory.

    console
    $ sudo mv wordpress/* /var/www/www.example.com
    
  7. Verify that the files are present.

    console
    $ ls /var/www/www.example.com
    
  8. Set the correct ownership for the web root directory.

    console
    $ sudo chown -R www-data:www-data /var/www/www.example.com
    
  9. Set directory permissions to 755.

    console
    $ sudo find /var/www/www.example.com -type d -exec chmod 755 {} \;
    
  10. Set file permissions to 644.

    console
    $ sudo find /var/www/www.example.com -type f -exec chmod 644 {} \;
    
  11. Confirm the updated permissions.

    console
    $ ls -l /var/www/www.example.com
    

Create a Virtual Host Configuration for WordPress

To serve your WordPress site using Nginx, create a virtual host configuration that defines the domain, webroot, and PHP processing settings.

  1. Navigate to the Nginx virtual host configuration directory.

    console
    $ cd /etc/nginx/sites-available
    
  2. Create a new virtual host file for your domain.

    console
    $ sudo nano www.example.com.conf
    
  3. Add the following configuration to the file.

    ini
    server {
        listen 80;
        server_name www.example.com;
    
        root /var/www/www.example.com;
        index index.php index.html index.htm;
    
        access_log /var/log/nginx/example.com.access.log;
        error_log /var/log/nginx/example.com.error.log;
    
        location / {
            try_files $uri $uri/ /index.php?$args;
        }
    
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php8.2-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        } 
    
        location ~ /\. {
            deny all;
        }
    
        location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
            expires 30d;
            access_log off;
            add_header Cache-Control "public, no-transform";
        }
    }
    

    Replace www.example.com with your actual domain.

    This configuration:

    • Listens on port 80 and handles requests for www.example.com.
    • Serves files from /var/www/www.example.com.
    • Forwards .php requests to the PHP-FPM socket for processing.
    • Denies access to hidden files.
    • Enables basic caching for static assets.

    Save and close the file.

  4. Enable the virtual host by creating a symbolic link.

    console
    $ sudo ln -s /etc/nginx/sites-available/www.example.com.conf /etc/nginx/sites-enabled/
    
  5. Remove the default Nginx configuration to avoid conflicts.

    console
    $ sudo rm /etc/nginx/sites-enabled/default
    
  6. Test the Nginx configuration for syntax errors.

    console
    $ sudo nginx -t
    

    Output:

    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

    If errors occur, review the configuration file and fix any issues.

  7. Reload Nginx to apply the changes.

    console
    $ sudo systemctl restart nginx
    

Secure WordPress with Trusted SSL Certificates

By default, the Nginx virtual host configuration for WordPress listens on port 80 (HTTP), which is unencrypted and insecure. To enable secure HTTPS access, generate SSL certificates using Let's Encrypt and configure Nginx to handle encrypted traffic.

  1. Update the APT package index.

    console
    $ sudo apt update
    
  2. Install Certbot and its Nginx plugin.

    console
    $ sudo apt install certbot python3-certbot-nginx -y
    
  3. Generate and install a free SSL certificate for your domain.

    console
    $ sudo certbot --nginx -d www.example.com -m wpadmin@example.com --agree-tos
    

    Replace wpadmin@example.com with your email address.

    Certbot will automatically update your Nginx configuration and reload the service.

  4. Test the automatic renewal process.

    console
    $ sudo certbot renew --dry-run
    
  5. Allow HTTPS traffic through the firewall.

    console
    $ sudo ufw allow https
    
  6. Reload UFW to apply the rule changes.

    console
    $ sudo ufw reload
    

Configure WordPress

Use the web interface to configure WordPress, connect the database, and create your admin account.

  1. Visit your domain in a web browser to launch the WordPress setup wizard.

    https://www.example.com

    WordPress Setup Page

  2. Click Let's Go.

  3. Enter the database name, username, and password you created earlier.

    Enter WordPress database details

  4. Click Run the Installation to initialize the WordPress database.

  5. Enter your site title, admin username, password, and email.

    Setup the WordPress site details

  6. Optionally enable Search Engine Visibility to discourage your site from indexing.

  7. Click Install WordPress.

  8. After installation, click Login to access the WordPress admin dashboard.

Access and Use WordPress

After installing WordPress, follow these steps to log in and begin managing your website.

  1. Open the WordPress login page by visiting your domain with the /wp-admin path.

    https://www.example.com/wp-admin
  2. Log in using your administrator credentials. The WordPress dashboard should load correctly, allowing you to manage themes, plugins, users, and other settings.

    WordPress Backend Dashboard

  3. Navigate to Users to add new users and assign roles.

  4. Click Appearance > Themes to install or activate themes.

  5. Click Plugins to add, remove, or configure WordPress plugins.

  6. Click Pages to manage site content and layout.

  7. Click Posts to view and edit blog entries.

    Manage Posts

  8. Click Add Post to create a new blog post.

  9. Set the post title as Hello World! Greetings from Vultr, and enter WordPress is installed in the content block.

  10. Click Publish to make the post live.

  11. Click View Post to confirm it appears correctly on your site.

    Published Post on a WordPress Site

Conclusion

In this article, you installed and configured WordPress on a Debian 12 server using a LEMP stack. You learned how to create a database, configure Nginx, secure the installation with SSL, and complete the WordPress setup via the web interface. WordPress enables you to build dynamic websites, from blogs and forums to online stores. For better scalability and performance, consider integrating a CDN, caching plugins, and security best practices. For advanced customization and management tips, refer to the official WordPress documentation.

Comments

No comments yet.