This setup shares some scripts to easily setup a Laravel project in Caddy using the caddy-api
service.
Check out this setup for when you have multiple hosts and need a Reverse Proxy. It contains a more detailed explanation on how to use caddy-api
Warning
The configs below are modified slightly from my production environment (where they worked) and I haven't tested them since I changed 'em. Feel free to submit fixes and/or improvements as you find them.
- A VPS with:
- PHP with FastCGI (
sudo apt install php8.1-fpm
) - MySQL (
sudo apt install mysql-server
) - Jq (
sudo apt install jq
) - The neccessary PHP extensions for Laravel (
sudo apt install php-intl php-gd php-zip php-bcmath php-ctype php-curl php-dom php-fileinfo php-mbstring php-pdo php-tokenizer php-xml php-mysql
) - See this article for a full setup guide for Ubuntu 22.04
- PHP with FastCGI (
- Caddy Server 2
This configures Caddy through it's API. You first customize the .caddy.json
files below to your situation. Then you'll send them to Caddy which will configure itself with them.
- Download all scripts below to your server
- Then replace
MYAPP.example
in the scripts below with your app domain name - Next replace
MYAPP
in the scripts with your app name, location of your repo on disk - Now run
./initial-setup-servers.sh
To lock a server behind HTTP Basic Auth:
-
First generate a valid hash with this caddy command:
caddy hash-password --plaintext YOURPASSWORD
-
In the
enable-basic-auth.caddy.json
config replacePASSWORDHASHHERE
with the hash generated by the above command. -
Run
./lock-server.sh staging
or./lock-server.sh production
to lock one of the servers