Deploy Wordpress on Debian 11
This tutorial is for manually deploying wordpress on an Debian 11 server. Alternatively, you could deploy wordpress through docker.
Install MariaDB
Now log into the database
Create the wordpress database, and then create a wordpress
user that will have access to it. Be sure to change the passwordHere
text.
Add Ondrej Sury PHP Repository
Debian 11 comes with PHP 7.4 by default, but PHP 8.1 is already out, and security support for PHP 7.4 comes to an end on the 28th of Nov 2022 (less than a month away), so we are going to upgrade to PHP 8.1 with the help of Ondřej Surý's very popular PHP repository.
Install Apache and PHP
Download Wordpress
Optional - Create Wordpress SSH User
I use SSH to update my wordpress instances, and wish to use a non-sudo user to do this. Thus I will create a wordpress user at this point.
Install Wordpress
Set Umask and Add to Group
Let's add the www-data
user to the wordpress
group so that Apache can access the files even if they are group owned by the wordpress user.
Now let's set the umask so that if the wordpress user creates a file, the Apache server can still read them.
027
means that new files will have 740 (-rwxr-----) permissions, but new directories will have 750 (-rwxr-x---).
Configure Apache
We now need to configure apache to load the wordpress folder as a site. If you use vim as your editor of choice, you may wish to fix the pasting issue, and syntax highlighting, if this is a fresh install of Debian.
Replace it with:
Restart apache for the changes to take effect
Enable URL Rewrite And Create Htaccess File
Create a .htaccess
file for routing.
editor /var/www/wordpress/public_html
Give it the following content:
RewriteEngine On
# Don't redirect if matches file
RewriteCond %{REQUEST_FILENAME} !-f
# Don't redirect if matches directory
RewriteCond %{REQUEST_FILENAME} !-d
# Redirect everything else to index.php
RewriteRule ^ index.php [QSA,L]
Create WP Config File
Move the example wp-config.php file into place
Database Credentials
Fill in the database credentials in the config file:
editor /var/www/wordpress/wp-config.php
Define Salts
Navigate to https://api.wordpress.org/secret-key/1.1/salt/ to generate a set of salts to update your wp-config.php file with.
Extra Steps For Those Using A Reverse Proxy
If you are using a reverse proxy, that terminates the TLS connection, and only forwards a plain HTTP connection to the underlying wordpress site, then we need to add the following to your wp-config.php file:
Web Installation
Now go to your servers IP or hostname and perform the web based installation steps, before then going through the tutorial on securing wordpress.
First published: 23rd October 2022