WordPress is a free, open-source, and one of the most popular content management systems on the internet. It allows you to host static and dynamic content on the internet. Generally, it used to be a blogging platform, but it is adapted by users over the years and has become extremely versatile. Now, it allows users to create fully functional websites of any category. WordPress is the best because it is customizable, optimized for mobile users, and easy to integrate with other software tools.
WordPress has a large database of themes and plugins that make your websites professional, user-friendly, and attractive. That’s the reason why more than 40% of the internet is using it!
A LAMP stack is a group of open source software (Linux, Apache, MariaDB, PHP) used to host dynamic websites and applications on the internet. LAMP server is a primary requirement for hosting any PHP-based application. In this section, we will demonstrate how to install the LAMP (Apache, MariaDB, PHP) server on Debian 10 Or 11
Install Apache Web Server
The Apache web server is the most popular web server in the world. It is the default choice for hosting a website. Run the following command to install the Apache webserver package on your server.
apt-get install apache2 -y
After completing the installation, start the Apache service and enable it to start after the system reboot:
At the time of writing this article, the latest version of PHP is 8.0. PHP 8 has significant performance improvements and new features. So it is always recommended to install PHP 8 on your server.
By default, PHP 8.0 is not included in the Debian 10/11 default repository. So you will need to add the PHP Sury repository to your server.
First, install the required dependencies using the following command:
WordPress uses MySQL or MariaDB as a database backend to store and manage a site and user information. Here, we will install and use MariaDB as a database backend.
By default, the MariaDB package is included in the Debian 10/11 default repository. You can install it by just running the following command:
apt-get install mariadb-server mariadb-client -y
Once the MariaDB package is installed, start the MariaDB service and enable it to start at system reboot:
systemctl start mariadb
systemctl enable mariadb
By default, MariaDB installation is not secured. So it is recommended to secure the MariaDB installation using the mysql_secure_installation script:
mysql_secure_installation
You will be asked to set a MariaDB root password, remove anonymous users, disallow root login remotely and remove test database as shown below:
Enter current password for root (enter for none):
Change the root password? [Y/n] Y
New password:
Re-enter new 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
At this point, the LAMP server is installed and ready to deploy the WordPress website.
Now, you will need to create a WordPress database and user on MariaDB. First, connect to the MariaDB with the following command:
mysql -u root -p
Provide your MariaDB root password then create a database and user using the following command:
CREATE DATABASE wordpressdb;
GRANT ALL PRIVILEGES ON wordpressdb.* to wordpressuser@localhost identified by 'strongpassword';
Next, flush the privileges to apply the changes then exit from the MariaDB using the following command:
FLUSH PRIVILEGES;
QUIT;
Step 3 - Download WordPress
Now, you will need to download and set up WordPress on your server. It is recommended to download the latest version of WordPress from their official website.
First, navigate to the Apache web root directory using the following command:
cd /var/www/html
Next, download the latest version of WordPress using the wget command:
wget https://wordpress.org/latest.zip
Next, unzip the downloaded file using the unzip command:
unzip latest.zip
Next, rename the extracted directory to your preferred domain name.
mv wordpress yourdomain.com
Next, navigate to yourdomain.com directory and copy the sample configuration file:
cd yourdomain.com
cp wp-config-sample.php wp-config.php
Next, edit the WordPress configuration file and define your database settings:
nano wp-config.php
Change the following lines that match your database settings:
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpressdb' );
/** MySQL database username */
define( 'DB_USER', 'wordpressuser' );
/** MySQL database password */
define( 'DB_PASSWORD', 'strongpassword' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
define('FS_METHOD', 'direct');
Save the file when you are finished. Then, change the ownership of yourdomain.com directory to www-data:
It is always recommended to enable the HTTPS on WordPress website to encrypt the HTTP traffic. You will need to install and configure Let’s Encrypt free SSL to enable the HTTPS.
First, install the Let’s Encrypt client package using the following command:
apt-get install certbot python3-certbot-apache -y
Now, run the following command to download and install the Let’s Encrypt certificate on your WordPress website.
This command will download the Let’s Encrypt SSL and configure your Apache to use those SSL certificates.
A brief explanation of each option is shown below:
–apache: Let’s Encrypt Apache plugin.
–agree-tos: Agree to terms and services.
–redirect: Redirect website to HTTPS using 301 redirect.
–hsts: Enable Strict-Transport-Security header to every HTTP response.
–uir: Add the Content-Security-Policy header to every HTTP response.
–staple-ocsp: Enables OCSP Stapling.
–email: A valid email address used for registration and certificate notification.
-d: Define domain name.
Next, you will need to set up a cron job to renew the Let’s Encrypt certificate automatically. To do so edit the cron job with the following command:
Save and close the file when you are finished. The above cron job will run daily and automatically renew the SSL certificates if they are about to expire.
Now, open your web browser and access the WordPress installation wizard using the URL https://yourdomain.com. You will be redirected to the language selection screen:
Select your language and click on the Continue button. You should see the WordPress site configuration screen:
Provide your site information and click on the Install WordPress button. Once the installation has been finished. You should see the following screen:
Click on the Login button. You should see the WordPress login screen:
Provide your admin username, password and click on the Login button. You will be redirected to the WordPress dashboard:
In the above guide, we demonstrated how to install WordPress on Debian 10/11. We also explained how to enable HTTPS on the WordPress site using Let’s Encrypt free SSL. You can now start creating your first blog on the WordPress platform.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
3.69votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Please login to comment
1 Comment
Most Voted
NewestOldest
Inline Feedbacks
View all comments
raymondday61
Member
1 year ago
It was step 4 were I messed up a lot. Did not add the conf at the end of my domain name.
nano /etc/apache2/sites-available/yourdomain.conf
Can not put a color so did it in bold I think it help others to know what to change on there end.
It was step 4 were I messed up a lot. Did not add the conf at the end of my domain name.
nano /etc/apache2/sites-available/yourdomain.conf
Can not put a color so did it in bold I think it help others to know what to change on there end.
-Raymond Day