In this tutorial we will show you how to install Caddy Web Server on CentOS 7. For those of you who didn’t know, KDE is a well-known desktop environment for the Unix-Like systems designed for users who wants to have a nice desktop environment for their machines, It is one of the most used desktop interfaces out there.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation KDE Plasma desktop environment on a CentOS 7 server.
- Automatic HTTPS.
- Easy Deployment.
- Rewrites & Redirects.
- Virtual Hosts.
Install Caddy Web Server on CentOS 7
Step 1. First let’s start by ensuring your system is up-to-date.
yum clean all
yum -y update
Step 2. Installing Caddy web server on CentOS 7.
Install Caddy is quick and easy with run the following command:
curl https://getcaddy.com | bash
After the script finishes, you can run the following command to see where is your Caddy’s binary file:
Your output should be like below:
Step 3. Setting Up Necessary Directories.
Next, create the directories where we will store the Caddy configuration file Caddyfile and SSL certificates:
chown -R root:caddy /etc/caddy
chown -R caddy:root /etc/ssl/caddy
chmod 0770 /etc/ssl/caddy
chown caddy:caddy /var/www
Step 4. Installing Caddy as a System Service.
We also need to create a new SystemD configuration script:
Add following line:
Description=Caddy HTTP/2 web server
; User and group the process will run as.
; Letsencrypt-issued certificates will be written to this directory.
; Always set "-root" to something safe in case it gets forgotten in the Caddyfile.
ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp
ExecReload=/bin/kill -USR1 $MAINPID
; Limit the number of file descriptors; see `man systemd.exec` for more limit settings.
; Unmodified caddy is not expected to use more than that.
; Use private /tmp and /var/tmp, which are discarded after caddy stops.
; Use a minimal /dev
; Hide /home, /root, and /run/user. Nobody will steal your SSH-keys.
; Make /usr, /boot, /etc and possibly some more folders read-only.
; … except /etc/ssl/caddy, because we want Letsencrypt-certificates there.
; This merely retains r/w access rights, it does not add any new. Must still be writable on the host!
; The following additional security directives only work with systemd v229 or later.
; They further retrict privileges that can be gained by caddy. Uncomment if you like.
; Note that you may have to add capabilities required by any plugins in use.
Set the owner and permissions:
chown root:root /etc/systemd/system/caddy.service
chmod 644 /etc/systemd/system/caddy.service
At last, execute the following commands to enable Caddy to run on boot:
systemctl enable caddy
systemctl start caddy
Step 5. Creating Test Web Page and a Caddyfile.
For testing purposes, we will create a test HTML file:
mkdir -p /var/www/idroot.net
echo "Caddy" > /var/www/idroot.net/index.html
chown -R www-data: /var/www/my-domain.com
Next, add our domain to the Caddy configuration file:
Add following line:
Save the file and exit the editor. To apply the changes, restart Caddy:
systemctl restart caddy.service
Now, with a web browser, just go to https://idroot.net, and you will see our test page!
Congratulation’s! You have successfully installed Caddy. Thanks for using this tutorial for installing Caddy web server in CentOS 7 system. For additional help or useful information, we recommend you to check the official Caddy web server web site.