Step-by-Step Guide to Setting Up a VPS for WordPress Hosting

📝 Step-by-Step Guide to Setting Up a VPS for WordPress Hosting

Setting up a WordPress site on a VPS can give you superior performance, flexibility, and control compared to shared hosting. In this guide, we’ll walk you through the complete WordPress VPS setup—from server configuration to security and optimization.

Whether you’re using a LAMP stack (Linux, Apache, MySQL, PHP) or a LEMP stack (Linux, NGINX, MySQL/MariaDB, PHP), this guide has you covered.


🔧 Step 1: Choose Your VPS and Access It

  • Select a VPS provider (e.g., BDIX VPS for Bangladesh users or International VPS for global audiences).
  • Recommended: Ubuntu 22.04 LTS
  • Connect via SSH: bashCopyEditssh root@your_server_ip

🧱 Step 2: Set Up the LAMP or LEMP Stack

Option A: LAMP Stack VPS Setup

bashCopyEditapt update && apt upgrade -y
apt install apache2 mysql-server php php-mysql libapache2-mod-php php-cli unzip -y

Option B: LEMP Stack VPS Setup

bashCopyEditapt update && apt upgrade -y
apt install nginx mysql-server php-fpm php-mysql unzip php-cli -y

🗄 Step 3: Secure MySQL and Create Database

mysql_secure_installation

Then log into MySQL:

mysql -u root -p

Create a WordPress database and user:

CREATE DATABASE wordpress_db;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

🌐 Step 4: Download and Configure WordPress

cd /var/www/
wget https://wordpress.org/latest.zip
unzip latest.zip
mv wordpress yourdomain.com
chown -R www-data:www-data /var/www/yourdomain.com
chmod -R 755 /var/www/yourdomain.com

⚙️ Step 5: Configure Apache or NGINX

Apache Virtual Host:

nano /etc/apache2/sites-available/yourdomain.com.conf

Paste:

<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/yourdomain.com
<Directory /var/www/yourdomain.com>
AllowOverride All
</Directory>
</VirtualHost>

Then:

a2ensite yourdomain.com.conf
a2enmod rewrite
systemctl reload apache2

NGINX Server Block:

nano /etc/nginx/sites-available/yourdomain.com

Paste:

server {
listen 80;
server_name yourdomain.com;
root /var/www/yourdomain.com;

index index.php index.html;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}

location ~ /\.ht {
deny all;
}
}

Then:

ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx

🔐 Step 6: Install SSL (Let’s Encrypt)

apt install certbot python3-certbot-apache  # For Apache
certbot --apache -d yourdomain.com

# OR for NGINX:
apt install certbot python3-certbot-nginx
certbot --nginx -d yourdomain.com

Set up auto-renewal:

crontab -e
# Add:
0 0 * * * /usr/bin/certbot renew --quiet

🧠 Step 7: Complete WordPress Installation via Browser

Go to http://yourdomain.com or https://yourdomain.com, and follow the on-screen setup:

  • Choose Language
  • Add Database Details
  • Set Admin Account
  • Complete Installation

🚀 Step 8: Optimization Tips for VPS Hosting

  • Enable Caching (e.g., WP Super Cache, LiteSpeed Cache)
  • Use a CDN (e.g., Cloudflare for global sites)
  • Use PHP-FPM & OPcache for performance
  • Secure SSH access (change port, disable root login, use keys)
  • Limit login attempts on WordPress

✅ Final Thoughts

Setting up WordPress on your own VPS gives you performance and control—but it also comes with responsibility. If you’re a beginner, start with a Managed VPS, and let the provider handle the technical side. For developers or power users, an Unmanaged LAMP or LEMP VPS offers limitless possibilities.


Scroll to Top
RangpurColo
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.