How to Install WordPress on Debian 12

WordPress is the content management system (CMS) that is used for the creation of different websites because it allows the users to create a static website using the graphical user interface for designing the website. 

WordPress provides ease to its users in designing a cool website for their business. It also provides hosting services to its users which means a user will have all the things under one roof for the creation of a website using WordPress. 

WordPress can be downloaded on multiple platforms including different distributions of Linux to create a website. This blog will explain the installation of WordPress on Debian 12 with the following outline:

Let’s start the post by understanding WordPress and exploring its features.

What is WordPress?

WordPress is used to create websites as well as to host them, therefore, there is no need to hire a web developer or freelance the project, now users can create and host the website using the graphical user interface of WordPress. 

The major features of using WordPress are:

  • It provides many themes and templates using which an eye-catching website can be created
  • It provides different plugins that are used to enhance the performance of a website including social media integration with the website
  • Users can edit the contents of the website with simple steps
  • Prices of the hosting and domain are flexible 
  • It also provides minimal pricing plans for storage

After going through the features mentioned above, users must be curious to install WordPress on Debian 12. Before the installation of WordPress, first, the setting up of the LAMP Stack is required by the instructions explained in the next section.  

How to Set Up a LAMP Stack on Debian Linux?

LAMP is the abbreviation of “Linux, Apache, MySQL, PHP” and all these tools are essential for the development of Web applications on Linux distributions. 

Apache is the web server that transfers the website’s files to the end users through the internet whereas MySQL is the database used to store and manage the data of the website. PHP is the programming language that is used to build the website’s content. 

Some users replace MySQL with MariaDB and PHP with Python. In this section, we will go with the installation of MySQL and PHP in setting up the LAMP. 

To set up the LAMP on Debian 12, follow the instructions mentioned below. 

Step 1: Open the Terminal and Update the Packages

First, open the terminal with the shortcut key CTRL+ALT+T and then update all its packages by running the command:

$ sudo apt update

Step 2: Install Apache and PHP on Debian 12

Use the below-mentioned command for the installation of Apache, MySQL, and PHP on Debian 12:

$ sudo apt install apache2 ghostscript libapache2-mod-php   php  php-bcmath php-curl php-imagick php-intl php-json  php-mbstring  php-mysql php-xml php-zip -y

Step 3: Install MySQL on Debian 12

Download the MySQL Debian package from its official website before installing it:

Click on the “Download” button and then navigate to the “Downloads” directory to list down its contents:

$ cd Downloads && ls

Now install the downloaded package of MySQL using the command:

$ sudo apt install ./mysql-apt-config_*_all.deb

Complete the installation of the configuration of the MySQL following the instructions that appear on the screen, now update the repository of Debian 12 and install MySQL by running the command:

$ sudo apt install mysql-server -y

The package of MySQL server has been successfully installed on Debian 12.

Step 4: Start and Secure MySQL on Debian 12

After starting the Apache web server, start the service of MySQL and display its status with the command:

$  sudo systemctl start mysql.service && systemctl is-active mysql

The “active” output is the confirmation of the successful initialization of the MySQL database. After starting it, secure the MySQL database with the following command:

$ sudo mysql_secure_installation

When the security configuration is completed, restart the MySQL service:

$  sudo systemctl restart mysql.service

Step 5: Start Apache Web Server

Now start the Apache web server and also enable it to make sure its initialization at the time of boot:

$ sudo systemctl start apache2 && sudo systemctl enable apache2

Verify the status of the installed Apache web server:

$ sudo systemctl status apache2

The Apache web server is running successfully on Debian 12. 

LAMP has successfully been set up on Debian 12 and now it’s time to create a MySQL database for WordPress. 

How to Set Up a Database of MySQL on Debian for WordPress?

To store the user information as well as the WordPress data, it is recommended to create a separate database using MySQL. To create a MySQL database for WordPress website, execute the commands explained in the next steps. 

Step 1: Log in to MySQL

First, log in to the MySQL database as a root user with the command:

$ sudo mysql -u root -p

Type the password and press the ENTER key to complete the login step.

Step 2: Create a MySQL Database

After logging in to MySQL, create a database with the name “wordpress” using the command:

> CREATE DATABASE wordpress;

The database has successfully been created on Debian 12. 

Step 3: Create a MySQL User

To manage the “wordpress”, create a user with the name “wordpress” by running the command:

> CREATE USER wordpress@localhost IDENTIFIED BY 'password';

Replace the “password” to set your strong password for the user “wordpress”. 

Step 4: Grant all the Privileges

Now grant all the privileges to the user “wordpress” for managing the “wordpress” with the command:

    -> ON wordpress.*
    -> TO wordpress@localhost;

Flush the previous privileges and exit the MySQL database:


The MySQL database for WordPress has been successfully created. 

How to Download and Configure WordPress on Debian 12?

Finally, download the latest package of WordPress from its official website by the following steps. 

Step 1: Create the Directory

To download and install WordPress, create a new directory using the command:

$ sudo mkdir -p /srv/www

Step 2: Set Permissions

To set the permissions of the “/srv/www” directory and files, use the chown command as shown:

$ sudo chown www-data: /srv/www

Step 3: Download WordPress on Debian 12

To download the WordPress package using the terminal, run the command:

$ curl | sudo -u www-data tar zx -C /srv/www

Step 5: Create a WordPress Configuration File

Now create a configuration file of WordPress using the nano text editor:

$  sudo nano /etc/apache2/sites-available/wordpress.conf

Users are requested to copy-paste the mentioned below lines in the file and exit by saving it:

<VirtualHost *:80>
    DocumentRoot /srv/www/wordpress
    <Directory /srv/www/wordpress>
        Options FollowSymLinks
        AllowOverride Limit Options FileInfo
        DirectoryIndex index.php
        Require all granted
    <Directory /srv/www/wordpress/wp-content>
        Options FollowSymLinks
        Require all granted

Step 6: Enable the VirtualHost

After making changes in the configuration file, enable the VirtualHost, rewrite the module created in the above step, and disable the welcome page of Apache:

$ sudo a2ensite wordpress && sudo a2enmod rewrite && sudo a2dissite 000-default

Step 7: Restart the Apache

Restart the Apache web server to reload the changes:

$ sudo service apache2 reload

Step 8: Connect the WordPress to the Database

Run the below-mentioned command to configure the WordPress that is the first step for connecting the WordPress to the database:

$ sudo -u www-data cp /home/itslinuxfoss/Downloads/wordpress/wp-config-sample.php /srv/www/wordpress/wp-config.php

Step 9: Set the Database Credentials

Now set the credentials by the commands mentioned below and ensure to replace the database name, username, and password with your unique set credentials:

$ sudo -u www-data sed -i 's/database_name_here/wordpress/' /srv/www/wordpress/wp-config.php

$ sudo -u www-data sed -i 's/username_here/wordpress/' /srv/www/wordpress/wp-config.php

$ sudo -u www-data sed -i 's/password_here/password/' /srv/www/wordpress/wp-config.php

Step 10: Secure the Website

To protect the website from the “unknown secret” attacks, open the configuration file of the WordPress:

$ sudo -u www-data nano /srv/www/wordpress/wp-config.php

Locate the lines below and replace them with the ones that are provided on the mentioned website:

define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );

Save the file with the CTRL+S key. 

Step 11: Open WordPress

Launch the web browser and go to the following address:


Step 12: Configure WordPress

Choose the language, for instance, “English” is chosen as shown:

Fill out the form to complete the information needed:

Now again fill in the blank boxes and click on the “Install WordPress” button:

A message of “Success!” will be displayed on the installation upon its completion: 

Now Enter the username and Password of your WordPress account to manage the website:

The WordPress dashboard has been successfully displayed on the screen:

This is all about the installation of WordPress on Debian 12. 


To install WordPress on Debian 12, download the latest package of “WordPress” from its official website and follow the instructions explained in this post.  Ensure the setup of LAMP on Debian 12 before the installation of WordPress. 

This blog explains all the steps involved in the installation of WordPress on Debian 12 with the demonstration.