HELPER VPS

Install WordPress on a VPS: methods for the WordPress, LEMP and Docker images

Install WordPress on your own server and you decide everything, from plugins and themes to server settings. Pick the install method that best fits the image you choose when creating your server, and follow along.

Choosing one of three methods

At HELPER VPS, simply choosing an image when you create a server cuts down the WordPress setup a lot. Pick the one method that fits your situation.

  • WordPress image: Nginx, MySQL, PHP and WordPress are installed on Ubuntu 24.04. Just finish the setup screen in your browser, making it the fastest way to open a single blog.
  • LEMP image: install WordPress yourself on a server with Nginx, MySQL and PHP ready. Good when you want several sites on one server or want to set the folder structure and settings yourself.
  • Docker image: run WordPress and its database as containers. Handy for moving a site to another server or creating the same environment several times.

A small blog is fine starting with the smallest 12GB general plan, while online stores or busy sites open pages more lightly on a high-performance NVMe server with a fast disk. Size recommendations are on the WordPress VPS page.

Connect your domain first

If you plan to use a domain, connect it before installing and you can get the HTTPS certificate in one go. Create the two records below in the DNS settings where you bought the domain.

  • A record: name @ (and www), value is the server's IPv4 address
  • AAAA record: name @ (and www), value is the server's IPv6 address

Records usually take a few minutes to a few hours to spread. Run ping -c 3 example.com on the server, and if your server IP appears, you are ready. Replace example.com in the commands below with your domain.

Method 1. Start right away with the WordPress image

  • On the create server page, choose a region and size and select WordPress from the image list.
  • When the server changes to running, open http://YOUR_SERVER_IP in your browser.
  • Choose a language and set the site title, admin username, password and email, and the installation is done.
  • Go to the admin area at http://YOUR_SERVER_IP/wp-admin.

Use a long, complex admin password, and a username only you know instead of admin, to stay strong against login attempts. For connecting a domain and HTTPS, just follow the HTTPS step below.

Method 2. Install it yourself on a LEMP server

The LEMP image already has Nginx, MySQL and PHP-FPM installed. Just add the PHP extensions WordPress needs, a database and a site config. This is for Ubuntu 24.04, and the steps are the same on other Ubuntu and Debian versions.

Step 1. Install PHP extensions

Terminal
apt update
apt install -y php-mysql php-curl php-gd php-mbstring php-xml php-zip php-intl php-imagick
php -v
ls /run/php/

php -v shows the PHP version and ls /run/php/ shows the PHP-FPM socket name. Ubuntu 24.04 has PHP 8.3, so you see php8.3-fpm.sock; Debian 13 has PHP 8.4, so you see php8.4-fpm.sock. Use this name as is in the Nginx config below.

Step 2. Create the database and user

Logged in as root, run mysql to enter MySQL without a password. Create a dedicated WordPress database and user with the four lines below. Replace the password with a long one and note it down.

mysql
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'change_this_long_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 3. Download WordPress

Terminal
cd /var/www
curl -O https://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz && rm latest.tar.gz
chown -R www-data:www-data /var/www/wordpress

Change the folder owner to the web server user (www-data) so the browser setup screen can create the config file itself, and you can install plugins and themes right from the admin area.

Step 4. Nginx site config

/etc/nginx/sites-available/wordpress
server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    root /var/www/wordpress;
    index index.php;
    client_max_body_size 64m;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }
    location ~ /\.ht {
        deny all;
    }
}
Terminal
ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx

If nginx -t shows syntax is ok and test is successful, the config is correct. If you do not have a domain yet, put _ in server_name and remove the default site link (/etc/nginx/sites-enabled/default) to open the site by IP address.

Step 5. Finish the install in your browser

Open http://example.com to see the setup screen. Enter the database name wordpress, user wpuser, the password you set in step 2 and host localhost, then set your site title and admin account, and you are done.

Method 3. Install with Docker Compose

On a server created with the Docker image, or one where you installed Docker yourself, one file starts WordPress and MariaDB together. Replace both passwords with long ones.

Terminal
mkdir -p /opt/wordpress && cd /opt/wordpress
cat > compose.yaml <<'EOF'
services:
  db:
    image: mariadb:11
    restart: unless-stopped
    environment:
      MARIADB_DATABASE: wordpress
      MARIADB_USER: wpuser
      MARIADB_PASSWORD: change_this_long_password
      MARIADB_ROOT_PASSWORD: change_this_other_password
    volumes:
      - db:/var/lib/mysql
  wordpress:
    image: wordpress:latest
    restart: unless-stopped
    depends_on:
      - db
    ports:
      - "80:80"
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: wpuser
      WORDPRESS_DB_PASSWORD: change_this_long_password
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - wp:/var/www/html
volumes:
  db:
  wp:
EOF
docker compose up -d

Open http://YOUR_SERVER_IP to see the setup screen. The database details are already in the file, so just set your site title and admin account. Posts and uploads stay in the wp volume and the database in the db volume, so they remain intact when you switch the containers to a new version.

To add HTTPS to a site deployed with Docker, putting a reverse proxy in front is the clean way. It is even simpler with the Coolify or Dokploy images, which attach certificates automatically once you enter the domain in the dashboard.

Add an HTTPS certificate

On the WordPress image and LEMP servers, get a free Let's Encrypt certificate with Certbot and attach it to Nginx right away. Your domain must be pointing to the server IP.

Terminal
apt install -y certbot python3-certbot-nginx
certbot --nginx -d example.com -d www.example.com

Enter your email and agree to the terms, and the certificate is issued and HTTPS is added to the Nginx config. Certbot renews the certificate automatically. Then, in the WordPress admin under Settings > General, change the WordPress Address and Site Address to https. If you use a firewall, open both ports with ufw allow 80,443/tcp.

Settings worth making after installation

  • Permalinks: choose the post name structure under Settings > Permalinks for readable addresses. The try_files line in the Nginx config above handles these addresses.
  • Upload size: to upload large images or theme files, raise Nginx's client_max_body_size together with upload_max_filesize and post_max_size in /etc/php/8.3/fpm/php.ini to the same size, then run systemctl restart php8.3-fpm.
  • Sending email: connect sign-up, password reset and order notification emails to port 587 or 465 of a mail sending service with an SMTP plugin. How to do this is in the email sending guide.
  • Updates: keep WordPress core, plugins and themes up to date from the admin area, and the server with apt update && apt upgrade -y, regularly.
  • Backups: your posts and database are assets you cannot recreate. Turn on automatic backups when you create the server, or keep copies using the methods in the backups and snapshots guide.

To reinstall from scratch, choose the WordPress image again under Reinstall on the server page to return to a clean state. The disk is freshly installed, so first download the posts you need with Tools > Export, and see the reinstall guide for the steps.

Related guides

Settings worth doing right after this guide.

View all guides