WordPress is a widely used free and open-source PHP-based Content Management System. It was developed by Matt Mullenweg and Mike Little in 2003. WordPress can be installed and used on almost any web hosting service, making it the easiest CMS to install and use. Futhermore, with WordPress, you can create a website without any programming knowledge.
The cool features associated with WordPress CMS are:
- Easy to add Additional Website Editors: easily add/edit/remove additional editors to give others within your organization the ability to manage your website content.
- Flexible Post Scheduling: Posts can be scheduled to display at later specific dates/times so that you can create content ahead of time and schedule.
- Restore deleted pages & Rollback Versioning: restore deleted page content before it is deleted permanently and even roll back page text to previous versions using built-in version control features.
- Automatic Backups – to prevent data loss, automatic daily site-level backups, as well as bare-metal backups, are taken.
- Integrated News & Blog Posting: use the built-in blogging and blog category management to easily add/edit/remove the content as you need to. Add news articles on an ongoing basis directly from your browser.
- Managed Website Security: as part of the WordPress managed web hosting services, WordPress’s security, backups, core upgrades, and updates are taken care of for you.
- Easy to manage: using the intuitive WordPress CMS, you can log in from any modern browser and make changes to your website without programming knowledge.
- Unlimited pages, posts, and products: it allows one to add images, text, files, links, and embed media right on the content areas without being restricted on the number of pages, posts, or products to can add.
- Stability and reliability: The third-party plugins are reviewed and tested to help prevent security risks and minimize performance impacts on your website.
By following this guide to the end, you should be able to install WordPress on Debian 11 (Bullseye) with Apache and Let’s Encrypt.
Getting Started.
It is important the system and available packages are updated and upgraded before we proceed. The command used to update the system and its packages is:
sudo apt update && sudo apt upgrade -y
Step 1 – Install PHP Extensions
Since WordPress is PHP-based, we need to install PHP and its extensions on Debian 11 (Bullseye).
The default repository provides PHP 7.4 which can be installed using the command:
sudo apt install php php-common php-mysql php-gmp php-curl php-intl php-mbstring php-xmlrpc php-gd php-xml php-cli php-zip
You can confirm the version of PHP with:
$ php -v
PHP 7.4.33 (cli) (built: Feb 22 2023 20:07:47) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
For PHP 8.2 and its extensions, you need to add a third-party repository as below:
sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
Remove old versions of PHP:
sudo apt remove apache2 php php-common php-mysql php-gmp php-curl php-intl php-mbstring php-xmlrpc php-gd php-xml php-cli php-zip libapache2-mod-php
Once added, install PHP 8.2 with the command:
sudo apt update
sudo apt install apache2 php8.2 libapache2-mod-php8.2 php8.2-{common,mysql,gmp,curl,intl,mbstring,xmlrpc,gd,xml,cli,zip}
Confirm the version of PHP:
$ php -v
PHP 8.2.6 (cli) (built: May 12 2023 07:48:41) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.6, Copyright (c) Zend Technologies
with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies
Once installed, you need to configure PHP for WordPress at below:
##For PHP7.4
sudo vim /etc/php/7.4/apache2/php.ini
##For PHP8.2
sudo vim /etc/php/8.2/apache2/php.ini
Edit the file as below:
max_execution_time = 300
upload_max_filesize = 100M
post_max_size = 128M
Step 2 – Install and Configure MariaDB
A database is required to serve as storage for WordPress. For this guide, we will install the MariaDB database on Debian 11.
sudo apt install -y mariadb-server mariadb-client
Start and enable MariaDB.
sudo systemctl start mariadb
sudo systemctl enable mariadb
Secure the MariaDB installation.
$ sudo mysql_secure_installation
.....
Enter current password for root (enter for none): Just press Enter
Switch to unix_socket authentication [Y/n] y
Change the root password? [Y/n]
New password: xxx << Enter Password
Re-enter new password: xxx << Re-Enter 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
....
Thanks for using MariaDB!
Now login to the shell and created a database for WordPress.
sudo mysql -u root -p
Create the database and remember to replace variables where needed.
CREATE DATABASE wordpress;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'Passw0rd';
GRANT ALL ON wordpress.* TO 'wp_user'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT
Step 3 – Download WordPress on Debian
Now we will pull the latest WordPress archive file using the wget
command below:
cd /tmp
wget https://wordpress.org/latest.tar.gz
Proceed and extract the archive.
tar -xvzf latest.tar.gz
Move the file to the webroot directory.
sudo mv wordpress /var/www/html/wordpress
Set the correct permissions for the path.
sudo chown -R www-data:www-data /var/www/html/wordpress/
sudo chmod -R 755 /var/www/html/wordpress/
Step 4 – Configure Apache Virtual Host for WordPress
We will then create a virtual host file for WordPress. Create the file using your favorite editor:
sudo vim /etc/apache2/sites-available/wordpress.conf
The file will contain the below lines:
<VirtualHost *:80>
ServerName wordpress.example.com
ServerAlias www.wordpress.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/html/wordpress
ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined
<Directory /var/www/html/wordpress>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Remember to replace wordpress.example.com with your own domain name. Save the file, enable the site and activate the rewrite module.
sudo a2dissite 000-default.conf
sudo a2ensite wordpress
sudo a2enmod rewrite ssl headers
Restart Apache for the changes to apply.
sudo systemctl restart apache2
Step 5 – Access the WordPress Web Installer
Access the WordPress Web Installer using the URL http://domain_name. Select the preferred language and proceed.
Click Let’s Go to proceed with the installation.
Provide the details for the created WordPress database.
If the connection goes through, you will see this message.
Click Run the installation and proceed to create your WordPress site and admin account.
Run the installation, and once it is complete, proceed and login to WordPress Admin.
Step 6 – Access and Use WordPress on Debian 11(Bullseye)
Login to the WordPress Admin dashboard by providing the created user credentials.
Once logged in, you will see the below dashboard.
On this dashboard, you can make several customizations/settings to your website.
To set the theme, background, widgets, and customize your page, click on appearance.
You can also add the desired plugins in the Plugins tab.
Create and manage users on WordPress in the Users tab. Here, you can create users and assign them a role as a subscriber, author, contributor, editor, or an administrator.
Make settings to the WordPress site in the settings tab. The general settings involve setting the site title, site URL, site tagline e.t.c
You can also configure the Permalink(permanent link) for your site. This is so important since it avoids exposing the post ID which at times may change when accessed from a different system. The Permanent link is normally obtained from the post title. You can configure how you want the Permalink to appear.
Once the made settings have been saved, proceed and create a sample post. In the Posts tab. We already have a sample post created.
Create a new one by clicking on Add New and providing the content you need to post.
While writing, you can save and preview the content. Once you have completed the task and need to publish it as online content, click publish.
The published content can be viewed using the permalink. Alternatively, visit the site using the URL http://domain_name.
Remember the admin console is moved to the URL http://domain_name/wp-admin after the installation is complete.
Step 7 – Secure WordPress with Let’s Encrypt
Let’s Encrypt is used to generate free trusted certificates for any FQDN. Begin by installing the required tools:
sudo apt install certbot python3-certbot-apache
Once the Certbot package has been installed, proceed and generate SSL certificates using the command:
sudo certbot --apache
Proceed as shown:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): Enter a valid Email address here
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Account registered.
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: wordpress.example.com
2: www.wordpress.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
Requesting a certificate for wordpress.example.com
Created an SSL vhost at /etc/apache2/sites-available/wordpress-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/wordpress-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/wordpress-le-ssl.conf
Redirecting vhost in /etc/apache2/sites-enabled/wordpress.conf to ssl vhost in /etc/apache2/sites-available/wordpress-le-ssl.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://wordpress.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Subscribe to the EFF mailing list (email: [email protected]).
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/wordpress.example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/wordpress.example.com/privkey.pem
Your certificate will expire on 2022-07-18. To obtain a new or
tweaked version of this certificate in the future, simply run
certbot again with the "certonly" option. To non-interactively
renew *all* of your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
That is it! You can now access your WordPress site via HTTPS.
Voila!
That was enough learning. We have successfully installed WordPress on Debian 11 (Bullseye) with Apache and Let’s Encrypt. I hope you found this significant.
See more:
- Install and Use WPScan – WordPress security scanner
- WordPress performance tips for the everyday user
- How To Setup WordPress Multisite on Ubuntu
- Best Books To Learn WordPress Development