
WordPress runs at its best when it has room to move like a disciplined warrior. On a VPS, you control the stack, the resources, and the speed. Below is a clean, fast AlmaLinux build using either NGINX + PHP-FPM or Apache + PHP, with MariaDB, SSL, and hardening.
Step 0: Patch and Prepare
sudo dnf clean all
sudo dnf update -y
sudo rebootStep 1: Install Web Stack
Option A – NGINX + PHP-FPM
sudo dnf install nginx php php-fpm php-mysqlnd php-cli php-gd php-xml php-mbstring php-json -y
sudo systemctl enable nginx --now
sudo systemctl enable php-fpm --now
# Basic PHP-FPM hardening
sudo sed -i 's/^;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php.ini
sudo systemctl restart php-fpmOption B – Apache (httpd) + PHP
sudo dnf install httpd php php-mysqlnd php-cli php-gd php-xml php-mbstring php-json -y
sudo systemctl enable httpd --nowMariaDB (for both options)
sudo dnf install mariadb-server -y
sudo systemctl enable mariadb --now
sudo mysql_secure_installationStep 2: Create the WordPress Database
mysql -u root -p
CREATE DATABASE wpdojo DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'STRONG_PASSWORD_HERE';
GRANT ALL PRIVILEGES ON wpdojo.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;Step 3: Fetch WordPress & Set Permissions
cd /var/www
sudo curl -O https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz
sudo mv wordpress dojo
cd dojo
sudo cp wp-config-sample.php wp-config.php
sudo sed -i "s/database_name_here/wpdojo/" wp-config.php
sudo sed -i "s/username_here/wpuser/" wp-config.php
sudo sed -i "s/password_here/STRONG_PASSWORD_HERE/" wp-config.php
# Salts
curl -s https://api.wordpress.org/secret-key/1.1/salt/ | sudo tee -a wp-config.php > /dev/nullStep 4: Configure the Web Server
NGINX server block
sudo nano /etc/nginx/conf.d/dojo.conf
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/dojo;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi.conf;
}
location ~* \.(log|txt|md)$ { deny all; }
}
sudo nginx -t && sudo systemctl reload nginxApache vhost
sudo nano /etc/httpd/conf.d/dojo.conf
ServerName yourdomain.com
ServerAlias www.yourdomain.com
DocumentRoot /var/www/dojo
AllowOverride All
Require all granted
ErrorLog /var/log/httpd/dojo_error.log
CustomLog /var/log/httpd/dojo_access.log combined
sudo systemctl reload httpdStep 5: Firewall & SELinux
sudo systemctl enable firewalld --now
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
# Allow outbound calls (updates, APIs)
sudo setsebool -P httpd_can_network_connect onStep 6: Free SSL (Let’s Encrypt)
# NGINX:
sudo dnf install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
# Apache:
sudo dnf install certbot python3-certbot-apache -y
sudo certbot --apache -d yourdomain.com -d www.yourdomain.comStep 7: Finish WordPress Install
Browse to http://yourdomain.com to complete the setup wizard. Choose a strong admin password and install only essential plugins.
Performance & Hardening Tips
- Enable page/object caching and image optimization.
- Restrict wp-admin by IP or use 2FA.
- Schedule updates and backups; verify restores monthly.
Need It Done For You?
Prefer a tuned WordPress stack with professional care? Our Managed WordPress Hosting handles caching, updates, backups, security and speed. For bespoke builds or migrations, talk to our WordPress Experts. Need help at the server layer? Advanced IT Support is your clan.
The Ninja Way
Fast setup, disciplined hardening, clean configs. That’s how you keep WordPress quick and quiet on a VPS. When you’re ready to scale, move to NinjaWeb VPS Hosting and we’ll keep your dojo battle-ready.
