If you’re trying to run WordPress on Ubuntu 24.04 using Caddy instead of Apache or Nginx, this guide is for you.
We’ll walk through the basic flow: set up MariaDB, install PHP, grab WordPress via WP-CLI, then wire everything into Caddy with PHP-FPM. This is aimed at people who already have a server with Ubuntu 24.04 and a domain ready to point to it.
I’ll keep things practical and step-by-step so you can get from “blank server” to a working WordPress site with HTTPS.
What You’ll Set Up (and Who This Helps)
This guide is for you if:
- You have an Ubuntu 24.04 server.
- You want to use Caddy as your web server instead of Apache or Nginx.
- You want a clean way to install WordPress using WP-CLI.
We’ll go through these big steps:
- Install and prepare MariaDB for WordPress.
- Install PHP 8.3 and configure PHP-FPM.
- Install WordPress using WP-CLI in a domain directory.
- Install and configure Caddy with a simple Caddyfile that talks to PHP-FPM.
- Test your site and basic WordPress functions.
Whenever we touch configs or permissions, I’ll add a quick note on what to watch out for.
Step 1 – Install and Prepare MariaDB
First, you need a database server for WordPress. Here we’re using MariaDB.
Install MariaDB
On Ubuntu 24.04, install MariaDB with your package manager. This gets the database server running on your machine.
Log In to MariaDB
Once MariaDB is installed, log in to the database server from the terminal.
You’ll use the root or a privileged database user to create a database for WordPress. Make sure you know the credentials you’re using here, because you’ll need them later when configuring WordPress.
Create a Database for WordPress
Inside the MariaDB shell, create a dedicated database for WordPress.
Also create a dedicated database user for that database, and give it only the privileges needed for that specific database. This keeps things more secure than using the root database user for everything.
Keep a note of:
- Database name
- Database username
- Database password
- Database host (usually
localhost)
You’ll need these values for wp-config.php later.
Step 2 – Install and Configure PHP 8.3
WordPress needs PHP. Here we’re using PHP 8.3 with PHP-FPM.
Install PHP 8.3
Install PHP 8.3 and its necessary modules using the package manager.
Make sure PHP-FPM is included. Caddy will talk to PHP through PHP-FPM, not via the command line.
Edit PHP-FPM Pool Configuration
PHP-FPM uses pools to handle requests. Each pool has its own config file.
Open the PHP-FPM pool configuration file for editing.
Adjust the pool settings as needed. At minimum, ensure that:
- The
listendirective matches what you plan to use in your Caddy configuration (for example a Unix socket path or a TCP port). - The user and group settings are appropriate for your setup.
If WordPress’ files are owned by a specific user (for example www-data), the PHP-FPM pool user should match or at least be allowed to read and write where needed.
Restart PHP-FPM
After editing the pool config, restart the PHP-FPM service so your changes take effect.
If PHP-FPM doesn’t restart cleanly, check for typos in the pool configuration file and correct them before moving on.
Step 3 – Install WordPress with WP-CLI
Here we’ll use WP-CLI to install WordPress and set up the basic config.
Install WP-CLI
Install WP-CLI on your server.
Make sure the wp command is accessible from your terminal (for example in /usr/local/bin or similar) so you can run WordPress commands from anywhere.
Create a Directory for Your Domain
Create a directory for your WordPress site based on your domain name. In the original example, the domain is mylabs.com.
Your directory path might look like:
/var/www/mylabs.com
This keeps things neat when you host multiple sites.
Download WordPress Core
Change into that domain directory, then use WP-CLI to download the WordPress core files.
WP-CLI will pull the latest stable WordPress core and put it into the current directory.
Create `wp-config.php`
Still inside the site directory, use WP-CLI to create the wp-config.php file.
When prompted (or via arguments), provide:
- Database name
- Database user
- Database password
- Database host
WP-CLI will also set up secure keys and salts for you, so you don’t have to copy-paste them manually.
Run the WordPress Install
Next, run the WP-CLI command to perform the actual WordPress installation.
You’ll provide:
- Site URL (for example
https://mylabs.com) - Site title
- Admin username
- Admin password
- Admin email
When this finishes, your WordPress database tables and basic settings will be created.
Fix Directory Ownership
Finally, adjust the ownership of the WordPress directory so your web server/PHP-FPM user can read and write files.
Set the user and group to the account that your PHP-FPM pool runs as (for example www-data). This helps avoid permission errors when installing plugins, themes, or doing updates.
Be careful not to make the directory world-writable. Stick to proper user/group ownership instead of chmod 777.
Step 4 – Install and Configure Caddy
Now we’ll install Caddy, then set up a Caddyfile so Caddy serves your WordPress site and forwards PHP requests to PHP-FPM.
Install Caddy
First, add the Caddy repository and GPG key, then install Caddy from that repository.
This gives you the official Caddy build that supports automatic HTTPS via Let’s Encrypt.
Edit the Caddyfile
Open the main Caddyfile for editing.
Remove the default contents so you can start fresh.
Then add a configuration block for your domain (in the example: mylabs.com) and link it to PHP-FPM.
In that block you’ll typically define:
- The site address (your domain name).
- The document root (your WordPress directory).
- A
php_fastcgidirective pointing to your PHP-FPM socket or port. - Basic file serving rules for static assets.
The key point is that Caddy knows:
- Which domain it’s serving.
- Where the site files live.
- How to send
.phprequests to PHP-FPM.
Caddy will handle HTTPS certificates automatically as long as your domain points to the server and ports 80/443 are open.
Validate Caddy Configuration
After editing the Caddyfile, run the Caddy config validation command.
If the configuration is valid, you’ll get a confirmation message. If it finds problems, the output will tell you where to look.
Handle Warnings If Any
If you see a warning, follow the suggested command from Caddy to address it.
This might be about system integration, capabilities, or service configuration. Run the recommended command to tidy things up.
Restart Caddy
Finally, restart the Caddy service so the new configuration is loaded.
If it fails to start, check the journal or logs, correct the Caddyfile, and try restarting again.
Step 5 – Test Your WordPress + Caddy Setup
Now let’s check that everything is actually working, not just “no errors in the console”.
Check the Site and HTTPS
Open a browser and visit your domain, for example:
https://mylabs.com
You should see the WordPress front page. The URL should load over HTTPS with a valid certificate.
If the browser shows certificate errors or fails to connect, double-check:
- DNS is pointing your domain to the server IP.
- Ports 80 and 443 are open in any firewall.
- Caddy is running without errors.
Log In to the WordPress Dashboard
Go to the admin URL, for example:
https://your-domain.com/wp-admin
Log in using the admin username and password you set during the WP-CLI install.
If you can log in and see the dashboard, PHP, MariaDB, and Caddy are all talking to each other correctly.
Test Theme Install and Delete
From the dashboard, try installing a new theme.
- Go to Appearance → Themes.
- Add a new theme and activate it.
- Then delete the theme again.
If this works without permission errors, your file ownership and PHP-FPM user are set correctly for WordPress to manage its own files.
Test Permalinks / URL Rewrite
Next, test WordPress permalinks to make sure URL rewriting is working.
- Go to Settings → Permalinks.
- Change from the default plain structure to something more friendly (for example “Post name”).
- Save your changes.
Visit a few posts or pages using the new URLs.
If they load correctly, your Caddy + PHP-FPM config is handling WordPress rewrites properly.
If you get 404 errors, re-check your Caddyfile rules and make sure directory and php_fastcgi settings match your WordPress location.
Quick Recap and Next Steps
You’ve just:
- Set up MariaDB and created a dedicated database for WordPress.
- Installed PHP 8.3 and configured PHP-FPM.
- Installed WordPress via WP-CLI in a clean domain directory.
- Installed Caddy, wired it to PHP-FPM, and configured your domain.
- Verified HTTPS, dashboard login, theme management, and permalinks.
From here, you can start hardening the server, add backups, or tune PHP-FPM and Caddy for more traffic. But for a clean, working WordPress install on Ubuntu 24.04 with Caddy, you’re good.
Need more help? Check the latest CrushEdge posts.
No Comments