As a System Administrator, I know that choosing the right web hosting stack is the foundation of a high-performing and scalable website. While Apache is common, the speed and efficiency of Nginx for serving static content and handling concurrent connections is unparalleled.
When paired with the robust MariaDB 11 database and PHP-FPM, you have a powerful platform known as the LEMP stack (Linux, Nginx, MariaDB, PHP) — perfect for dynamic applications like WordPress.
This hands-on guide will walk you through setting up a professional-grade WordPress server for your domain wordpress.masdzub.com, using MariaDB 11 and PHP 8.1 for optimal performance and stability.
Whether you’re a budding system administrator or an experienced developer, this guide provides clear, actionable steps to build your LEMP stack with confidence.
I. Server Preparation and Installing Nginx Webserver
Before diving into the core setup, make sure your Linux system is updated and ready. This guide assumes a Debian-based distribution (like Ubuntu Server), commonly used in production environments.
1. Updating the System and Installing Prerequisites
Start fresh by updating all system packages:
sudo apt updatesudo apt upgrade -y2. Installing Nginx (Engine X)
Nginx is the backbone of this setup. Its asynchronous, event-driven architecture ensures high performance under heavy loads.
sudo apt install nginx -ysudo systemctl start nginxsudo systemctl enable nginxFirewall Configuration (UFW)
If you’re using UFW (Uncomplicated Firewall), allow HTTP and HTTPS traffic:
sudo ufw allow 'Nginx Full'sudo ufw enableNow, test Nginx by visiting your server’s public IP — you should see the default Nginx welcome page.
II. Installing and Securing MariaDB 11 Database
MariaDB is a powerful, community-driven alternative to MySQL, optimized for performance and reliability — ideal for WordPress databases.
1. Adding the MariaDB 11 Repository
By default, Debian/Ubuntu may ship with older MariaDB versions (e.g., 10.6). To install MariaDB 11, add the official repository:
sudo apt install software-properties-common dirmngr apt-transport-https -ysudo curl -o /etc/apt/trusted.gpg.d/mariadb_release_signing_key.asc 'https://mariadb.org/mariadb_release_signing_key.asc'sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el,s390x] https://ftp.mariadb.org/repo/11.1/debian bullseye main'sudo apt updatesudo apt install mariadb-server -y2. Securing the MariaDB Installation
Lock down your new MariaDB instance for production use:
sudo mysql_secure_installationRespond “Y” to all prompts to set the root password, remove anonymous users, and disallow remote root login.
3. Creating the WordPress Database and User
Log in to MariaDB:
sudo mysqlThen create a dedicated database and user (replace YOUR_SECURE_PASSWORD with a strong password):
CREATE DATABASE masdzub_db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;CREATE USER 'masdzub_user'@'localhost' IDENTIFIED BY 'YOUR_SECURE_PASSWORD';GRANT ALL PRIVILEGES ON masdzub_db.* TO 'masdzub_user'@'localhost';FLUSH PRIVILEGES;EXIT;III. Installing and Configuring PHP 8.1 with PHP-FPM
WordPress runs on PHP, so you’ll need PHP-FPM (FastCGI Process Manager) to handle dynamic requests efficiently.
1. Installing PHP 8.1 and Required Extensions
sudo apt install php8.1-fpm php8.1-mysql php8.1-curl php8.1-gd php8.1-mbstring php8.1-xml php8.1-xmlrpc php8.1-soap php8.1-intl php8.1-zip -y2. Tuning PHP-FPM
Edit the PHP-FPM configuration file:
sudo nano /etc/php/8.1/fpm/php.iniFind and set:
cgi.fix_pathinfo=0This prevents Nginx from executing incorrect PHP files, improving security.
Restart PHP-FPM:
sudo systemctl restart php8.1-fpmPHP-FPM Optimization Tips
Increase limits for better WordPress performance:
memory_limit = 256Mupload_max_filesize = 64Mpost_max_size = 64MIV. Nginx Server Block Configuration for WordPress
Now, configure Nginx to handle your WordPress domain.
1. Creating the Document Root
sudo mkdir -p /var/www/wordpress.masdzub.com/public_htmlsudo chown -R www-data:www-data /var/www/wordpress.masdzub.com/sudo chmod -R 755 /var/www/wordpress.masdzub.com/2. Creating the Nginx Server Block
sudo nano /etc/nginx/sites-available/wordpress.masdzub.com.confPaste the configuration below:
server { listen 80; server_name wordpress.masdzub.com www.wordpress.masdzub.com; root /var/www/wordpress.masdzub.com/public_html; index index.php index.html index.htm;
location / { try_files $uri $uri/ /index.php?$args; }
location ~ /\. { deny all; }
location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.1-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
location ~* /(?:wp-config|readme|license)\.php { deny all; }}Enable the site and test the configuration:
sudo ln -s /etc/nginx/sites-available/wordpress.masdzub.com.conf /etc/nginx/sites-enabled/sudo nginx -tsudo systemctl reload nginxV. Installing and Configuring WordPress
1. Downloading and Extracting WordPress
cd /var/www/wordpress.masdzub.com/public_htmlsudo wget https://wordpress.org/latest.tar.gzsudo tar -xvzf latest.tar.gzsudo mv wordpress/* .sudo rm -rf wordpress latest.tar.gz2. Configuring wp-config.php
sudo mv wp-config-sample.php wp-config.phpsudo nano wp-config.phpUpdate your database credentials:
define( 'DB_NAME', 'masdzub_db' );define( 'DB_USER', 'masdzub_user' );define( 'DB_PASSWORD', 'YOUR_SECURE_PASSWORD' );Add your unique security keys from: 👉 https://api.wordpress.org/secret-key/1.1/salt/
3. Completing the Installation
Visit http://wordpress.masdzub.com and follow the WordPress installation wizard to configure your site name, admin credentials, and email.
VI. Best Practices and Sysadmin Insights
| Area | Actionable Advice | Sysadmin Insight |
|---|---|---|
| Security | Use a unique database user per site. Install an SSL certificate with Let’s Encrypt. | Limits attack surface and improves HTTPS reliability. |
| Performance | Enable Nginx FastCGI caching and use a CDN. | Reduces server load and speeds up content delivery. |
| Maintenance | Schedule automated backups and updates. | Critical for uptime and disaster recovery. |
Common Issues and Troubleshooting (FAQ)
Q: Why do I see a 404 error when visiting WordPress posts?
A: Ensure your try_files directive is set correctly in Nginx and reload the service using sudo systemctl reload nginx.
Q: Why is my site slow after setup?
A: Check the PHP-FPM log (/var/log/php8.1-fpm.log) and increase memory limits if needed. Consider enabling caching.
Conclusion: Mastering High-Performance WordPress Hosting
Congratulations! 🎉 You’ve successfully built a high-performance LEMP stack with Nginx, MariaDB 11, and PHP 8.1 — the ideal environment for secure and scalable WordPress hosting.
By following Nginx server block best practices and PHP-FPM optimization, your site wordpress.masdzub.com is now ready to handle real-world traffic with speed and reliability.