Install Common (CL)

One C file, no dependencies. Build it in a second, then serve any folder of pages.

The whole thing
git clone https://github.com/commonlang/cl.git
cd cl
make
./cl serve 8000 examples

Then open localhost:8000/hello. Any folder of .html pages works the same way. SQLite support switches on by itself when SQLite is installed, which it is on macOS and most Linux systems.

On your computer

🍎 macOS
  1. Install the compiler if you do not have it. A dialog opens, click Install.
    xcode-select --install
  2. Build and install:
    git clone https://github.com/commonlang/cl.git
    cd cl
    make
    sudo make install      # copies cl to /usr/local/bin
  3. Check: cl words prints the language, and cl serve 8000 examples serves the example page at /hello.

On a web server

The built-in server is for development. For the internet, run Common the way PHP was first run: behind a real web server. Pick whichever you already have.

Caddy, simplest

Keep cl serve running and let Caddy add the domain and TLS.

example.com {
    reverse_proxy localhost:8000
}

Run cl serve 8000 /var/www/site under systemd so it restarts on reboot.

Apache, shared hosting

Copy the cl binary into cgi-bin/ and add to .htaccess:

Action common /cgi-bin/cl
AddHandler common .html
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [L]

The rewrite lines give you clean URLs like /about.

nginx with fcgiwrap
location ~ \.html$ {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/fcgiwrap.socket;
}
location / {
    try_files $uri $uri.html /index.html;
}

Point fcgiwrap at cl cgi. In CGI mode Common reads the standard variables, runs the page named by SCRIPT_FILENAME, and turns go to into a 303.

Before going public
  • Keep your data private. Common's own server never sends databases, secrets or saved email. Behind Apache or nginx, add the same rule (see docs/deploy.md), or keep the database in a folder outside the site.
  • Lock the files down: chmod 600 site.db cl.secret
  • Expect spam on open forms. Email is limited to 20 an hour, but forms like a guestbook have no rate limit yet.

Check it works

cl words          # every word in the language
make test         # the test suite
make sanitize     # the same suite under AddressSanitizer and UBSan

Full details: docs/install.md and docs/deploy.md in the repository.