• Porto, Portugal
Tecnologias da Informação
Install WordPress on Debian 11

Install WordPress on Debian 11

 

Download the WordPress package

The next step is to download the latest stable version of WordPress for Linux. This step will be done from the /tmp folder and using the wget command.

cd /tmp
wget https://wordpress.org/latest.tar.gz

When the download is finished, unzip it, move it to the Apache root directory, assign the appropriate permissions and make Apache the owner of the folder so that it will not have any problems running.

tar -xvzf latest.tar.gz
sudo mv wordpress/ /var/www/html/
sudo chmod 755 -R /var/www/html/wordpress/
sudo chown -R www-data:www-data /var/www/html/wordpress/

Next, create a new VirtualHost to better manage the WordPress website

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

And add the following:

<VirtualHost *:80>
     ServerAdmin admin@your_domain.com
      DocumentRoot /var/www/html/wordpress
     ServerName your-domain.com

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

     ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
     CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined

</VirtualHost>

Replace the ServerName and ServerAdmin values with the appropriate values which are your domain and Admin email. Save the changes and close the editor.
Now enable the new Apache site and the Apache rewrite module.

ln -s /etc/apache2/sites-available/wordpress.conf /etc/apache2/sites-enabled/wordpress.conf
a2enmod rewrite

Apply changes by restarting Apache

systemctl restart apache2

Install the Let’s Encrypt certificates
As your site will be on the internet, you should enable HTTPS and for that, you have to generate and install the Let’s Encrypt certificates which we can do with the help of Certbot.

So, install Certbot and the Apache plug-in.

apt install certbot python3-certbot-apache

And generate the certificates, with the following command

certbot --apache -d [your-domain]

Replace [your-domain] with your domain. During the process, you will have to enter an email address and accept the license terms.

Afterward, if the process is successful you will be notified and you can restart Apache and finish the process. Now open a web browser and go to https://yourdomain and you will see the following screen starting the installer.