Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install WordPress on Debian

Set up Apache, MariaDB and PHP, create a database and install WordPress with a virtual host.

WordPress2 min read6 steps

What you need

  1. A Debian server or virtual machine with root access.
  2. Basic Linux command-line skills.
  3. A domain name that points to the server IP.

Step 1: Install the LAMP stack

Apache

sudo apt update
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2

MariaDB (the MySQL replacement in Debian)

sudo apt install mariadb-server
sudo mysql_secure_installation

PHP

sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-xml php-mbstring php-zip
sudo systemctl restart apache2

Step 2: Create the database and user

sudo mysql
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace your_password with a strong password.

Step 3: Download WordPress

cd /tmp
wget https://wordpress.org/latest.tar.gz
tar xf latest.tar.gz
sudo mv wordpress /var/www/html/wordpress

Set the database details:

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

Change these lines:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');

Set the owner:

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

Step 4: Create the Apache virtual host

sudo nano /etc/apache2/sites-available/wordpress.conf
<VirtualHost *:80>
    ServerName your_domain.com
    ServerAlias www.your_domain.com
    DocumentRoot /var/www/html/wordpress

    <Directory /var/www/html/wordpress>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Replace your_domain.com with your domain. Then enable it:

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

Step 5: Run the installer

Open your domain in a browser. Enter the site title, admin username, password and email, then click Install WordPress.

Step 6: Log in

Go to http://your_domain.com/wp-admin and start building your site.

Security and speed tips

  1. Update WordPress, themes and plugins often.
  2. Install an SSL certificate and use HTTPS.
  3. Use caching, optimized images and a CDN.

Quick recap

  • Install Apache, MariaDB and PHP, create a database.
  • Download WordPress, set wp-config.php and the virtual host.
  • Finish in the browser.