How to Install WordPress with Apache and Let’s Encrypt SSL on Debian 11


WordPress is the most popular content management system on the internet. It is free, open-source, and works well with almost any web hosting service, making it one of the easiest to install and use.

If you do not have web hosting yet, we recommend installing WordPress on your local Debian system or VPS.

Here, we will see how to install WordPress with Apache on Debian 11.


Install LAMP Stack

Follow the below link to install the LAMP stack on your Debian system

Install AMP (Apache, MariaDB, and PHP) on Debian 11

Install PHP Extensions for WordPress

Use the apt command to install the PHP extensions required for a WordPress installation.

sudo apt install -y php-curl php-xml php-common php-imagick php-json php-mbstring php-mysql php-zip php-bcmath php-gd php-int

Configure PHP for WordPress

The default PHP values may not be appropriate for everyone and you may need to change them based on the requirement. So, edit the php.ini file.

sudo nano /etc/php/7.4/apache2/php.ini

Then, update the below values as per your requirement. You may start with the below values for now and increase or decrease the values at any time when required.

max_execution_time = 300

upload_max_filesize = 64M

post_max_size = 64M

Setup Apache Virtual Host

We will start with creating an Apache virtual host for a WordPress installation. You can find all Apache virtual host configuration files under /etc/apache2/sites-available directory.

Typically virtual host files contain a domain name, port number, document root, log location, fast CGI, etc.

Assume the following,

Domain name:
Port No: 80
Document root: /var/www/html/

Create a virtual host configuration.

sudo nano /etc/apache2/sites-available/

Then, place the following content into the above configuration file. You will need to change ServerName as per your requirement.

<VirtualHost *:80>

   ServerAdmin [email protected]
   DocumentRoot /var/www/html/

   ErrorLog ${APACHE_LOG_DIR}/www.itzgeek.net_error.log
   CustomLog ${APACHE_LOG_DIR}/www.itzgeek.net_access.log combined

   <Directory /var/www/html/>
      Options FollowSymlinks
      AllowOverride All
      Require all granted


Next, create a document root directory to place WordPress files.

sudo mkdir -p /var/www/html/

Enable the virtual host and SSL, rewrite modules.

sudo a2ensite

sudo a2enmod rewrite ssl

Then, restart the Apache service.

sudo systemctl restart apache2

Install Let’s Encrypt SSL Certificate

Create DNS Record

Go to your domain registrar and create an A and CNAME (optional if you do not want to use www subdomain) record for your domain. Typically you will have to make two records for your WordPress website.

  1. Non-www Domain Name (Ex. >> A record point to your server IP
  2. www Domain Name (Ex. >> CNAME record point to

For this demo, I will create two records so that my WordPress website will be accessible at

DNS Records
DNS Records

Install Certbot client

The Certbot client, which helps us generate and install the Let’s Encrypt SSL certificate, is now available as a snap package for Debian operating system. So, first, install snapd daemon on your system.

sudo apt update

sudo apt install -y snapd

Then, update snapd to the latest version.

sudo snap install core && sudo snap refresh core

Finally, install the Certbot client using the below command.

sudo snap install --classic certbot

sudo ln -s /snap/bin/certbot /usr/bin/certbot

Install SSL Certificate

Use the below command to generate and install the Let’s Encrypt SSL certificate on the Apache webserver.

sudo certbot --apache
1. Enter email address to receive notification on urgent renewal and security notices
2. Type Y and press Enter to register with the ACME server
3. Type Y or N to receive emails about EFF news, campaigns, and newsletters.
4. Certbot will automatically detect the WordPress domain and ask you permission to activate HTTPS for your WordPress website. Type 1 or appropriate numbers separated by a comma in case you have multiple websites.
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1,2

Wait for the SSL installation to complete.

Redirect non-www HTTP requests to www HTTPS with Apache

The Certbot client will place the required rules to redirect the traffic from HTTP to the HTTPS website.

1. >>

2. >>

As you can see, the first domain is not reaching www HTTPS with rules placed by Certbot. So, you will have to add a rule manually to redirect traffic from non-www HTTP to www HTTPS domain if required, I.e., >>

Auto-Renew SSL Certificate

The Certbot client comes with a systemd service that takes care of automated certificate renewals. So, you will not have to renew the certificates manually.

Install WordPress with Apache on Debian 11

Create WordPress Database

First, login into MariaDB/MySQL database server.

sudo mysql -u root -p

Then, create the database for WordPress installation along with the database user and password.


CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'wppassword';

GRANT ALL PRIVILEGES ON wpdatabase.* TO 'wpuser'@'localhost';


Download WordPress

Download the latest version of the WordPress files by using the following command.


Then, extract the downloaded file.

tar -zxvf latest.tar.gz

And then, move the files to your website document root directory.

sudo mv wordpress/* /var/www/html/

Update the ownership and a group of the WordPress directory.

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

Install WordPress

Open your browser and visit your WordPress website domain to perform the WordPress installation.


1. Choose the Installation Language and click Continue

2. Click Let’s go!

3. Enter the WordPress database details and then click Submit

4. Click Run the installation

5. Enter the WordPress website information and then click Install WordPress

6. Click Log In to access the WordPress admin backend to manage WordPress installation. Alternatively, you can access the WordPress backend by going to https://your-wordpress-website/wp-admin

Access WordPress Website

Now, you will be able to access the site with your domain name.

WordPress with Apache
WordPress with Apache


That’s All. I hope you have learned how to install WordPress with Apache on Debian 11.

You might also like