This guide installs WordPress with WP-CLI after the Nginx, PHP-FPM, and MariaDB base stack is working. If those services are not installed and verified yet, complete the CMS development base-stack guide first.
The commands below create the WordPress database and user, download WordPress, configure PHP-FPM and Nginx, and connect the domain. Run them from an account with sudo access, keep current backups, and replace every uppercase placeholder with a value for your environment.
Step 1: prepare your VPS environment
Ensure that PHP, NGINX and MariaDB are installed in your development environment.
Create a separate user from the root user for usage and run this command to switch users:
su - YOUR_USER
Use the following command to make WP-CLI executable:
chmod +x wp-cli.phar
Download the WP-CLI Phar with:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Step 2: set up WP-CLI and configure access
Move the WP-CLI file to an appropriate directory with
sudo mv wp-cli.phar /usr/local/bin/wp
You can then use it as the:
wp
Check the WP-CLI version by running:
wp cli info
Log in to MariaDB using
sudo mysql -u root -p
to proceed with database creation. Enter the root password when prompted.
Step 3: set up and organize your WordPress database
Execute the SQL command
CREATE DATABASE YOUR_DATABASE;
to create the database. These commands are case sensitive, so be sure to type them as-is.
Grant necessary privileges to the WordPress user with
CREATE USER 'NEW_USER'@'localhost' IDENTIFIED BY 'STRONG_PASSWORD';
GRANT ALL PRIVILEGES ON YOUR_DATABASE.* TO 'NEW_USER'@'localhost';
FLUSH PRIVILEGES;
Step 4: create and configure the WordPress database
After granting privileges, exit MariaDB by typing EXIT;. Navigate to /var/www/html using:
cd /var/www/html
Step 5: prepare the WordPress installation directory
Install and download WP-Core using
wp core download --locale=YOUR_LOCALE
Please note when downloading WP-Core make sure to adjust the language when installing e.g.
wp core download --locale=en_GB
If permission errors occur, identify your user by typing whoami and adjust permissions for /var/www/html using:
Safety check: Confirm the target and keep a recent backup or snapshot. Preview the affected resources where possible, and document a tested recovery or rollback path before running this command.
sudo chown -R YOUR_USER /var/www/html
for the necessary access.
Step 6: download and install WordPress core files
Once downloaded, execute
wp config create --dbname=YOUR_WP_DATABASE --dbuser=YOUR_USER --dbpass=STRONG_PASSWORD --dbhost=localhost
to set up the wp-config.php configuration file.
Step 7: run the WordPress configuration command
Run the following command:
wp core install --url="YOUR_DOMAIN_NAME" --title="YOUR_SITE_TITLE" --admin_user="YOUR_USER" --admin_password="ANOTHER_STRONG_PASSWORD" --admin_email="YOUR_EMAIL"
Step 8: configure PHP-FPM for WordPress
Verify the PHP-FPM version you have installed, and update the server configuration file to match this version. Here, we're using PHP 8.3.
Check the status of PHP FastCGI Process Manager with
systemctl list-unit-files 'php*-fpm.service'
Use the installed PHP-FPM service name in the Nginx socket path and service commands. Return to the base-stack guide if PHP-FPM is not installed.
If the PHP-FPM service is not running, start it with
sudo systemctl start YOUR_PHP_FPM_SERVICE
Enable it to start on boot with
sudo systemctl enable YOUR_PHP_FPM_SERVICE
Step 9: configure Nginx for WordPress
Configure NGINX by navigating to /etc/nginx/sites-available with:
cd /etc/nginx/sites-available
Create a new file for your domain using the
sudo nano YOUR_DOMAIN_NAME
command and add the server configuration.
Create a complete server block with the correct document root, index files, WordPress front-controller fallback, PHP-FPM socket, and protection for hidden files:
server {
listen 80;
server_name YOUR_DOMAIN_NAME;
root /var/www/html;
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/YOUR_PHP_FPM_SOCKET;
}
location ~ /\.ht {
deny all;
}
}
Save the file after editing.
Step 10: review ownership and permissions
Give the web-server account only the write access WordPress actually needs. Avoid leaving the entire document root owned by a personal deployment account or globally writable. Record the chosen owner/group model before enabling the site.
Step 11: add server names to your Nginx configuration
Create a symbolic link from sites-available to sites-enabled running this command:
sudo ln -s /etc/nginx/sites-available/YOUR_DOMAIN_NAME /etc/nginx/sites-enabled/
to ensure the configuration loads correctly.
Step 12: test and apply Nginx changes with PHP-FPM
Test the NGINX configuration with
sudo nginx -t
to ensure it works properly.
Apply the verified configuration with sudo systemctl reload nginx. A reload keeps the previous configuration running if the syntax test fails; do not reload until sudo nginx -t passes.
Step 13: set up DNS records for your VPS domain
At the authoritative DNS provider, add an A record that points the intended hostname to the VPS IPv4 address. Add an AAAA record only when IPv6 is configured and reachable. After DNS resolves, install a TLS certificate using a current method for your environment and verify the served hostname, certificate chain, WordPress front page, and admin login.
Frequently asked questions
What software is required before installing WordPress on a VPS?
Ensure PHP, NGINX, MariaDB, a DBMS, and a web server are installed before starting.
How do I create a database for WordPress?
Log in to MariaDB, execute SQL commands to create a database, and grant user privileges with a password.
What should I do if I encounter permission errors during the installation?
Use the whoami command to identify your user and adjust permissions with chown for proper access.
How do I test and apply NGINX server configuration changes?
Use the command sudo nginx -t to test the NGINX configuration. If there are no errors, apply the changes by restarting NGINX with this command:
sudo systemctl restart nginx
How can I connect my domain to the WordPress VPS?
Update DNS settings with your domain provider by adding an A record pointing to your VPS IP address.
Ready to run a WordPress development VPS?
Compare self-managed VPS sizes for WordPress development, staging, and databases with root access, NVMe storage, IPv4 + IPv6 and one snapshot.
VPS S
For small WordPress sites
- ✓ 3 cores
- ✓ 6 GB
- ✓ 50 GB NVMe
- ✓ Unlimited
VPS M
For growing WooCommerce or blogs
- ✓ 6 cores
- ✓ 16 GB
- ✓ 100 GB NVMe
- ✓ Unlimited