Install a LEMP Server on Debian Bookworm
To run a WordPress website, you need a server with the required services pre-installed. A low-cost VPS is usually enough for small or new sites, and Debian 12 (Bookworm) is a solid base for a lightweight LEMP stack.
This guide uses the root user. If you want to run commands with a normal user (for example debian), run the following first as root:
usermod -aG sudo username
exec su -l username
Replace username with your actual account name.
1. L - Linux
Install Debian 12 (Bookworm) on your VPS.
2. E - Install Nginx
apt update
apt install -y nginx-full
After installation, open your browser:
http://your-domain-or-ip
3. M - Install and Configure MariaDB
apt update
apt install -y mariadb-server
mysql_secure_installation
Log in to MariaDB as root:
mysql -u root
If your root account authentication method needs to be switched to password-based auth, run:
USE mysql;
UPDATE user SET plugin='mysql_native_password' WHERE User='root';
FLUSH PRIVILEGES;
EXIT;
Restart MariaDB:
systemctl restart mariadb
Optional backup for a custom MariaDB config file:
mv /etc/mysql/conf.d/mysql.cnf /etc/mysql/conf.d/mysql.cnf.backup
Then create your own /etc/mysql/conf.d/mysql.cnf if you need custom tuning.
4. P - Install and Configure PHP 8.2 (FPM)
On Debian 12 (Bookworm), the default PHP version is 8.2.
apt install -y php8.2-fpm php8.2-mysql php8.2-zip php8.2-xml php8.2-curl php8.2-gd
Check PHP-FPM status:
systemctl status php8.2-fpm.service
Backup and edit the main PHP-FPM configuration:
mv /etc/php/8.2/fpm/php.ini /etc/php/8.2/fpm/php.ini.backup
nano /etc/php/8.2/fpm/php.ini
systemctl restart php8.2-fpm
5. Configure Nginx to Use PHP-FPM
Backup the default Nginx virtual host file:
mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
Create a new /etc/nginx/sites-available/default with your server block and PHP-FPM settings. Make sure the PHP socket matches PHP 8.2:
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
Restart Nginx:
systemctl restart nginx
Create a test file to verify Nginx + PHP:
mkdir -p /srv/www
nano /srv/www/test.php
<?php
phpinfo();
Open in browser:
http://your-domain-or-ip/test.php
6. Create a Database for WordPress
Create a database skywirex, user skywire, and grant permissions:
mysql -u root
CREATE DATABASE skywirex CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'skywire'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON skywirex.* TO 'skywire'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Your VPS is now ready for WordPress installation.
7. Remove Components (Optional)
If you need to remove Nginx and reinstall from scratch:
apt remove nginx-full nginx-common
apt purge nginx-full nginx-common
apt autoremove
Bonus: WordPress Permissions
Assuming your website root is /srv/www:
chown root:www-data -R /srv/www/wp-content/*
cd /srv/www/wp-content
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;