How to Install WordPress on a VPS
Requirements
Section titled “Requirements”WordPress recommends a current PHP runtime (8.3+), MariaDB 10.11+ or MySQL 8.0+, and HTTPS. This example uses Ubuntu 24.04, Nginx, PHP-FPM and MariaDB. Use a domain such as blog.example.com that points to your VPS.
This guide assumes a new server. If Nginx, PHP or a database already runs on your VPS, inspect your configuration first to avoid service conflicts.
1. Install the web and database stack
Section titled “1. Install the web and database stack”sudo apt updatesudo apt install -y nginx mariadb-server php8.3-fpm php8.3-mysql \ php8.3-curl php8.3-gd php8.3-mbstring php8.3-xml php8.3-zip unzip curlsudo systemctl enable --now nginx mariadb php8.3-fpmConfirm the relevant services are running and that MariaDB is not publicly bound to 0.0.0.0.
2. Create a WordPress database
Section titled “2. Create a WordPress database”Generate a unique, strong database password in your password manager; never reuse the example placeholder below.
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;CREATE USER 'wpapp'@'localhost' IDENTIFIED BY 'REPLACE_WITH_STRONG_UNIQUE_PASSWORD';GRANT ALL PRIVILEGES ON wordpress.* TO 'wpapp'@'localhost';FLUSH PRIVILEGES;Enter the SQL above in sudo mariadb. Do not commit the password to Git or paste it into a public support request.
3. Download and configure WordPress
Section titled “3. Download and configure WordPress”cd /tmpcurl -fLO https://wordpress.org/latest.tar.gztar -xzf latest.tar.gzsudo mkdir -p /var/www/blog.example.comsudo cp -a wordpress/. /var/www/blog.example.com/sudo cp /var/www/blog.example.com/wp-config-sample.php /var/www/blog.example.com/wp-config.phpsudo chown -R www-data:www-data /var/www/blog.example.comsudo find /var/www/blog.example.com -type d -exec chmod 755 {} +sudo find /var/www/blog.example.com -type f -exec chmod 644 {} +sudo chmod 640 /var/www/blog.example.com/wp-config.phpEdit wp-config.php: set DB_NAME=wordpress, DB_USER=wpapp, the generated DB_PASSWORD, and DB_HOST=localhost. Replace the sample authentication keys with unique values obtained from the WordPress salt service.
4. Configure Nginx
Section titled “4. Configure Nginx”Create a new Nginx server block:
server { listen 80; server_name blog.example.com; root /var/www/blog.example.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.3-fpm.sock; } location ~ /\. { deny all; }}Enable the site and run sudo nginx -t before reloading. Once DNS is set, configure HTTPS using Certbot. Never leave the WordPress admin login over plain HTTP.
5. Complete the web installer and secure the site
Section titled “5. Complete the web installer and secure the site”Open https://blog.example.com, choose an administrator login other than admin, use a strong unique password and keep plugin count minimal. Install WordPress and plugin updates promptly.
Backup both the database and wp-content/ and test restoring them. Disable unused themes/plugins, apply rate limiting to logins and verify your firewall only exposes necessary ports.
Official references: WordPress requirements, installation guide.
Need a VPS for this project? Compare ProstoHosting VPS plans.