Suppose you have a directory named ~/www/default.website that contains all the files to implement a website. These can be static files or CGI if the execute bit is set. You can run Althttpd to serve that website as follows:
althttpd -root ~/www -port 8080
The "root ~/www" tells althttpd where to go to find the files for the website. The "-port 8080" option is what tells althttpd to run in stand-alone mode, listening on port 8080.
Stand-alone with HTTPS
If althttpd is built with TLS support then it can be told to operate in HTTPS mode with one of the following options:
althttpd -root ~/www --port 8043 --cert unsafe-builtin
this option uses a compiled-in self-signed SSL certificate which is wildly insecure and is intended for testing purposes only. Use the --cert option to specify your own PEM-format SSL certificate. The argument to --cert can be the concatenation of the SSL private key (often named "privkey.pem") and the certificate chain (often named "fullchain.pem"). Alternatively, the --cert can point to just the fullchain.pem file and the separate --pkey option can point to the privkey.pem file.
Using your own certificate:
althttpd -root ~/www --port 8043 --cert fullchain.pem --pkey privkey.pem
Note that the certificate is read before althttpd drops root privileges, so the certificate may live somewhere inaccessible to the non-root user under which the althttpd process will run.
Stand-alone mode for website development and testing
If you have in a directory the various HTML, Javascript, CSS, and other resource files that together comprise a website and you want to test those files easily, you can type a command like:
althttpd --page index.html
In the above, "index.html
" is the name of the initial HTML page. This
command starts althttpd in stand-alone mode, listening on the first
available port it can find, and bound to the loopback IP address
(127.0.0.1). It also automatically brings up a new tab in your web-browser
and points it to the "index.html" page.
If you are developing the website on a remote system, you can start up as follows:
althttpd --popup
The "--popup" option works similarly to "--page" except that it does not restrict the IP address to loopback and it does not attempt to start up a new web browser tab.