Independent testing Updated April 2026 387 self-hosting guides 5 VPS providers tested

guide

How to Self-Host WordPress on a VPS (Complete Guide)

A complete step-by-step guide to self-hosting WordPress on a VPS in 2026, covering installation, configuration, securing WordPress, and the specs you need.

How to Self-Host WordPress on a VPS (Complete Guide)

Self-hosting WordPress on a VPS can give you full control over your server environment, better performance, and the flexibility to customize your applications. This guide will walk you through the necessary steps to install and configure WordPress on a VPS. We will cover the use of both traditional setups and Docker containers.

Choosing a VPS Provider

Before diving into the installation process, you need to select a VPS provider. Hereโ€™s a quick comparison of popular VPS services for hosting WordPress:

ProviderMonthly PriceCPU CoresRAMSSD StorageWebsite
Contabo VPS5.99 EUR48GB200GBContabo
Hetzner Cloud4.15 EUR22GB20GBHetzner
DigitalOcean6 USD11GB25GBDigitalOcean
Vultr6 USD11GB25GBVultr
Linode5 USD12GB25GBLinode

For detailed comparisons, visit our full VPS comparison.

Steps to Self-Host WordPress on a VPS

Step 1: Provision Your VPS

  1. Sign Up: Choose your provider and create an account.
  2. Select an Image: Choose a Linux distribution (Ubuntu 20.04 LTS is recommended).
  3. Choose Plan: Select the appropriate plan based on your traffic and storage needs.
  4. Access Your VPS: Once your server is provisioned, youโ€™ll receive an IP address and root access.

Step 2: Initial Setup

  1. Connect to Your VPS:

    ssh root@your_server_ip
  2. Update System:

    apt update && apt upgrade -y

Step 3: Install Required Packages

Install LAMP Stack

You need to install Apache, MySQL, and PHP (LAMP) to run WordPress.

apt install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring -y

Secure MySQL

Run the MySQL secure installation script:

mysql_secure_installation

Step 4: Create a Database for WordPress

  1. Access MySQL:

    mysql -u root -p
  2. Execute the following commands:

    CREATE DATABASE wordpress;
    CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_password';
    GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;

Step 5: Download and Configure WordPress

  1. Download WordPress:

    cd /var/www/html
    wget https://wordpress.org/latest.tar.gz
    tar xzvf latest.tar.gz
    mv wordpress/* ./
    rm -rf wordpress latest.tar.gz
  2. Set Permissions:

    chown -R www-data:www-data /var/www/html
    chmod -R 755 /var/www/html
  3. Create wp-config.php:

    cp wp-config-sample.php wp-config.php
    nano wp-config.php

    Replace database_name_here, username_here, and password_here with your database details.

Step 6: Finalize Apache Configuration

  1. Create a New Virtual Host:

    nano /etc/apache2/sites-available/wordpress.conf

    Add the following configuration:

    <VirtualHost *:80>
        DocumentRoot /var/www/html
        ServerName your_domain.com
        <Directory /var/www/html>
            AllowOverride All
        </Directory>
    </VirtualHost>
  2. Enable the New Site and Rewrite Module:

    a2ensite wordpress.conf
    a2enmod rewrite
    systemctl restart apache2

Step 7: Access WordPress

Open a web browser and navigate to http://your_server_ip or http://your_domain.com. You should see the WordPress installation screen.

Self-Hosting WordPress Using Docker

For those inclined to use containerization, you can also install WordPress via Docker. Hereโ€™s how to do it.

  1. Install Docker:

    apt install docker.io docker-compose -y
  2. Create a docker-compose.yml file:

    version: '3'
    
    services:
      db:
        image: mysql:5.7
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: root_password
          MYSQL_DATABASE: wordpress
          MYSQL_USER: wp_user
          MYSQL_PASSWORD: user_password
    
      wordpress:
        image: wordpress
        restart: always
        ports:
          - "8000:80"
        environment:
          WORDPRESS_DB_HOST: db
          WORDPRESS_DB_USER: wp_user
          WORDPRESS_DB_PASSWORD: user_password
          WORDPRESS_DB_NAME: wordpress
  3. Run the Docker Container:

    docker-compose up -d

Access it via http://your_server_ip:8000.

FAQs

How can I secure my self-hosted WordPress site?

To secure your WordPress site, establish a strong password for the MySQL user and use HTTPS for your domain. Configure a firewall using UFW and regularly update WordPress to protect against vulnerabilities. Additionally, consider security plugins such as Wordfence or Sucuri for additional layer protection.

Is self-hosting WordPress on a VPS difficult?

Self-hosting WordPress on a VPS may seem daunting initially, especially if youโ€™re unfamiliar with server management. However, with clear instructions and practice, it becomes manageable. Having command-line experience can significantly mitigate challenges. Docker can also simplify the setup process, as it abstracts many complexities.

What are the advantages of using a VPS for WordPress?

A VPS offers greater control over your environment compared to shared hosting. You can configure the server as per your needs, optimize performance, and ensure better uptime. Moreover, you can scale resources as your site grows, providing flexibility and enhanced security.

Self-hosting lets you dive into an exciting world of web development and offers the freedom to manage your applications.