> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Install WordPress on a VPS (Ubuntu 24.04)

> Install WordPress on an Ubuntu 24.04 VPS: set up Nginx, MariaDB and PHP 8.3, create a database, download WordPress, add a server block, then enable HTTPS.

To install WordPress on an Ubuntu 24.04 VPS, install Nginx, MariaDB and PHP-FPM, create a database and user, download `https://wordpress.org/latest.tar.gz` into `/var/www/wordpress`, set the database details in `wp-config.php`, and add an Nginx server block with `try_files $uri $uri/ /index.php?$args;`. Add HTTPS with Certbot, then finish the setup at `https://example.com/wp-admin/install.php`.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Intermediate | 30 minutes | Ubuntu 22.04 / 24.04, Debian 12 / 13 (AlmaLinux / Rocky: see notes) | A domain, SSH with sudo, 1 GB RAM or more |

## Before you start

* Point your domain's `A` record at the server: [point a domain](https://help.freakhosting.com/portals/other/how-to-point-a-domain-to-your-server.md).
* Take a [snapshot or backup](https://help.freakhosting.com/portals/vps-panel/how-to-schedule-and-restore-backups.md) if the server already hosts something.
* Use a user with `sudo`. If you are `root`, leave out `sudo`.
* WordPress recommends PHP 8.3 or newer, MariaDB 10.11+ or MySQL 8.0+, and HTTPS. Ubuntu 24.04 and Debian 13 meet these out of the box.

## How to install Nginx, MariaDB and PHP

```bash theme={null}
sudo apt update
sudo apt install nginx mariadb-server php-fpm php-mysql php-curl php-gd php-intl php-mbstring php-xml php-zip php-imagick
```

These are the extensions WordPress lists as required or highly recommended. For a full walkthrough, firewall rules and AlmaLinux / Rocky commands, see [install a LEMP stack](https://help.freakhosting.com/portals/other/how-to-install-a-lemp-stack.md). Then secure the database:

```bash theme={null}
sudo mysql_secure_installation
```

## How to create the WordPress database

```bash theme={null}
sudo mariadb
```

```sql theme={null}
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'Choose-A-Strong-Password-1';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
```

Use your own strong password. More options are in [create a MySQL database and user](https://help.freakhosting.com/portals/other/how-to-create-a-mysql-database-and-user.md).

## How to download and configure WordPress

**1. Download and unpack**

```bash theme={null}
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
sudo mv wordpress /var/www/wordpress
```

**2. Create wp-config.php**

```bash theme={null}
sudo cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php
sudo nano /var/www/wordpress/wp-config.php
```

Set the database details:

```php theme={null}
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'Choose-A-Strong-Password-1' );
define( 'DB_HOST', 'localhost' );
```

Replace the block of `put your unique phrase here` lines with fresh keys from `https://api.wordpress.org/secret-key/1.1/salt/`.

**3. Set ownership**

PHP-FPM runs as `www-data` on Ubuntu and Debian and must be able to write uploads and updates:

```bash theme={null}
sudo chown -R www-data:www-data /var/www/wordpress
```

## How to configure Nginx for WordPress

Create `/etc/nginx/sites-available/wordpress`:

```nginx theme={null}
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 ~ /\. {
        deny all;
    }
}
```

Use `php8.4-fpm.sock` on Debian 13 (check with `php -v`). The `try_files` line sends pretty permalinks to `index.php`. `client_max_body_size` allows uploads up to 64 MB; raise PHP's limits to match with [increase PHP upload size](https://help.freakhosting.com/portals/other/how-to-increase-php-upload-size-and-memory-limit.md).

Enable the site, test and reload:

```bash theme={null}
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
```

## How to add HTTPS and finish the install

**1. Get a certificate**

```bash theme={null}
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com
```

See [free SSL with Certbot](https://help.freakhosting.com/portals/other/how-to-get-a-free-ssl-certificate-with-certbot.md).

**2. Run the installer**

Open `https://example.com/wp-admin/install.php`. Choose the language, site title, an admin username (not `admin`), a strong password and your email.

**3. Log in**

Log in at `https://example.com/wp-admin/`. Set **Settings > Permalinks** to **Post name** and save.

> [!NOTE]
>
> **AlmaLinux / Rocky:** use the LEMP guide's commands, `/etc/nginx/conf.d/wordpress.conf`, `fastcgi_pass unix:/run/php-fpm/www.sock;`, and `sudo chown -R apache:apache /var/www/wordpress` (the default PHP-FPM pool user is `apache`). With SELinux enforcing, also run `sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/wordpress/wp-content(/.*)?"` and `sudo restorecon -Rv /var/www/wordpress` so uploads work.

## How to check it worked

* `https://example.com` shows your new site with a padlock.
* **Tools > Site Health** in the dashboard lists missing PHP extensions or HTTPS problems.
* Upload an image under **Media > Add New** to confirm write permissions.

## Frequently asked questions

### I see "Error establishing a database connection". What now?

The values in `wp-config.php` do not match the database. Test them with `mariadb -u wpuser -p wordpress`. If that login fails, recreate the user with the SQL above.

### WordPress asks for FTP details when I install a plugin. Why?

PHP cannot write to the WordPress folder. Run the `chown` command again for the user PHP-FPM runs as (`www-data` or `apache`).

### Permalinks give 404 errors. How do I fix them?

The `try_files $uri $uri/ /index.php?$args;` line is missing from your server block. Add it, run `sudo nginx -t` and reload Nginx.

### How do I back up WordPress?

Back up both the files in `/var/www/wordpress` and the database. See [back up MySQL databases](https://help.freakhosting.com/portals/other/how-to-back-up-and-restore-mysql-databases.md) and [back up a Linux server](https://help.freakhosting.com/portals/other/how-to-back-up-a-linux-server.md).

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every server guide in one place.

> [card] [Install a LEMP stack](https://help.freakhosting.com/portals/other/how-to-install-a-lemp-stack.md)
>
> The base WordPress runs on.

> [card] [Increase PHP upload size](https://help.freakhosting.com/portals/other/how-to-increase-php-upload-size-and-memory-limit.md)
>
> Fix upload size errors.

> [card] [Free control panels](https://help.freakhosting.com/portals/other/how-to-install-a-free-control-panel-on-your-vps.md)
>
> Manage sites in a browser.

> [card] [Linux security checklist](https://help.freakhosting.com/portals/other/linux-server-security-checklist.md)
>
> Harden the server too.

***

> [!NOTE]
>
> **Checked against the official [WordPress requirements](https://wordpress.org/about/requirements/), [WordPress installation guide](https://developer.wordpress.org/advanced-administration/before-install/howto-install/) and [WordPress hosting handbook](https://make.wordpress.org/hosting/handbook/server-environment/)** on 4 November 2026; packages, SQL and the Nginx configuration tested on Ubuntu 24.04 LTS (Nginx 1.24.0, MariaDB 10.11, PHP 8.3.6). The WordPress download itself and the browser installer were not run in the test. Commands can differ on other distributions or releases.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.