Debian 9 WordPress Installation: Secure LAMP (Apache, MariaDB, PHP)
What will you learn in this guide?
In this guide, you will learn how to install WordPress securely using the LAMP architecture on a Debian 9 server.
Database creation, Apache configuration, file permissions and security keys are explained step by step.
🧠 Technical Summary
Main topic: Installing WordPress with LAMP on Debian 9
Purpose: To release WordPress on a stable, secure and widely supported infrastructure
Approach:
- Creating MariaDB database and user
- Installing required PHP extensions
- Configuring Apache for
.htaccessand permalink - Installing WordPress files
- Adjust file permissions and security settings
- Complete the installation from the web interface
🛠 Prerequisites
- A Cloud Server (Instance) running Debian 9
- Non-root user with sudo authority
- LAMP stack installed (Apache, MariaDB, PHP)
- Domain name (example:
ornek.com) - SSL configuration
- If there is a domain name: Let's Encrypt
- If it is a test environment: Self-Signed SSL
1️⃣ Creating MariaDB Database and User
WordPress stores all content and user data on MariaDB.
1. Log in to the MariaDB instance
sudo mariadb
- This command opens the MariaDB root account.
- Create the WordPress database
CREATE DATABASE genixnode_site DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
- This database will be used by WordPress.
- Create and authorize custom user
GRANT ALL ON genixnode_site.* TO 'genixnode_wpuser'@'localhost' IDENTIFIED BY 'guclu_sifreniz';
- This user can only access the WordPress database.
- Apply authorizations and exit
FLUSH PRIVILEGES;
EXIT;
- This step activates the database settings.
2️⃣ Installing Required PHP Extensions
WordPress and plugins need additional PHP modules.
- Update package list
sudo apt update
- This command refreshes system packages.
- Install PHP extensions
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
- These packages are required for WordPress functions.
3️⃣ Adapting Apache Configuration to Compatible with WordPress
WordPress uses .htaccess and permalink structure.
- Open the site configuration file
sudo nano /etc/apache2/sites-available/genixnode.conf
- This file contains Apache settings for your domain.
- Allow the use of .htaccess
<Directory /var/www/wordpress/>
AllowOverride All
</Directory>
- This setting is required for WordPress plugins.
- Enable Rewrite module
sudo a2enmod rewrite
- This module activates the permalink structure.
- Test the configuration and restart Apache
sudo apache2ctl configtest
sudo systemctl restart apache2
- This applies Apache settings.
4️⃣ Downloading and Installing WordPress Files
- Download and extract WordPress
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
- This command downloads the current version of WordPress.
- Prepare the necessary files
touch /tmp/wordpress/.htaccess
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
mkdir /tmp/wordpress/wp-content/upgrade
- This step is required for WordPress updates.
- Move files to web root
sudo cp -a /tmp/wordpress/. /var/www/wordpress
- This process prepares WordPress for publication.
5️⃣ File Permissions and Security Settings
- Set file ownership
sudo chown -R www-data:www-data /var/www/wordpress
- This setting allows Apache to access files.
- Edit directory and file permissions
sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;
- These permissions are recommended for security.
- Generate security keys
curl -s https://api.wordpress.org/secret-key/1.1/salt/
- These keys increase session security.
- Edit the configuration file
sudo nano /var/www/wordpress/wp-config.php
- Enter database and file system settings
define('DB_NAME', 'genixnode_site');
define('DB_USER', 'genixnode_wpuser');
define('DB_PASSWORD', 'guclu_sifreniz');
define('FS_METHOD', 'direct');
- This setting allows updates without asking FTP.
6️⃣ Completing the Setup Via the Web Interface
- From the browser, navigate to your domain or IP address:
https://alanadiniz.com
- Select the language, enter the site information and complete the installation. After installation, you will be directed to the WordPress administration panel.
❓ Frequently Asked Questions (FAQ)
1. What is the difference between LAMP and LEMP? Apache is modular, Nginx is lighter.
2. Why is MariaDB preferred? It is MySQL compatible and default in Debian.
3. What does .htaccess do? Provides URL redirection and security rules.
4. Why file permissions 750 and 640? Provides maximum security with minimum permissions.
5. Is SSL required? Recommended for SEO and user trust.
🎯 Result
With this guide, you have established a secure, stable and production-ready WordPress infrastructure on Debian 9. Apache compatibility, MariaDB database and PHP support are provided together.
👉 You can create a Cloud Server on the GenixNode platform in minutes and implement this WordPress/LAMP installation immediately.

