How to Self-Host WordPress on Hetzner (2026 Guide)
WordPress is a powerful content management system thatโs perfect for bloggers, businesses, and anyone looking to self-host a website. If youโre looking for an affordable VPS provider, Hetzner is an excellent option starting at just 4.15 EUR/month. In this guide, weโll walk you through the steps to install and configure WordPress on a Hetzner VPS.
Prerequisites
Before getting started, ensure you meet the following:
- A Hetzner VPS: Sign up for a VPS plan at Hetzner and choose your preferred configuration.
- Domain Name: Youโll need a domain name pointed to your VPS IP.
- Basic Linux Knowledge: Familiarity with command line operations and Linux-based systems.
Step 1: Setting Up Your VPS
Once you have your Hetzner VPS up and running, connect to it via SSH using the following command:
ssh root@your_ip_address
Replace your_ip_address with the actual IP of your VPS.
Step 2: Update System Packages
Before installing any software, itโs good practice to update your system packages. Run the following commands:
apt update
apt upgrade -y
Step 3: Install Required Software
You will need a web server, a database server, and PHP to run WordPress. Install Apache, MySQL, and PHP with the following command:
apt install apache2 mysql-server php libapache2-mod-php php-mysql -y
Verify the Installations
- Apache: Access your serverโs IP address in a web browser. You should see the Apache default page.
- MySQL: Secure your MySQL installation:
mysql_secure_installation
Follow the prompts to set a root password and secure your instance.
Step 4: Create a MySQL Database for WordPress
Log into MySQL:
mysql -u root -p
Once in the MySQL shell, run the following commands to create a new database and user for WordPress:
CREATE DATABASE wordpress_db;
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Make sure to replace 'your_password' with a strong password.
Step 5: Download and Configure WordPress
Navigate to the web directory and download the latest WordPress package:
cd /var/www/html
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
mv wordpress/* .
rm -rf wordpress latest.tar.gz
Next, configure WordPress by creating a configuration file:
cp wp-config-sample.php wp-config.php
nano wp-config.php
Change the database configuration values:
define('DB_NAME', 'wordpress_db');
define('DB_USER', 'wordpress_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');
Save and exit the editor.
Step 6: Set File Permissions
Ensure that the web server can read and write necessary files:
chown -R www-data:www-data /var/www/html
chmod -R 755 /var/www/html
Step 7: Enable Apache Rewrite Module
WordPress relies on the Apache rewrite module to create pretty URLs. Enable it using:
a2enmod rewrite
systemctl restart apache2
Step 8: Complete WordPress Installation Through Browser
Now, open a web browser and navigate to http://your_ip_address. Follow the on-screen instructions to complete the installation.
You will set your site title, admin username, password, and email during this process.
Comparison of Top VPS Providers
| Provider | Price (EUR/USD) | Key Features |
|---|---|---|
| Contabo VPS | 5.99 EUR/mo | High storage, low cost |
| Hetzner Cloud | 4.15 EUR/mo | Excellent performance, easy scalability |
| DigitalOcean | 6 USD/mo | User-friendly interface, great for beginners |
| Vultr | 6 USD/mo | Multiple locations, fast SSD storage |
| Linode (Akamai) | 5 USD/mo | High reliability, good support |
FAQs
Can I use a managed database service with Hetzner?
Yes, you can use a managed database service if preferred. By using managed databases, you offload the responsibility of backups, updates, and scaling, allowing you to focus on your application. Hetzner also provides various options for managed services which can be beneficial in a production environment.
What are the security best practices for self-hosting WordPress?
When self-hosting WordPress, ensure you follow best security practices such as keeping your software updated, using strong passwords, implementing HTTPS with SSL certificates, and regularly backing up your site. Additionally, consider using security plugins like Wordfence and performing regular security audits to minimize vulnerabilities.
How do I migrate an existing WordPress site to Hetzner?
To migrate your existing WordPress site, export your database using tools like phpMyAdmin or the command line. Upload your WordPress files using SCP or FTP. Import your database into the newly created database on your Hetzner VPS and update your wp-config.php file with the new database details. Ensure you update the site URL and permalinks settings post-migration.
For more details on VPS providers, check out our full VPS comparison. Enjoy your self-hosted WordPress experience on Hetzner!