DebianDebian Based

How To Install WordPress on Debian 12

Install WordPress on Debian 12

In this tutorial, we will show you how to install WordPress on Debian 12. WordPress, the world’s most popular content management system (CMS), powers millions of websites across the globe. Its user-friendly interface, extensive customization options, and a vast library of plugins and themes make it an ideal choice for bloggers, businesses, and developers alike.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the WordPress on Debian 12 (Bookworm).

Prerequisites

Before proceeding with the installation, make sure your Debian 12 system meets the following requirements:

  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • Familiarity with basic terminal commands will help you follow the installation steps.
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • A user account with sudo privileges to execute administrative commands.

Install WordPress on Debian 12

Step 1. Update Your System Package.

To begin, it’s crucial to update your system packages to their latest versions. This ensures that you have access to the most recent security patches and bug fixes. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade

These commands will update the package list and upgrade all installed packages to their latest versions.

Step 2. Installing Apache Web Server

Apache is a robust and widely-used web server that will handle HTTP requests for your WordPress site. To install Apache on your Debian 12 server, run the following command:

sudo apt install apache2

Once the installation is complete, start the Apache service and enable it to start automatically on system boot:

sudo systemctl start apache2
sudo systemctl enable apache2

To verify that Apache is running correctly, open a web browser and enter your server’s IP address. You should see the default Apache landing page.

Step 3. Install MySQL/MariaDB.

WordPress uses a database to store all its content, settings, and user information. We’ll install MariaDB, a popular open-source fork of MySQL, as our database server. To install MariaDB, run the following command:

sudo apt install mariadb-server

After the installation is complete, it’s essential to secure your database server. Run the following command to launch the MariaDB security script:

sudo mysql_secure_installation

Follow the prompts to set a strong root password, remove anonymous users, disable remote root login, and remove the test database. This step ensures that your database server is secure and ready for production use.

Next, log in to the MariaDB shell using the root account:

sudo mysql -u root -p

Enter the root password you set earlier. Once logged in, create a new database and user for WordPress:

CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace ‘your_strong_password‘ with a secure password of your choice.

Step 4. Install PHP

PHP is the programming language that powers WordPress. To install PHP and the necessary extensions for WordPress, run the following command:

sudo apt install php libapache2-mod-php php-mysql

This command installs PHP, the Apache PHP module, and the PHP MySQL extension. To verify that PHP is installed correctly, create a test file in the Apache root directory:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Open a web browser and visit http://your_server_ip/info.php. You should see the PHP configuration page displaying your server’s PHP settings.

Step 5. Download and Configure WordPress.

Now that we have our LAMP stack set up, it’s time to download and configure WordPress. Change to a temporary directory and download the latest version of WordPress using wget:

cd /tmp
wget https://wordpress.org/latest.tar.gz

Extract the downloaded archive and move the WordPress files to the Apache root directory:

tar xvf latest.tar.gz
sudo mv wordpress /var/www/html/

Set the appropriate permissions on the WordPress directory to allow Apache to read and write files:

sudo chown -R www-data:www-data /var/www/html/wordpress

Next, create a copy of the WordPress sample configuration file:

cd /var/www/html/wordpress
cp wp-config-sample.php wp-config.php

Open the wp-config.php file in a text editor:

sudo nano wp-config.php

Locate the following lines and replace the placeholder values with your database information:

define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'your_strong_password' );

Save the changes and exit the text editor.

Step 6. Configure Apache for WordPress.

To configure Apache to serve your WordPress site, create a new virtual host file:

sudo nano /etc/apache2/sites-available/wordpress.conf

Add the following configuration:

<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/html/wordpress
<Directory /var/www/html/wordpress>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Replace yourdomain.com with your actual domain name. Save the changes and exit the text editor.

Enable the new site and the Apache rewrite module:

sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Your WordPress site should now be accessible via http://yourdomain.com.

Step 7: Secure WordPress with HTTPS.

To ensure secure communication between your WordPress site and its visitors, it’s crucial to enable HTTPS. We’ll use Let’s Encrypt, a free and open certificate authority, to obtain an SSL certificate for your domain.

First, install the Certbot client and the Apache plugin:

sudo apt install certbot python3-certbot-apache

Next, run Certbot to obtain and install the SSL certificate:

sudo certbot --apache

Follow the prompts to provide your email address, agree to the Let’s Encrypt terms of service, and choose your domain name. Certbot will automatically configure Apache to use the SSL certificate and redirect HTTP traffic to HTTPS.

To test your SSL configuration and set up automatic certificate renewals, run:

sudo certbot renew --dry-run

Step 8: Complete WordPress Installation

With your WordPress site now accessible via HTTPS, it’s time to complete the installation through the web interface. Open a browser and visit https://yourdomain.com. You’ll be greeted by the WordPress setup wizard.

Install WordPress on Debian 12

 

Follow the on-screen instructions to choose your language, provide a site title, and create an admin user account. Once you’ve completed the setup, log in to the WordPress dashboard using your newly created admin credentials.

Congratulations! You have successfully installed WordPress. Thanks for using this tutorial to install the latest version of WordPress on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official WordPress website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button