Debian 11 Bullseye
WordPress Installation on Debian 11 Bullseye
Packages list update
Before installing any package, it’s advisable to update your Debian machine packages list.
As root, run the command:
As root, run the command:
apt update
(Optional) Packages upgrade
Not necessarily required for having a working WordPress installation,
but it is best practice and healthy to upgrade your box.
Especially on Debian stable (which is the case for version 11 ‘Bullseye’),
as the upgrades are mostly related to fixing security issues.
As root, run the command:
but it is best practice and healthy to upgrade your box.
Especially on Debian stable (which is the case for version 11 ‘Bullseye’),
as the upgrades are mostly related to fixing security issues.
As root, run the command:
apt upgrade
(and press Enter to confirm the upgrades)
Install the required packages
The command below will install the web server (Apache),
the PHP language interpreter
and the database (MariaDB/MySQL).
As root, run the command:
the PHP language interpreter
and the database (MariaDB/MySQL).
As root, run the command:
apt-get install -y libapache2-mod-php php-cli mariadb-server php-mysql mariadb-client mariadb-common php-json php-curl php-imagick php-mbstring php-xml php-zip php-intl
Web server configuration
Now it’s time to configure Apache, the web server.
This will allow your server to serve web pages
and answer to a certain web domain name.
Be sure to create a DNS record
of type A
that points to your server’s public IP address.
(you will need your domain provider’s panel to do that)
Once you have taken care of that,
the next thing is to edit the file /etc/apache2/sites-available/000-default.conf
changing the ServerName directive to reflect your web domain name.
As root, run the command:
This will allow your server to serve web pages
and answer to a certain web domain name.
Be sure to create a DNS record
of type A
that points to your server’s public IP address.
(you will need your domain provider’s panel to do that)
Once you have taken care of that,
the next thing is to edit the file /etc/apache2/sites-available/000-default.conf
changing the ServerName directive to reflect your web domain name.
As root, run the command:
nano /etc/apache2/sites-available/000-default.conf
and edit the line:
#ServerName www.example.com
removing the hash sign and replacing www.example.com with your domain.
The final result should be similar to this:
#ServerName www.example.com
removing the hash sign and replacing www.example.com with your domain.
The final result should be similar to this:
ServerName yourdomain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Press ctrl+o to save the file
and then ctrl+x to exit from nano
Reload the Apache web server.
As root, run the command:
As root, run the command:
service apache2 reload
Finally delete the Apache default index.html file
otherwise it will conflict with WordPress.
As root, run the command:
otherwise it will conflict with WordPress.
As root, run the command:
rm /var/www/html/index.html
Database configuration
Your WordPress website needs a database and credentials (username, password and permissions) to access it.
We have already installed the database engine (MariaDB/MySQL)
and now it’s the time to use it.
Access the database CLI (Command Line Interface)
with the command:
We have already installed the database engine (MariaDB/MySQL)
and now it’s the time to use it.
Access the database CLI (Command Line Interface)
with the command:
mariadb
Now to create a database:
choose a name (for example mywpdb)
and then type in the database CLI:
choose a name (for example mywpdb)
and then type in the database CLI:
create database mywpdb;
We now need to create a user
and a strong password.
An example of a username can be: mywpuser
and an example of a strong password can be: DF05.002S0H2tIyty
Decide your username and password
and then type in the database CLI:
and a strong password.
An example of a username can be: mywpuser
and an example of a strong password can be: DF05.002S0H2tIyty
Decide your username and password
and then type in the database CLI:
create user 'mywpuser'@'%' identified by 'DF05.002S0H2tIyty';
To grant permissions to this user, to the database, type in the database CLI:
grant all privileges on mywpdb.* to 'mywpuser'@'%' identified by 'DF05.002S0H2tIyty';
Tell the database engine to refresh its internal information about the newly created account and permissions.
Type in the database CLI:
Type in the database CLI:
flush privileges;
Well done !
You can now exit from the database CLI:
You can now exit from the database CLI:
exit
You can also use quit, or just ctrl+d
Download WordPress
We are now going to download, uncompress, change the permissions of the WordPress files,
perform some initial configuration preparation
and do a cleanup.
First, change your current working directory to /var/www/html
As root, run the command:
perform some initial configuration preparation
and do a cleanup.
First, change your current working directory to /var/www/html
As root, run the command:
cd /var/www/html
Now, download the latest version of WordPress.
As root, run the command:
As root, run the command:
wget https://wordpress.org/latest.tar.gz
Uncompress the WordPress archive.
As root, run the command:
As root, run the command:
tar xf latest.tar.gz
Move the uncompressed files.
As root, run the command:
As root, run the command:
mv wordpress/* .
Clean the folder.
As root, run the command:
As root, run the command:
rmdir wordpress
rm latest.tar.gz
Change the permissions of the folder.
As root, run the command:
As root, run the command:
chown -Rf www-data.www-data /var/www/html
Is it working ?
Open your browser and navigate to
http://yourdomain.com
and you should see the WordPress initial configuration page.
If not, double-check all the steps until now.
http://yourdomain.com
and you should see the WordPress initial configuration page.
If not, double-check all the steps until now.
Tweak PHP
Before performing the WordPress setup wizard,
it is important to tweak some of the PHP default settings.
The responsible file is php.ini.
As root, run the command:
it is important to tweak some of the PHP default settings.
The responsible file is php.ini.
As root, run the command:
nano /etc/php/7.4/apache2/php.ini
And update those parameters:
max_input_time = 300
max_input_vars = 3000
memory_limit = 512M
post_max_size = 256M
upload_max_filesize = 256M
default_socket_timeout = 300
Press ctrl+o to save the file
and then ctrl+x to exit from nano
Reload the Apache web server.
As root, run the command:
As root, run the command:
service apache2 reload
Enable .htaccess on Apache
The .htaccess file is important for WordPress
(and many WordPress plugins)
to further configure the web server (Apache)
without any manual interaction.
The responsible file is apache2.conf.
As root, run the command:
(and many WordPress plugins)
to further configure the web server (Apache)
without any manual interaction.
The responsible file is apache2.conf.
As root, run the command:
nano /etc/apache2/apache2.conf
And change this part:
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
in order to be like this:
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
Press ctrl+o to save the file
and then ctrl+x to exit from nano
Reload the Apache web server.
As root, run the command:
As root, run the command:
service apache2 reload
Enable Apache modules
There are several Apache modules that are required by WordPress and by some plugins.
As root, run the commands:
As root, run the commands:
a2enmod rewrite
a2enmod headers
a2enmod expires
Reload the Apache web server.
As root, run the command:
As root, run the command:
service apache2 reload
(Optional) Enable the www subdomain
If your website is already a subdomain
for example blog.yourdomain.com or docs.yourdomain.com
then you can skip this part.
Otherwise, it’s best practice for your website to be reachable on both yourdomain.com and www.yourdomain.com
To do that, you first need to create a DNS record
of type CNAME
that points to www.
(you will need your domain provider’s panel to do that)
(and you may want to double-check with your provider’s support)
Otherwise, you can create another DNS record
of type A
named www
that points to your server’s public IP address.
After you have taken care of that,
you need to edit the file /etc/apache2/sites-available/000-default.conf
adding a line after the ServerName directive.
As root, run the command:
for example blog.yourdomain.com or docs.yourdomain.com
then you can skip this part.
Otherwise, it’s best practice for your website to be reachable on both yourdomain.com and www.yourdomain.com
To do that, you first need to create a DNS record
of type CNAME
that points to www.
(you will need your domain provider’s panel to do that)
(and you may want to double-check with your provider’s support)
Otherwise, you can create another DNS record
of type A
named www
that points to your server’s public IP address.
After you have taken care of that,
you need to edit the file /etc/apache2/sites-available/000-default.conf
adding a line after the ServerName directive.
As root, run the command:
nano /etc/apache2/sites-available/000-default.conf
And change the relevant line so that it looks like this:
ServerName yourdomain.com
ServerAlias www.yourdomain.com
Press ctrl+o to save the file
and then ctrl+x to exit from nano
Reload the Apache web server.
As root, run the command:
and then ctrl+x to exit from nano
Reload the Apache web server.
As root, run the command:
service apache2 reload
(Optional) Enable SSL / HTTPS
Not necessarily required to have WordPress working
but a requirement for your website to have decent browser compatibility
and basic SEO.
We will use the Let’s Encrypt free service
which comes packaged as a snap.
As root, run the command:
but a requirement for your website to have decent browser compatibility
and basic SEO.
We will use the Let’s Encrypt free service
which comes packaged as a snap.
As root, run the command:
apt install snapd
to install the snap daemon
Then update the core:
Then update the core:
snap install core
And then install certbot
which is the tool to create and update Let’s Encrypt SSL certificates:
which is the tool to create and update Let’s Encrypt SSL certificates:
snap install --classic certbot
Then create a symlink to the certbot binary:
ln -s /snap/bin/certbot /usr/bin/certbot
And finally run:
certbot --apache
and follow the on-screen instructions (provide an email, accept the terms, etc).
You should now be able to reach your WordPress setup wizard on https://yourdomain.com
and the optional https://www.yourdomain.com
You should now be able to reach your WordPress setup wizard on https://yourdomain.com
and the optional https://www.yourdomain.com
WordPress configuration wizard
You can now configure WordPress
with the help of the configuration wizard.
Access your WordPress setup wizard on https://yourdomain.com
and chose the language.
You will then be asked a few questions about the database.
In this tutorial, for example:
the Database Name was mywpdb
the Username was mywpuser
and the Password was DF05.002S0H2tIyty
Replace with your settings
and leave Database Host and Table Prefix as default (locahost and wp_)
Confirm and if everything goes well, you should be able to see the Run the installation button.
Congratulations !
Now you can proceed with setting your site title, the panel’s credentials
and start publishing content on your fully functional WordPress website.
with the help of the configuration wizard.
Access your WordPress setup wizard on https://yourdomain.com
and chose the language.
You will then be asked a few questions about the database.
In this tutorial, for example:
the Database Name was mywpdb
the Username was mywpuser
and the Password was DF05.002S0H2tIyty
Replace with your settings
and leave Database Host and Table Prefix as default (locahost and wp_)
Confirm and if everything goes well, you should be able to see the Run the installation button.
Congratulations !
Now you can proceed with setting your site title, the panel’s credentials
and start publishing content on your fully functional WordPress website.