Before installing WordPress on a virtual server, you need to prepare the VPS for operation. Use a clean system — most often Ubuntu or Debian. Connect to the server via SSH using root access or a user with administrative privileges. First, update the system:
sudo apt update && sudo apt upgrade -y
Create a new user to manage the site so you don’t work constantly as root:
adduser siteadmin
usermod -aG sudo siteadmin
Now, you can safely continue all actions as a new user.
WordPress requires a web server, a PHP interpreter, and a database management system. The most popular stack is LAMP (Linux, Apache, MySQL, PHP). Install it using the commands:
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql -y
It’s also worth installing PHP extensions:
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-zip -y
After installation, check the PHP version and make sure Apache and MySQL services are running:
php -v
sudo systemctl status apache2
sudo systemctl status mysql
Proceed to create the database. Open MySQL:
sudo mysql
Then create the database, user, and grant permissions:
CREATE DATABASE wpdb DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Use a strong password to enhance connection security. Remember these details — you will need them during CMS installation.
Download the latest version of WordPress from the official site:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
Move the CMS files to the site directory:
sudo mkdir -p /var/www/yourdomain.com
sudo cp -R wordpress/* /var/www/yourdomain.com
Set the necessary permissions:
sudo chown -R www-data:www-data /var/www/yourdomain.com
sudo find /var/www/yourdomain.com -type d -exec chmod 755 {} ;
sudo find /var/www/yourdomain.com -type f -exec chmod 644 {} ;
Create a new virtual host in Apache:
sudo nano /etc/apache2/sites-available/yourdomain.com.conf
Add the configuration:
ServerAdmin admin@yourdomain.com
ServerName yourdomain.com
DocumentRoot /var/www/yourdomain.com
AllowOverride All
ErrorLog ${APACHE_LOG_DIR}/yourdomain.com_error.log
CustomLog ${APACHE_LOG_DIR}/yourdomain.com_access.log combined
Enable the site and restart Apache:
sudo a2ensite yourdomain.com.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Open a browser and enter your site address (e.g., http://yourdomain.com
). You will be greeted by the WordPress installation wizard. Enter the database details, admin username, password, and email address. After this, the CMS will complete the setup and create all necessary tables in MySQL.
If you see a connection error — check the accuracy of the login and database name in the wp-config.php
file located in the site root. It is created automatically or copied manually from wp-config-sample.php
.
After installation, we recommend setting up HTTPS. Install the Let’s Encrypt certificate:
sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d yourdomain.com
To enhance protection, enable automatic system updates:
sudo apt install unattended-upgrades
Setting up backups, caching plugins, and essential bot protection is also worth it. Configure permalinks within the WordPress admin panel, choose a theme, and install necessary plugins for SEO and security.
Setting up a VPS for WordPress gives you full control over the environment, allows for increased site performance, and eliminates shared hosting limitations. Thanks to this guide, you’ll be able to deploy the CMS, adapt the webserver to project needs and ensure the stable operation of your site from the very first minute.
Learn more about how to purchase a domain, hosting, VPS, or dedicated server.
Use caching plugins, optimize images, configure server-side caching (e.g., using Varnish or Redis), and choose a performance-optimized theme. Using a CDN to speed up the loading of static resources is also recommended.
Regularly update WordPress, plugins, and themes, use strong passwords, install security plugins (such as Wordfence or Sucuri Security), configure a firewall, and restrict access to .htaccess and wp-config.php files.
To restore WordPress from a backup on VPS, first restore the site files and the database. Then, configure the wp-config.php file with the recovered database credentials. Make sure file paths and site URLs are correct.