Skip to main content
How to Install WordPress on a Web Development VPS Environment - Virtarix Blog

How to Install WordPress on a Web Development VPS Environment

December 6, 2024 · Blog / Technical Guides

This document outlines the process of installing WordPress in a web development setting. The steps include setting up necessary software, configuring databases, and completing the installation of WordPress. Ensure that PHP, NGINX and MariaDB are installed before proceeding.

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:

Switch to the WordPress deployment user
su - YOUR_USER

Use the following command to make WP-CLI executable:

Make the WP-CLI Phar executable
chmod +x wp-cli.phar 

Download the WP-CLI Phar with:

Safety check: This legacy command uses plain HTTP. Prefer the official HTTPS WP-CLI release URL, verify the published checksum before execution, and keep the downloaded Phar outside the system path until verification succeeds.

Download the WP-CLI Phar
curl -O http://githubusercontent.com/wp-cli/gh-pages/phar/wp-cli.phar

Terminal downloading WP-CLI and making the command executable

Step 2: set up WP-CLI and configure access

Move the WP-CLI file to an appropriate directory with

Install WP-CLI in the system path
sudo mv wp-cli.phar /usr/local/bin/wp 

You can then use it as the:

Invoke the WP-CLI executable
wp 

Check the WP-CLI version by running:

Display WP-CLI environment information
wp cli info

Terminal showing WP-CLI environment and version information

Log in to MariaDB using

Open MariaDB as the root user
sudo mysql -u root -p 

to proceed with database creation. Enter the root password when prompted.

MariaDB prompt showing a failed and successful WordPress database creation command

Step 3: set up and organize your WordPress database

Execute the SQL command

Create the WordPress database
CREATE DATABASE YOUR_DATABASE; 

to create the database. These commands are case sensitive, so be sure to type them as-is.

MariaDB prompt showing the initial WordPress database command attempt

Grant necessary privileges to the WordPress user with

Grant a local user all database privileges
GRANT ALL PRIVILEGES on YOUR_DATABASE.* TO 'NEW_USER'@'localhost' IDENTIFIED BY 'STRONG_PASSWORD'

MariaDB prompt showing a GRANT ALL PRIVILEGES query for the WordPress database

Step 4: create and configure the WordPress database

After granting privileges, exit MariaDB by typing EXIT;. Navigate to /var/www/html using:

Change to the WordPress document root
cd /var/www/html

Step 5: prepare the WordPress installation directory

Install and download WP-Core using

Attempt to download WordPress core for a locale
wp core download --locale-en_[your-language]

Please note when downloading WP-Core make sure to adjust the language when installing e.g.

Show WordPress locale download examples
 wp core download --locale-en_GB (English) or  wp core download --locale-en_NL (Dutch)

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.

Change ownership of the WordPress document root
sudo chown -R YOUR_USER /var/www/html

for the necessary access.

WP-CLI downloading WordPress core files successfully

Step 6: download and install WordPress core files

Once downloaded, execute

Create wp-config.php with database credentials
wp config create --dbname=YOUR_WP_DATABASE --dbuser=YOUR_USER --dbpass=STRONG_PASSWORD --dbhost=localhost 

to set up the wp-config.php configuration file.

WP-CLI confirming creation of the WordPress configuration file

Step 7: run the WordPress configuration command

Run the following command:

Install and configure the WordPress site
wp core install --url="YOUR_DOMAIN_NAME" --title="YOUR_SITE_TITLE" --admin_user="YOUR_USER" --admin_password="ANOTHER_STRONG_PASSWORD" --admin_email="YOUR_EMAIL"

WP-CLI confirming successful WordPress installation

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

Attempt to check the PHP-FPM 8.3 service status
sudo systemctl status php8.3-fpm.

If it is not installed use

Install PHP-FPM 8.3
sudo apt install php8.3-fpm 

to install it.

systemctl status output confirming PHP-FPM is active

If the PHP-FPM service is not running, start it with

Start PHP-FPM 8.3
sudo systemctl start php8.3-fpm

Enable it to start on boot with

Enable PHP-FPM 8.3 at boot
sudo systemctl enable php8.3-fpm

Step 9: configure Nginx for WordPress

Configure NGINX by navigating to /etc/nginx/sites-available with:

Change to the Nginx sites-available directory
cd /etc/nginx/sites-available 

Create a new file for your domain using the

Open a new Nginx server block file
sudo nano YOUR_DOMAIN_NAME 

command and add the server configuration.

Enter your root domain and fully qualified domain name in the server_name section as:

Set the Nginx server name
server_name YOUR_DOMAIN_NAME; 

Save the file after editing.

Nginx site configuration open in Nano

Step 10: configure and activate Nginx for WordPress

Update your system by typing:

Refresh the APT package index
sudo apt update

Step 11: add server names to your Nginx configuration

Create a symbolic link from sites-available to sites-enabled running this command:

Enable the Nginx site with a symbolic link
sudo ln -s /etc/nginx/sites-available/YOUR_DOMAIN_NAME /etc/nginx/sites-enabled/

to ensure the configuration loads correctly.

Terminal showing PHP-FPM service output and the Nginx site symlink command

Step 12: test and apply Nginx changes with PHP-FPM

Test the NGINX configuration with

Test the Nginx configuration
sudo nginx -t 

to ensure it works properly.

Nginx configuration test reporting successful syntax and configuration

Apply the new changes by restarting NGINX with systemctl restart nginx. You may be prompted to input a password to restart nginx.service.

Terminal confirming authentication after restarting Nginx

Step 13: set up DNS records for your VPS domain

Access your domain provider's settings to change DNS records, add an A record that points to your VPS.

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:

Restart Nginx
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 VPS sizes for WordPress development, staging, databases, root access, NVMe storage, IPv4 + IPv6, snapshots, and backups.

VPS S

For small WordPress sites

$ 5 .50 /month
  • 3 cores
  • 6 GB
  • 50 GB NVMe
  • Unlimited
Get It Now
BEST SELLER

VPS M

For growing WooCommerce or blogs

$ 11 .40 /month
  • 6 cores
  • 16 GB
  • 100 GB NVMe
  • Unlimited
Get It Now
Peter French
About the Author Peter Frenchis the Managing Director at Virtarix, with over 17 years in the tech industry. He has co-founded a cloud storage business, led strategy at a global cloud computing leader, and driven market growth in cybersecurity and data protection.