HugeServer Knowledgebase

How to install WordPress with Caddy web server on CentOS 7


Caddy is one of the next generation modern web servers written in GO language that’s why the binaries are entirely self-contained and can be run on every platform. In the previous articles, we talked about Caddy web server and it’s easy configuration, as you remember we learned how to install and use it, In this article, we are going to install WordPress and serve it with our Caddy web server. It contains installing and integrating PHP with Caddy which is pretty easy.

  • Caddy is very lightweight and has low resource requirements.
  • Configuration is very simple.
  • Supports HTTP/2.0
  • Caddy is the only web server that uses HTTPS by default.
  • It’s very fast for processing static content.

We are assuming that you have root permission, otherwise, you may start commands with “sudo”.


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

Let’s hit the road

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;

> exit

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.
For more information and news visit the Caddy official website!

Was this tutorial helpful?

Thank you for your vote.Thank you for your vote.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *