Setting up a LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) on Debian 12 and installing WordPress can be a straightforward process when you follow the right steps. This guide will walk you through it with minimal explanations.
While performing a minimal install of Debian 12, I’ve opted to select the web server and ssh server options.
If you haven’t installed Apache, then use these commands:
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2
Step 1: Install MariaDB
First, install MariaDB, which will serve as the database for WordPress:
sudo apt update
sudo apt install mariadb-server mariadb-client
Step 2: Secure MariaDB
After installing MariaDB, it’s crucial to secure it. Run the secure installation script:
sudo mysql_secure_installation
Important: If this is your first time securing MySQL, then don’t rush this step as you will want to enter a root password so that you can log in later when you use phpmyadmin.
Step 3: Install PHP
WordPress requires PHP to run. Install PHP and necessary extensions:
sudo apt install php libapache2-mod-php php-mbstring php-xml php-gd php-curl
Step 4: Install phpMyAdmin
phpMyAdmin is a web-based tool to manage your MariaDB databases. Install it with:
sudo apt install phpmyadmin
During the installation, you’ll be asked to configure the database for phpMyAdmin. Choose Yes
to use the existing MariaDB database
Step 5: Install WordPress
Now, install WordPress. Download the latest WordPress package and extract it:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
sudo mv wordpress /var/www/html/
sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress
Step 6: Configure Apache
Set up Apache to serve your WordPress site. Create a new virtual host configuration file:
sudo nano /etc/apache2/sites-available/wordpress.conf
Add the following configuration:
<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
DocumentRoot /var/www/html/wordpress
ServerName yourdomain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the new site configuration and restart Apache:
sudo a2ensite wordpress.conf
sudo systemctl restart apache2
Step 7: Complete WordPress Installation
Navigate to http://localhost/websitename
in your browser and follow the WordPress installation wizard to complete the setup.