Setting up Caddy with PHP & MySQL Stack on Ubuntu 16.04

Caddy

  1. Inherent security — Https is enabled by default, with redirections. Caddy features On-Demand TLS. This means Caddy can obtain a certificate for your site during the first TLS handshake for a hostname that does not yet have a certificate. This means no hassle with obtaining a certificate. It uses Automatic Certificate Management Environment, a protocol that allows server to obtain https certificate automatically (it uses the same protocol that certbot by EFF uses, only automated). It obtains certificate from Let's Encrypt by default, but it can connect to any ACME compatible Certificate Authority. ACMEv2, which Caddy supports, allows for wildcard certificates. Caddy is able to detect some versions of Man-in-the-Middle attacks.
  2. It is configured to support HTTP/2 and server push by default — a feature that has been lacking, until recently, in major servers like Nginx and Apache, and is still not as straightforward as it should be.
  3. It supports WebSocket connections directly to local programs’ stdin/stdout streams .
  4. It supports brotli compression, as long as the client supports it.
  5. Due to being written in Go, Caddy is memory-safe, and invulnerable to bugs like Heartbleed.

Setting Up the Instance

Installing Caddy

Configuring Caddy

mkdir /etc/caddy
chown -R root:root /etc/caddy
mkdir /etc/ssl/caddy
mkdir /var/log/caddy
chown -R root:www-data /etc/ssl/caddy /var/log/caddy
chmod 0770 /etc/ssl/caddy /var/log/caddy
touch /etc/caddy/Caddyfile
chown root:root /etc/caddy/Caddyfile
chmod 644 /etc/caddy/Caddyfile
chown -R www-data:www-data /var/www
chmod -R 555 /var/www
mydomain.com {
root /var/www
...
}
wget https://raw.githubusercontent.com/mholt/caddy/master/dist/init/linux-systemd/caddy.service
cp caddy.service /etc/systemd/system/
chown root:root /etc/systemd/system/caddy.service
chmod 644 /etc/systemd/system/caddy.service
systemctl daemon-reload
systemctl start caddy.service
systemctl enable caddy.service

Installing MySQL

Installing PHP7.0

ttfb.review {
root /var/www
log /var/log/caddy/ttfb.review.log
errors /var/log/caddy/errors.log

fastcgi / /run/php/php7.0-fpm.sock php {
ext .php
split .php
index index.php
}
}

Conclusion

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Docker Useful Commands

The Impossible Travel Problem

<a href=”https://www.freepik.com/vectors/fantastic">Fantastic vector created by upklyak — www.freepik.com</a>

Tasker and Fitbit Integration

The Journey of making Music Player Android App

Protecting Jenkins using the Datawiza Access Broker (Single-Sign-On and Granular Access Control)

What happens when you type `ls -l *.c` in the shell

Downgrading Kops with Homebrew

Precision T3600 Q4000 E5–1650 V1 3.2 Ghz 16Gb Ram 240Gb SSD

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Appwrite Storage meets limitless S3

Dockerize WordPress by docker-compose

Integration with the SAP Commerce Cloud Build APIs with Jenkins/Sonar Qube

Setup Gitlab Backup into S3 Bucket