Are you looking to build a stunning website or start a blog? WordPress is an excellent tool that can help you achieve your goals. It is a popular open-source software that allows you to create beautiful websites, blogs, and even applications. In this comprehensive guide, we will walk you through the process of installing WordPress on a Debian 11 system with the LEMP stack.

Why Choose Debian 11 for WordPress Installation?

Debian 11, also known as “Bullseye,” is a stable and reliable operating system that provides a robust foundation for hosting your WordPress site. It offers excellent security features, regular updates, and extensive software repositories. Pairing Debian 11 with the LEMP stack (Nginx, MariaDB, and PHP) ensures optimal performance and scalability for your WordPress installation.

Step 1: Updating the System

Before we begin the installation process, it’s essential to update our Debian system to ensure that all installed packages are up to date. Open the terminal and enter the following commands:

apt update
apt upgrade

Step 2: Installing Nginx

Nginx is a high-performance web server that will serve as the backbone of our WordPress installation. To install Nginx, use the command below:

apt-get install nginx

After the installation is complete, start Nginx and enable it to start automatically upon system boot with the following commands:

systemctl start nginx
systemctl enable nginx

You can verify the status of Nginx by running:

systemctl status nginx

Step 3: Installing PHP and MariaDB Server

Next, we need to install PHP and MariaDB, which are essential components for running WordPress. Use the following command to install PHP, PHP-FPM, and MariaDB packages:

apt-get install php php-mysql php-fpm php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip mariadb-server mariadb-client

Once the installation is complete, start MariaDB and enable it to start automatically upon system boot:

systemctl start mariadb
systemctl enable mariadb

You can verify the status of MariaDB by running:

systemctl status mariadb

To enhance security, it’s recommended to run the MySQL secure installation script:

mysql_secure_installation

This script will guide you through securing your MariaDB installation by setting a root password and removing unnecessary default users and databases.

Step 4: Creating a Database for WordPress

Now, let’s create a database for our WordPress installation. Start by logging into MySQL:

mysql -u root -p

Replace password with your actual MariaDB root password when prompted. Once logged in, execute the following commands to create a new database and user for WordPress:

CREATE DATABASE wordpress_db;
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Make sure to replace password with a strong password of your choice.

Step 5: Downloading and Installing WordPress

With the preliminary setup complete, we can now download and install WordPress. Use the following commands:

wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
tar -xzvf/tmp/wordpress.tar.gz -C /var/www/html

Next, we need to adjust the permissions of the WordPress directory:

chown -R www-data:www-data /var/www/html/wordpress
chmod -R 755 /var/www/html/wordpress

Step 6: Creating an Nginx Virtual Host

To configure Nginx for hosting our WordPress site, we’ll create a virtual host. Open the Nginx configuration file for WordPress:

nano /etc/nginx/conf.d/wordpress.conf

Add the following configuration to the file:

server {
listen 80;
listen [::]:80;
root /var/www/html/wordpress;
index index.php index.html index.htm;
error_log /var/log/nginx/wordpress_error.log;
access_log /var/log/nginx/wordpres_access.log;
client_max_body_size 100M;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

Save the file and exit the text editor.

To enable the virtual host, remove the default server block:

rm /etc/nginx/sites-enabled/default
rm /etc/nginx/sites-available/default

Finally, test the Nginx configuration for any syntax errors:

nginx -t

If everything is fine, reload Nginx to apply the changes:

systemctl reload nginx

Step 7: Completing the WordPress Installation

Now that all the necessary components are in place, we can finish the WordPress installation through a web browser.

Open your favorite web browser and navigate to http://your_server_ip. You will be greeted with the WordPress installation page. Provide the requested information, including the database details we set up earlier.

Click on the “Run the installation” button, and WordPress will complete the installation process. Once the installation is successful, you can log in to your WordPress dashboard using the credentials you specified during the installation.

Congratulations! You have successfully installed WordPress on your Debian 11 system with the LEMP stack.

Conclusion

In this comprehensive guide, we walked you through the step-by-step process of installing WordPress on a Debian 11 system using the LEMP stack. By following these instructions, you can set up a powerful and secure environment for your WordPress site.

Remember that choosing the right hosting provider is crucial for the optimal performance and reliability of your WordPress site. Shape.host offers premium Cloud VPS hosting services, providing scalable and secure solutions for your website needs. With Shape.host, you can focus on creating amazing content while leaving the technical aspects to the experts.