How to Install WordPress on Debian 10/11 (Step by Step)

WordPress is a free, open-source, and one of the most popular content management systems on the internet. It allows you to host static and dynamic content on the internet. Generally, it used to be a blogging platform, but it is adapted by users over the years and has become extremely versatile. Now, it allows users to create fully functional websites of any category. WordPress is the best because it is customizable, optimized for mobile users, and easy to integrate with other software tools.

WordPress has a large database of themes and plugins that make your websites professional, user-friendly, and attractive. That’s the reason why more than 40% of the internet is using it!

In this guide, we will explain how to install WordPress on Debian 10 or 11

Step 1 - Install LAMP Server

A LAMP stack is a group of open source software (Linux, Apache, MariaDB, PHP) used to host dynamic websites and applications on the internet. LAMP server is a primary requirement for hosting any PHP-based application. In this section, we will demonstrate how to install the LAMP (Apache, MariaDB, PHP) server on Debian 10 Or 11

Install Apache Web Server

The Apache web server is the most popular web server in the world. It is the default choice for hosting a website. Run the following command to install the Apache webserver package on your server.

					apt-get install apache2  -y

After completing the installation, start the Apache service and enable it to start after the system reboot:

					systemctl start apache2
systemctl enable apache2

Install PHP 8

At the time of writing this article, the latest version of PHP is 8.0. PHP 8 has significant performance improvements and new features. So it is always recommended to install PHP 8 on your server.

By default, PHP 8.0 is not included in the Debian 10/11 default repository. So you will need to add the PHP Sury repository to your server.

First, install the required dependencies using the following command:

					apt-get install gnupg2 ca-certificates apt-transport-https software-properties-common -y

Next, add the PHP Sury repository to APT and add the GPG key with the following command:

					echo "deb $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
wget -qO - | apt-key add -

Next, update the repository and install PHP 8.0 with all necessary PHP extensions needed for WordPress using the following command:

					apt-get update -y
apt-get install php libapache2-mod-php php-pear php-cgi php-common php-mbstring php-zip php-net-socket php-gd php-xml-util php-gettext php-mysql php-bcmath unzip wget git -y

You can now check the PHP version using the command below:

					php -v

Sample output:

					PHP 8.0.9 (cli) (built: Jul 30 2021 13:09:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies

Install MariaDB Database Server

WordPress uses MySQL or MariaDB as a database backend to store and manage a site and user information. Here, we will install and use MariaDB as a database backend.

By default, the MariaDB package is included in the Debian 10/11 default repository. You can install it by just running the following command:

					apt-get install mariadb-server mariadb-client -y

Once the MariaDB package is installed, start the MariaDB service and enable it to start at system reboot:

					systemctl start mariadb
systemctl enable mariadb

By default, MariaDB installation is not secured. So it is recommended to secure the MariaDB installation using the mysql_secure_installation script:


You will be asked to set a MariaDB root password, remove anonymous users, disallow root login remotely and remove test database as shown below:

					Enter current password for root (enter for none):
Change the root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

At this point, the LAMP server is installed and ready to deploy the WordPress website.

Step 2 - Create a WordPress Database

Now, you will need to create a WordPress database and user on MariaDB. First, connect to the MariaDB with the following command:

					mysql -u root -p    

Provide your MariaDB root password then create a database and user using the following command:

					 CREATE DATABASE wordpressdb;
 GRANT ALL PRIVILEGES ON wordpressdb.* to wordpressuser@localhost identified by 'strongpassword';

Next, flush the privileges to apply the changes then exit from the MariaDB using the following command:


Step 3 - Download WordPress

Now, you will need to download and set up WordPress on your server. It is recommended to download the latest version of WordPress from their official website.

First, navigate to the Apache web root directory using the following command:

					cd /var/www/html

Next, download the latest version of WordPress using the wget command:


Next, unzip the downloaded file using the unzip command:


Next, rename the extracted directory to your preferred domain name.

					mv wordpress

Next, navigate to directory and copy the sample configuration file:

cp wp-config-sample.php wp-config.php
Next, edit the WordPress configuration file and define your database settings:
					nano wp-config.php
Change the following lines that match your database settings:
					/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpressdb' );

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

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

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

define('FS_METHOD', 'direct');

Save the file when you are finished. Then, change the ownership of directory to www-data:

					chown -R www-data:www-data /var/www/html/

Step 4 - Create Apache Virtual Host for WordPress

Next, you will need to create an Apache virtual host configuration file for WordPress. You can create it using the following command:

					nano /etc/apache2/sites-available/yourdomain.conf

Add the following lines:

					<VirtualHost *:80>
        DocumentRoot /var/www/html/

        <Directory "">
             AllowOverride All

        ErrorLog ${APACHE_LOG_DIR}/yourdomain.error.log
        CustomLog ${APACHE_LOG_DIR}/yourdomain.access.log combined


Save and close the file then verify the configuration file for any syntax error:

					apache2ctl configtest

Sample output:

					Syntax OK

Next, activate the Apache virtual host and enable the rewrite module using the following command:

					a2ensite yourdomain
a2enmod rewrite

Finally, restart the Apache service to apply the configuration changes.

					systemctl restart apache2

Step 5 - Enable HTTPS for WordPress

It is always recommended to enable the HTTPS on WordPress website to encrypt the HTTP traffic. You will need to install and configure Let’s Encrypt free SSL to enable the HTTPS.

First, install the Let’s Encrypt client package using the following command:

					apt-get install certbot python3-certbot-apache -y
Now, run the following command to download and install the Let’s Encrypt certificate on your WordPress website.
					certbot --apache --agree-tos --redirect --hsts --uir --staple-ocsp --email -d,

This command will download the Let’s Encrypt SSL and configure your Apache to use those SSL certificates.

A brief explanation of each option is shown below:

  • –apache: Let’s Encrypt Apache plugin.
  • –agree-tos: Agree to terms and services.
  • –redirect: Redirect website to HTTPS using 301 redirect.
  • –hsts: Enable Strict-Transport-Security header to every HTTP response.
  • –uir: Add the Content-Security-Policy header to every HTTP response.
  • –staple-ocsp: Enables OCSP Stapling.
  • –email: A valid email address used for registration and certificate notification.
  • -d: Define domain name.

Next, you will need to set up a cron job to renew the Let’s Encrypt certificate automatically. To do so edit the cron job with the following command:

					crontab -e

Add the following line:

					@daily certbot renew --quiet &amp;&amp; systemctl reload apache2

Save and close the file when you are finished. The above cron job will run daily and automatically renew the SSL certificates if they are about to expire.

Step 6 - Access WordPress Website

Now, open your web browser and access the WordPress installation wizard using the URL You will be redirected to the language selection screen:

install WordPress on Debian 10

Select your language and click on the Continue button. You should see the WordPress site configuration screen:

wordpress installation on Debian 10

Provide your site information and click on the Install WordPress button. Once the installation has been finished. You should see the following screen:

installing wordpress steps

Click on the Login button. You should see the WordPress login screen:

wordpress login screen

Provide your admin username, password and click on the Login button. You will be redirected to the WordPress dashboard:

wordpress dashboard


In the above guide, we demonstrated how to install WordPress on Debian 10/11. We also explained how to enable HTTPS on the WordPress site using Let’s Encrypt free SSL. You can now start creating your first blog on the WordPress platform.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

3 2 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x