---
title: How to Install WordPress on Debian 12
url: https://docs.vultr.com/how-to-install-wordpress-on-debian-12
description: Learn how to install WordPress on Debian 12 with our step-by-step guide. Set up a secure, optimized WordPress site on your Debian server quickly and easily.
publish_date: 2025-07-31T13:38:12.320056Z
last_updated: 2025-07-31T13:49:44.069774Z
author: Davis Clifford Pandya
header_image: https://sjc1.vultrobjects.com/docs-main-doc-assets-1/2272/a5315e42-4915-4211-9eab-b124b79f1121.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

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:

* Have access to a [Debian 12](https://www.vultr.com/servers/debian/) server as a [non-root user with `sudo` privileges](https://docs.vultr.com/limited-user-login).
* Create a [DNS A record](https://docs.vultr.com/products/network/dns/provisioning) pointing to your server's IP address, such as `www.example.com`.

## 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.

* To install the **LEMP stack** on Debian 12, follow the [How to Install Nginx, MySQL, PHP (LEMP Stack) on Debian 12](https://docs.vultr.com/how-to-install-nginx-mysql-php-lemp-stack-on-debian-12) article.

* If you prefer to use the **LAMP stack**, refer to the [How to Install Apache, MySQL, PHP (LAMP Stack) on Debian 12](https://docs.vultr.com/how-to-install-apache-mysql-php-lamp-stack-on-debian-12) article instead.

## 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
    ```

1. Create a new database for WordPress.

    ```sql
    MariaDB [(none)]> CREATE DATABASE wordpressdb;
    ```

1. 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.

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

    ```sql
    MariaDB [(none)]> GRANT ALL ON wordpressdb.* TO 'wpadmin'@'localhost';
    ```

1. Apply the permission changes.

    ```sql
    MariaDB [(none)]> FLUSH PRIVILEGES;
    ```

1. 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 ~
    ```

1. Download the latest WordPress archive.

    ```console
    $ wget https://wordpress.org/latest.tar.gz
    ```

1. Extract the archive.

    ```console
    $ tar -xvf latest.tar.gz
    ```

1. Confirm that the `wordpress` directory was extracted.

    ```console
    $ ls
    ```

    Output:

    ```
    latest.tar.gz  wordpress
    ```

1. Create a new web root directory for your WordPress site.

    ```console
    $ sudo mkdir -p /var/www/www.example.com
    ```

1. Move the WordPress files to the web root directory.

    ```console
    $ sudo mv wordpress/* /var/www/www.example.com
    ```

1. Verify that the files are present.

    ```console
    $ ls /var/www/www.example.com
    ```

1. Set the correct ownership for the web root directory.

    ```console
    $ sudo chown -R www-data:www-data /var/www/www.example.com
    ```

1. Set directory permissions to `755`.

    ```console
    $ sudo find /var/www/www.example.com -type d -exec chmod 755 {} \;
    ```

1. Set file permissions to `644`.

    ```console
    $ sudo find /var/www/www.example.com -type f -exec chmod 644 {} \;
    ```

1. 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
    ```

1. Create a new virtual host file for your domain.

    ```console
    $ sudo nano www.example.com.conf
    ```

1. 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.

1. 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/
    ```

1. Remove the default Nginx configuration to avoid conflicts.

    ```console
    $ sudo rm /etc/nginx/sites-enabled/default
    ```

1. 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.

1. 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
    ```

1. Install Certbot and its Nginx plugin.

    ```console
    $ sudo apt install certbot python3-certbot-nginx -y
    ```

1. 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.

1. Test the automatic renewal process.

    ```console
    $ sudo certbot renew --dry-run
    ```

1. Allow HTTPS traffic through the firewall.

    ```console
    $ sudo ufw allow https
    ```

1. 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](https://sjc1.vultrobjects.com/docs-main-doc-assets-1/2272/209ce9e8-09f6-45b6-a70f-6ce7e3105043.png)

1. Click **Let's Go**.

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

    ![Enter WordPress database details](https://sjc1.vultrobjects.com/docs-main-doc-assets-1/2272/5bf3458c-f25d-4dfe-a6c4-fe7a118b58dd.jpg)

1. Click **Run the Installation** to initialize the WordPress database.

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

    ![Setup the WordPress site details](https://sjc1.vultrobjects.com/docs-main-doc-assets-1/2272/8612cff2-b37f-44c9-8232-7bf13b6afb07.jpg)

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

1. Click **Install WordPress**.

1. 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
    ```

1. 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](https://sjc1.vultrobjects.com/docs-main-doc-assets-1/2272/725ac705-2bb4-4744-b040-a3f29aa57373.jpg)

1. Navigate to **Users** to add new users and assign roles.

1. Click **Appearance** > **Themes** to install or activate themes.

1. Click **Plugins** to add, remove, or configure WordPress plugins.

1. Click **Pages** to manage site content and layout.

1. Click **Posts** to view and edit blog entries.

    ![Manage Posts](https://sjc1.vultrobjects.com/docs-main-doc-assets-1/2272/0138faa7-c209-4bc4-a549-37faef364fc6.jpg)

1. Click **Add Post** to create a new blog post.

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

1. Click **Publish** to make the post live.

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

    ![Published Post on a WordPress Site](https://sjc1.vultrobjects.com/docs-main-doc-assets-1/2272/27ca8164-c9bd-4af9-a6a9-52815ce4557d.jpg)

## 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](https://wordpress.org/documentation/).
