How to install WordPress CMS on Debian 11.3

To Install WordPress CMS On Debian 11.3

Introduction:

WordPress is the most popular CMS (content management system) on the internet. It allows you to easily set up flexible blogs and websites on top of a MariaDB backend with PHP processing. WordPress has seen incredible adoption and is a great choice for getting a website up and running quickly.

Prerequisites:

• Apache Web server

• PHP and its Modules

• Mariadb mysql server

Step 1: Check the OS version by using the below command

root@linuxhelp:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye

Step 2 : Install the Apache Webserver by using the below command

root@linuxhelp:~# apt install apache2 -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libonig5
Use 'apt autoremove' to remove it.

Step 3: Start the Apache webserver by using the below command

root@linuxhelp:~# systemctl start apache2

Step 4: Check the Apache server status by using the below command

root@linuxhelp:~# systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-05-25 03:59:30 IST; 1h 12min ago
       Docs: https://httpd.apache.org/docs/2.4/

Step 5: Install PHP by using the below command

root@linuxhelp:~# apt install php libapache2-mod-php php-zip php-cli php-common php-curl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libonig5
Use 'apt autoremove' to remove it.

Step 6 : Install PHP dependency package by using the below command

root@linuxhelp:~# apt install php7.4-cli php7.4-json php7.4-common php7.4-mysql
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
php7.4-cli is already the newest version (7.4.28-1+deb11u1).
php7.4-cli set to manually installed.
php7.4-common is already the newest version (7.4.28-1+deb11u1).
php7.4-common set to manually installed.

Step 7: Install the MySQL secure installation and set the root password by using the below command

root@linuxhelp:~# apt install mariadb-server -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

root@linuxhelp:~# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...


All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

Step 8: Create a database and database user for wordpress by using the below command

root@linuxhelp: # mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 57
Server version: 10.5.15-MariaDB-0+deb11u1 Debian 11

MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.000 sec)


MariaDB [(none)]> grant all on wordpress.* to wordpress@localhost identified by 'linuxc#4';
Query OK, 0 rows affected (0.044 sec)


MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.015 sec)


MariaDB [(none)]> use wordpress;
Query OK, 0 rows affected (0.015 sec)

MariaDB [wordpress]> Create user ‘linuxhelp1’@’localhost’ identified by ‘linux’ 
Query OK, 0 rows affected (0.007 sec)


MariaDB [wordpress]> grant all on wordpress.* to linuxhelp1@localhost;
Query OK, 0 rows affected (0.044 sec)


MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.015 sec)


MariaDB [(none)]> exit
Bye

Step 9: Change the directory by using the below command

root@linuxhelp:~# cd /var/www/

Step 10: Install the wget by using the below command

root@linuxhelp:/var/www# apt-get install wget -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libonig5

Step 11: Download the wordpress by using the below command

root@linuxhelp:/var/www# wget https://wordpress.org/latest.tar.gz
--2022-05-28 05:30:40--  https://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... 198.143.164.252
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21166276 (20M) [application/octet-stream]
Saving to: ‘latest.tar.gz’

latest.tar.gz       100%[===================>]  20.19M  6.56MB/s    in 3.3s    

2022-05-28 05:30:44 (6.07 MB/s) - ‘latest.tar.gz’ saved [21166276/21166276]

Step 12: Extract the wordpress zip file by using the below command

root@linuxhelp:/var/www# tar -xzvf latest.tar.gz
wordpress/
wordpress/xmlrpc.php
wordpress/wp-blog-header.php
wordpress/readme.html
wordpress/wp-signup.php
wordpress/index.php
wordpress/wp-content/themes/twentytwentyone/

Step 13 : See the wordpress file by using the below command

root@linuxhelp:/var/www# ls -la
total 20692
drwxr-xr-x  4 root   root        4096 May 28 05:31 .
drwxr-xr-x 12 root   root        4096 May 25 02:28 ..
drwxr-xr-x  2 root   root        4096 May 25 02:49 html
-rw-r--r--  1 root   root          21 May 25 03:59 html.info.phpy
-rw-r--r--  1 root   root    21166276 May 25 00:33 latest.tar.gz
drwxr-xr-x  5 nobody nogroup     4096 May 25 00:32 wordpress

Step 14: Change Mode to the wordpress directory by using the below command

root@linuxhelp:/var/www# chmod -R 775 wordpress/

Step 15: Change Ownership to the wordpress directory by using the below command

root@linuxhelp:/var/www# chown  -R  wordpress/

Step 16: Change Directory to Apache2 by using the below command

root@linuxhelp:~# cd /etc/apache2/sites-available/

Step 17: Open Nano conf.editor and add server name by using the below command

root@linuxhelp:/etc/apache2/sites-available# nano wordpress.conf

<virtualHost *:80>
serverName www.linuxhelp.com
DocumentRoot /var/wwwwordpress
<Directory /var/www/wordpress>
AllowOverride all
Allow from all
<Directory>
</virtualhost>

Step 18: open Host Nano conf.editor add host name and Ip by using the below command

root@linuxhelp:~# nano /etc/hosts

<ip address> www.linuxhelp1.com

Step 19: Restart the Apache2 by using the below command

root@linuxhelp:/etc/apache2/sites-available# systemctl restart apache2

Step 20: Access Wordpress Website as shown in the below images

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install WordPress CMS on Debian 11.3. Your feedback is much welcome.

FAQ
Q
What is the location of the WordPress config file?
A
The location for WordPress configuration is /var/www/wordpress/wordpress.conf
Q
How to create using a WordPress database?
A
Create user ‘linuxhelp1’@’localhost’ identified by ‘’;
Q
How to create a permission WordPress database?
A
grant all on WordPress.* to wordpress@localhost identified by ;
Q
How to install WordPress on Debian?
A
wget https://wordpress.org/latest.tar.gz
Q
What are the prerequisites for CMS creation?
A
Apache Web server,PHP and its Modules,Mariadb mysql server