Beginner Tutorial
This tutorial will help you install, run, and configure Casket for your first time. It assumes you have never used a web server before! (If you have, do the quick start.) Although Casket is very easy to use, it is still expected that you are already familiar with using your machine:
- Extracting, moving, and renaming files
- Managing users and file permissions
- Using the terminal or command line
- Configuring your firewall
With these prerequisites, you're ready to go.
Topics
Download
Download Casket from the download page. Builds are available for most common architectures. You can also build it from source if you prefer.
Install
The file you downloaded is a compressed archive. You'll want to extract the Casket binary (executable file).
Windows
- Right-click the .zip file and choose "Extract All". Choose any folder to extract into, just don't lose track of it. You can delete it when we're done.
- Move the executable to any folder that's easy to get at. For example,
C:\Casket
.
macOS
- Double-click the .zip file to extract it, or run this command:shell
unzip casket*.zip casket
- Next, we will move the Casket binary into a folder where we can execute it easily. Any $PATH location will do:shellIf you get permission denied errors, you'll need to run with sudo.
mv ./casket /usr/local/bin
Linux
- Run this command to extract the archive:shell
tar -xzf casket*.tar.gz casket
- Next, we will move the Casket binary into a folder where we can execute it easily. Any $PATH location will do:shellIf you get permission denied errors, you'll need to run with sudo.
mv ./casket /usr/local/bin
Run
By default, Casket will use the current directory (the directory it is being executed from, not the folder where the binary lives) as the root of the site. This makes it easy to work on sites locally!
Using the terminal or command line, change into the folder where your site is:
cd path/to/my/site
And run Casket:
casket
Load http://localhost:2015 in your browser. If you see a 404 error, then Casket is working but your site is missing an index file.
You can quit Casket by pressing Ctrl+C. It will terminate as gracefully as possible.
Configure
Your site is already fit for production! But it's not ideal, because we happen to running on localhost
(your home computer):
- The site is being served on port 2015, not 80 (the standard HTTP port).
- The site isn't protected with HTTPS.
It's easy to fix both of these simply by telling Casket the name of the site to serve. By "name", we mean a domain name. We'll use example.com
here, but you use your real domain. This next part is only going to work if your computer is accessible from the wider Internet on ports 80 and 443, and your domain name points to the computer you're on. If not, or you don't have a real domain name, then use localhost
as your domain name.
The name of the site is also called the host or hostname. One way to specify the host is with a command line option:
casket -host example.com
The first time you run Casket with a real hostname (not localhost
), you'll be asked to enter your email address. This is because Casket needs to verify you own the domain and to store the certificate safely on disk for you.
After submitting your email address, do you see an error like permission denied
? That's because Casket is trying to bind to ports 80 and 443 for a real site, but doing this requires root or Administrator privileges:
Windows
Right-click cmd.exe and click "Run as Administrator". Then run Casket again:
C:\Casket\casket.exe -host example.com
macOS
Use sudo to run Casket as root:
sudo casket -host example.com
Linux
On a real server, you would consider using setcap like this:
sudo setcap cap_net_bind_service=+ep $(which casket)
casket -host example.com
But for your own computer, running Casket with sudo probably fine:
sudo casket -host example.com
If you got your permissions right and run Casket again, you'll see:
Activating privacy features... done.
https://example.com
http://example.com
Using a real domain name triggers Casket's privacy features, which operate on ports 80 and 443. If you're just using localhost
as your hostname, Casket continues to serve on port 2015 unless you change it with the -port
option.
The command line interface is great for quick Casket configurations. But what if you want to reuse the same config every time? It's easy with the Casketfile.
The Casketfile is a text file that tells Casket how to serve. It usually lives next to your site. Let's make one. Create a file called Casketfile
(no extension), and put one line in it (use your actual domain name, or localhost):
example.com
Casket will automatically find that file when you start it:
casket
This works because the first line of a Casketfile is always the address (or name) of the site to serve.
If the Casketfile is ever in another directory than the current one, you can tell Casket where to get the Casketfile:
casket -conf ../path/to/Casketfile
You almost know enough to be dangerous. Next, learn how to wield the Casketfile. You'll love how easy it is to write.
Or go to docs index.