The CLMP stack
Instead of the regular LAMP (Linux, Apache, MySQL, PHP) stack, we’ll be swapping out the Apache webserver with Caddy.
Why Caddy? Caddy is my go-to choice for web servers. What makes it stand out is its automatic HTTPS setup, straightforward configuration, and modern protocol support like HTTP/3. While it’s easier to set up than NGINX or Apache, Caddy tends to use more resources and has a smaller ecosystem. It’s great for WordPress and small-to-medium projects, but for high-traffic sites or complex configurations, NGINX or Apache may be a better fit. However, for small projects like this, it would be a great choice.
Procedure
Step 1: Install Mysql
Start by updating your package lists and installing MySQL:
Secure your installation with:
Then log in to MySQL:
Create a database for WordPress:
Remember to replace ‘wordpressuser‘ with your username and ‘password’ with your password. Take note of the username, password, and your host (localhost) as this will be entered once more when WordPress configuration begins.
Step 2: Install PHP
WordPress requires PHP, so install PHP and its required modules:
Step 3: Install Caddy
Caddy is a powerful web server that automatically manages SSL certificates. Install it with these commands:
Step 4: Download and extract WordPress
Navigate to the web root directory and download WordPress:
Step 5: Configure DNS
Log into your domain registrar and add an ‘A’ record pointing your domain to your server’s IP address:
- Name:
@for root domain orwwwfor subdomain - Type:
A - TTL: 1 hour or default
- Value: Your server’s public IP address
Step 6: Configure Caddy for WordPress
Edit Caddy’s configuration file (/etc/caddy/Caddyfile):
Modify the Caddyfile contents:
In this configuration, replace yourdomain.com with your actual domain or IP address. At the time of writing, the php-fpm version is 7.4. Check your php-fpm version in the /run/php directory and modify the configuration to match your php-fpm version.
Step 7: Start and Enable Caddy
Enable and start Caddy to ensure it runs on boot:
Step 8: Finalize WordPress Setup
Open your browser and visit http://yourdomain.com to complete the WordPress setup process.
Final Notes
This tutorial covers only the setup of the CLMP stack. Further configuration of WordPress should follow and the credentials for the database we setup earlier will need to be entered once more. After that, the rest of the steps will be straightforward and you’ll have your own instance of WordPress attached to your custom domain.