
Why Install WordPress on a VPS Instead of Shared Hosting?
If you have used WordPress on shared hosting before, you know the limitations: resources shared among many users cause slowdowns during traffic spikes, you cannot install custom software, and a compromised neighbor site can affect your own. A VPS gives you a fully isolated environment with dedicated resources and root-level control.
With a VPS you choose the PHP version, allocate RAM, install any package you need, and scale on demand. Performance is significantly better, making VPS the right choice for any WordPress site with growth ambitions.
AsiaGB VPS: Starting at 500 THB/month with Full Root Access, Linux (Ubuntu/CentOS/Debian) support, and data centers in Thailand and Singapore — ideal for hosting WordPress.
Prerequisites
- A Linux VPS (Ubuntu 22.04 or CentOS 8+ recommended)
- Your VPS IP address and root password
- An SSH client: Terminal on macOS/Linux or PuTTY on Windows
- A domain name pointed to your VPS IP
Step 1: SSH into Your VPS
Open a terminal and connect to your VPS:
ssh root@YOUR_VPS_IP
Once connected, update all system packages before proceeding:
Ubuntu: apt update && apt upgrade -y
CentOS: yum update -y
Step 2: Install the LAMP Stack (Apache + MySQL + PHP)
Install Apache Web Server
Ubuntu: apt install apache2 -y
CentOS: yum install httpd -y && systemctl enable httpd && systemctl start httpd
Install MySQL / MariaDB
Ubuntu: apt install mysql-server -y
CentOS: yum install mariadb-server mariadb -y && systemctl enable mariadb && systemctl start mariadb
After installation run mysql_secure_installation to set a root password and harden your database server.
Install PHP
Ubuntu: apt install php php-mysql php-curl php-gd php-mbstring php-xml php-zip libapache2-mod-php -y
CentOS: yum install php php-mysqlnd php-curl php-gd php-mbstring php-xml php-zip -y
Step 3: Create a WordPress Database
Log in to MySQL and create a dedicated database and user for WordPress:
mysql -u root -p
CREATE DATABASE wordpress_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 4: Download and Place WordPress Files
Download the latest WordPress release and move it to your web root:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
mv wordpress /var/www/html/
chown -R www-data:www-data /var/www/html/wordpress
chmod -R 755 /var/www/html/wordpress
Step 5: Configure wp-config.php
Copy the sample config file and edit it with your database credentials:
cd /var/www/html/wordpress
cp wp-config-sample.php wp-config.php
nano wp-config.php
Update the following constants to match what you created earlier:
DB_NAME→wordpress_dbDB_USER→wp_userDB_PASSWORD→StrongPassword123!DB_HOST→localhost
Step 6: Configure Apache Virtual Host
Create a Virtual Host configuration file for your domain, then enable it with a2ensite yourdomain.com.conf && systemctl reload apache2. This tells Apache which directory to serve when your domain is requested.
Step 6b: Configure Firewall and Basic Server Security
Before exposing your WordPress site to the internet, configure a firewall to block unnecessary ports and reduce your attack surface. A locked-down server is the first line of defense for any public-facing website.
# Ubuntu — install and configure UFW
apt install ufw -y
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
# Verify status
ufw status
# CentOS — use firewalld
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
Install Fail2Ban to automatically block IP addresses that make repeated failed login attempts on SSH and the WordPress login page:
# Install Fail2Ban
apt install fail2ban -y # Ubuntu
yum install fail2ban -y # CentOS
# Enable and start the service
systemctl enable fail2ban
systemctl start fail2ban
Step 7: Complete the WordPress Setup in Your Browser
Open a browser and navigate to http://yourdomain.com/wordpress or http://YOUR_VPS_IP/wordpress to run the WordPress installation wizard:
- Select your language
- Enter site title, admin username, password, and email
- Click "Install WordPress"
- Log in at
/wp-admin
Tip: After setup, install a free SSL certificate via Let's Encrypt and Certbot to enable HTTPS. This improves both security and SEO rankings.
Optimizing WordPress Performance on Your VPS
Once WordPress is running, tuning the server stack unlocks performance gains that shared hosting cannot offer. The two most impactful changes are enabling PHP OPcache and optionally adding Redis as an object cache.
Enable PHP OPcache
# OPcache ships with PHP — edit php.ini to activate it
nano /etc/php/8.1/apache2/php.ini
# Recommended settings
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.revalidate_freq=2
# Apply changes
systemctl restart apache2
Add Redis Object Cache (Recommended for High Traffic)
# Ubuntu
apt install redis-server php-redis -y
systemctl enable redis-server
systemctl start redis-server
# Confirm Redis is running
redis-cli ping # Expected response: PONG
After installing Redis, install the "Redis Object Cache" plugin from the WordPress plugin directory, then click Enable Object Cache in the plugin settings. This stores database query results in memory so repeat page loads skip the database entirely, significantly reducing server load.
LAMP vs LEMP for WordPress on a VPS
| Feature | LAMP (Apache) | LEMP (Nginx) |
|---|---|---|
| Setup complexity | Easier | Requires more knowledge |
| .htaccess support | ✓ Works out of the box | ✗ Must convert to Nginx config |
| Static file serving | Good | Faster |
| Concurrent connections | Good | Better (event-driven) |
| WordPress plugin compatibility | Full compatibility | Some plugins need config adjustments |
| Best for | Beginners and standard sites | High-traffic sites needing performance |
Summary
Installing WordPress on a Linux VPS follows a clear path: SSH → LAMP Stack → Database → WordPress Files → wp-config → Virtual Host → Browser Wizard. With Full Root Access on an AsiaGB VPS, you control every aspect of your WordPress environment for maximum performance and flexibility, starting at just 500 THB/month.
Ready to Launch Your WordPress VPS?
Linux VPS starting at 500 THB/month. Full Root Access. Data centers in Thailand and Singapore.
View VPS Plans