NinjaWeb

Contact Info

106 Anne rd Knoxfield 3180 Vic Australia

+61 (03) 82023009

info@ninjaweb.com.au

Contact us
Recommended Services
Supported Scripts
WordPress
Joomla
Drupal
Magento
Javascript
Angular
React
NodeJS
vps-security-best-practices

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 reboot

Step 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-fpm

Option 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 --now

MariaDB (for both options)

sudo dnf install mariadb-server -y
sudo systemctl enable mariadb --now
sudo mysql_secure_installation

Step 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/null

Step 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 nginx

Apache 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 httpd

Step 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 on

Step 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.com

Step 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.