Caddy, sometimes clarified as the Caddy web server, is an open source, HTTP/2-enabled web server written in Go. It uses the Go standard library for its HTTP functionality.A variety of web site technologies can be served by Caddy, which can also act as a reverse proxy and load balancer.


  • Virtual hosting.
  • Native IPv4 and IPv6 support.
  • Serve static files.
  • Graceful restart/reload
  • Reverse proxy.
  • Load balancing with health checks.
  • FastCGI proxy.


We are going to need an installed and configured Caddy web server with a “systemd” service, If you don’t have it installed, use the following article:

How to Install Caddy Web server on CentOS 7

If you have all of the prerequisites ready, we can start right away. 

 Install and configure MySQL database

We are going to install MariaDB (an official fork of MySQL database) as our database which is necessary for WordPress:

yum install mariadb-server

After the installation is finished you can go ahead and start the “Secure installation” script for primary configuration:


Choose a password for “root” user and disallow access for remote login with root user for better security, (you can answer the rest of the questions with “Y”)

Now login with root user to create a database and user for WordPress:

mysql -u root -p
create database test;
grant all privileges on test.* to 'admin'@'localhost' identified by 'password';
flush privileges;

Install and configure PHP and PHP-FPM

In order to install and run WordPress, we need to have PHP installed can integrate with Caddy, Also WordPress is depended on some PHP extensions which we will install it with the command below:

yum install php php-fpm php-mbstring php-gd php-xml php-curl php-mcrypt

As soon as the installation process is complete run the following commands to start the “php-fpm” service and make it run as startup:

systemctl start php-fpm
systemctl enable php-fpm

We need to make some changes to PHP-FPM because by default only Apache can use it, So open the following file with your text editor:

nano /etc/php-fpm.d/www.conf

Find the following lines:

user = apache
; RPM: Keep a group allowed to write in log dir.
group = apache

Then change the value of “user” and “group” like below:

user = caddy
; RPM: Keep a group allowed to write in log dir.
group = caddy

Save and exit.

Restart the “php-fpm” service to take effect:

systemctl restart php-fpm

Configuring Caddy to serve WordPress

Open the famous “Caddyfile” configuration with your text editor:

nano /etc/caddy/Caddyfile

If your file is empty it’s great, if it’s not then exit the text editor and run the following command first:

echo "" > /etc/caddy/Caddyfile

Paste the following lines in your Caddyfile then save and exit:

    tls admin@YOUR_DOMAIN
    root /var/www/wordpress
    fastcgi / php
    rewrite {
        if {path} not_match ^\/wp-admin
        to {path} {path}/ /index.php?_url={uri}

Restart your Caddy service to take effect:

systemctl restart caddy

Download and Install WordPress

switch to your web server’s root directory:

cd /var/www

Download the WordPress using “WGET”:


Extract the “tar.gz” file with the command below:

tar xvzf latest.tar.gz

After the extraction process is complete execute the following command to set the correct permissions for WordPress files:

chown -R caddy:caddy wordpress/

That’s it, you can go ahead and Install your WordPress using your domain or your public IP address.

Was this answer helpful? 0 Users Found This Useful (0 Votes)