WordPress is a massive content management system used by millions of websites worldwide. If you’re on Debian 12 and want to install WordPress, this guide will walk you through it in a step-by-step, beginner-friendly way.
Whether you’re a developer or a small business owner, this will help you install WordPress on Debian 12 in no time.
How to Install WordPress on Debian 12:
Requirements
Before you begin, ensure you have the following:
- A Debian 12 Server: Ensure your server is running the latest version of Debian 12 with SSH access.
- Domain Name and DNS Settings: Have a domain pointed to your server’s IP address.
- LAMP Stack Installed: Install Linux, Apache, MySQL/MariaDB, and PHP (referred to as the LAMP stack).
- Root or Sudo User Access: Access to a user with sudo privileges for executing administrative tasks.
Step 1: Update and Upgrade Your Server
- Always start by ensuring your system is up-to-date. Run the following commands:
apt update && sudo apt upgrade -y
Bash
This will update the package list and upgrade the installed packages.
Step 2: Install Apache Web Server
- Apache is one of the most popular web servers for hosting WordPress. To install it, type:
apt install apache2 -y
Bash
- Enable and start the Apache service:
systemctl enable apache2
systemctl start apache2
Bash
- Check if Apache is running by visiting your server’s IP address in a web browser. You should see the default Apache welcome page.
Step 3: Install PHP
- WordPress requires PHP to function. Install PHP and necessary extensions:
apt install php php-mysql libapache2-mod-php php-cli php-curl php-xml php-mbstring -y
Bash
- Verify the PHP installation:
php -v
Bash
This will display the PHP version.
Step 4: Install MySQL and Create a Database
- WordPress needs a database to store its content. Install MySQL server:
apt install mysql-server -y
Bash
- Secure the MySQL installation by running:
mysql_secure_installation
Bash
During the process, set a root password and follow the prompts to improve security.
- Log in to MySQL:
mysql -u root -p
- Create a database and user for WordPress:
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
SQL
Step 5: Download WordPress
- Navigate to your web server’s root directory:
cd /var/www/html
Bash
- Download the latest WordPress package:
wget https://wordpress.org/latest.zip (Online)
or download local network LAB SMKN 1 MAJALAYA (Offline)
wget http://192.168.106.252/comot/wrd.zip
Bash
- Extract the archive:
chmod +x wrd.zip
unzip wrd.zip
Bash
- Move the WordPress files to the root directory:
mv wordpress/* /var/www/html/
Bash
- Set proper permissions:
chown -R www-data:www-data /var/www/html
chmod -R 755 /var/www/html
Bash
Step 6: Configure Apache
- Create a virtual host file for WordPress:
nano /etc/apache2/sites-available/wordpress.conf
Bash
- Add the following configuration:
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/html
<Directory /var/www/html>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Apache Configuration
- Enable the virtual host and Apache rewrite module:
a2ensite wordpress.conf
a2enmod rewrite
Bash
- Restart Apache:
systemctl restart apache2
Bash
Step 7: Configure WordPress
Visit your domain or ip address in a web browser. You’ll be greeted by the WordPress setup wizard.
- Select your language.
- Enter your database details:
- Database Name: wordpress
- Username: wpuser
- Password: yourpassword
- Click Submit and then Run the Installation.
Provide site details like your website title, admin username, and password. Once complete, log in to your WordPress admin panel.