Your own VPS gives you full control over WordPress: choice of PHP version, Redis cache, HTTP/2, no restrictions on plugins or resources.
Step 1: LEMP stack (Nginx + MySQL + PHP)
sudo apt update
sudo apt install -y nginx mysql-server php8.2-fpm php8.2-mysql php8.2-xml php8.2-mbstring php8.2-curl php8.2-gd php8.2-zip php8.2-imagick php8.2-redis
Step 2: Database
sudo mysql -u root -p
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
Step 3: Download WordPress
cd /var/www
sudo wget https://wordpress.org/latest.tar.gz
sudo tar xzf latest.tar.gz
sudo mv wordpress yourdomain.com
sudo chown -R www-data:www-data yourdomain.com
Step 4: Nginx config
sudo nano /etc/nginx/sites-available/yourdomain.com
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/yourdomain.com;
index index.php;
location / { try_files $uri $uri/ /index.php?$args; }
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Step 5: SSL with Let's Encrypt
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Common Errors When Installing WordPress on a VPS
Error establishing a database connection
502 Bad Gateway
connect() to unix:/run/php/php8.2-fpm.sock failed (13: Permission denied)
The uploaded file exceeds the upload_max_filesize directive
| Message | Cause | Fix |
|---|---|---|
| Error establishing a database connection | Wrong credentials in wp-config.php, or MySQL isn't running | Check systemctl status mysql and compare DB_USER/DB_PASSWORD with what you created in Step 2 |
| 502 Bad Gateway | Nginx can't reach PHP-FPM — the socket doesn't match, or the daemon isn't running | Check systemctl status php8.2-fpm and the socket path in fastcgi_pass |
| connect() to unix:/run/php/php8.2-fpm.sock failed (13: Permission denied) | Nginx runs as www-data, but the PHP-FPM socket was created with different permissions | In the PHP-FPM pool, set listen.owner = www-data and listen.group = www-data |
| The uploaded file exceeds the upload_max_filesize directive | The php.ini upload limit is smaller than the theme, plugin, or media file | Raise upload_max_filesize and post_max_size in the PHP-FPM config, restart the service |
Managed Hosting vs. Your Own VPS
| Parameter | VPS with a manual install | Managed WordPress hosting |
|---|---|---|
| Choice of PHP version | Any, installed by hand | Limited to what the plan offers |
| Redis and cache setup | Full control, custom parameters | Often already built in, but without fine-tuning |
| Time to the first live site | 30–60 minutes following this guide | 5–10 minutes via an auto-installer |
| Responsibility for OS and PHP updates | Entirely on the administrator | Handled by the hosting provider |
If a manual setup is overkill for the task, installing through a hosting panel is covered in the article WordPress in cPanel.
When Installing WordPress on a Bare VPS Isn't Worth It
- No Linux administration experience and no time to gain it — if php-fpm or Nginx breaks, the site goes down completely, and recovery without a panel is harder
- The site is simple (a brochure page, a blog) with no real load — the extra cost of administering a VPS won't pay off; regular shared hosting handles this just as well
- You need automatic security updates without manual intervention — on a VPS, PHP and kernel updates have to be tracked yourself
- The team is used to a cPanel or ISPmanager interface for everyday tasks (mail, backups, domains) — on a bare VPS all of that has to be done from the console
Verifying the Installation
# Nginx and PHP-FPM are up and active
systemctl is-active nginx php8.2-fpm mysql
# Nginx config syntax is valid
sudo nginx -t
# The site responds with 200, not 502/500
curl -o /dev/null -s -w '%{http_code}\n' http://yourdomain.com/
- Open
http://yourdomain.com— the five-step WordPress setup wizard should appear, not a PHP error - Go through the wizard, enter the site name and admin details, then log in at
/wp-admin/ - Check that SSL actually works:
curl -I https://yourdomain.com/should return 200, not a certificate error - Make sure WordPress's background jobs (wp-cron) run — publish a scheduled post and check it goes live on time
After installation, set up regular backups — unlike hosting panels, a bare VPS doesn't create them automatically; see the article WordPress backups. Brute-force protection and baseline security rules are covered in WordPress security.
Frequently asked questions
Is it worth migrating an already existing WordPress site to a VPS the same way this guide installs a fresh one?
This guide installs WordPress from scratch; migrating an already live site is a different task. It means copying the theme, plugin, and media files, exporting and importing the database, then updating the site address in the settings. The LEMP stack and certificate set up here form a solid base, but content migration needs its own extra steps.
Will Nginx, MySQL, and PHP-FPM start automatically after the server reboots?
Package managers usually enable autostart for these services right during installation, so after a reboot the site keeps working in most cases without any manual action from the administrator. After the first reboot it is worth checking each service's status once and enabling autostart separately if needed, otherwise a power outage would leave the site down until someone intervenes.
Should the administrator credentials set during the WordPress setup wizard be changed right away?
Yes, the administrator login and password should be strong and unlike common defaults such as admin, since the login page is the most frequent target for automated password guessing by bots. It also helps to restrict access to that page and add brute-force protection right away, rather than waiting for suspicious activity to show up in the server logs.
How do you add a second site on the same VPS — does it need a separate MySQL user and its own Nginx configuration?
Yes, each new site should get its own database and its own MySQL user with rights limited to that database, plus a separate Nginx server block with its own paths and certificate. The same PHP-FPM installation can stay a single shared pool for lightweight sites, or be split into separate pools when the sites differ noticeably in processor load.