5-minute quickstart
Minisleep comes with working example server configs that you can run in-place.
Option 1: lighttpd
Lighttpd's configuration files tend to be simpler than that of Apache.
1. Install lighttpd on your computer. Eg:
sudo xbps-install lighttpd # Void
sudo apt-get install lighttpd # Devuan, Debian, Ubuntu, Mint, etc
sudo yum install lighttpd # Fedora
2. Enter the folder 'minisleep/docs/lighttpd'
3. Try to run lighttpd with the provided config:
$ lighttpd -f lighttpd.conf -D
You may need to provide the full path of lighttpd, depending on your distro:
$ /usr/sbin/lighttpd -f lighttpd.conf -D
If you want to edit any pages: the username is 'david' and the password is 'magic'.
If you plan to use Lighttpd yourself then pay attention to:
- Enabling server.follow-symlink
- Inserting mod_auth and mod_cgi in the right order to avoid module-loading problems.
- Configuring page expiry, so that browsers don't keep old copies of pages cached.
Option 2: Yaws
"Yet Another Webserver" also has a nice config file format.
1. Install yaws
2. Enter the folder 'minisleep/docs/yaws'
3. Run yaws with the provided config:
If you want to edit any pages: the username is 'david' and the password is 'magic'.
If you intend to use Yaws yourself then note:
- Yaws aggressively caches pages by default. You may have to wait up to 30 seconds before refreshing will show changed page contents.
Option 3: Hiawatha
Hiawatha is another easy to configure webserver with some really nice features and a long history. It's not in the Debian repos but many other distros package it.
1. Install hiawatha
2. Enter the folder 'minisleep/docs/hiawatha/'
3. Get your current path using the 'pwd' command:
$ pwd
/home/valentine/library/code/minisleep/docs/hiawatha
4. Edit hiawatha.conf to reflect this path:
set START_POINT=/home/valentine/library/code/minisleep/docs/hiawatha
5. Run hiawatha with the provided config:
If you want to edit any pages: the username is 'david' and the password is 'magic'.
If you want to use Hiawatha yourself then note:
- MaxRequestSize (for uploading page edits with lots of big images)
- Enabling FollowSymlinks
Full installation procedure
(1) Obtain a HTTP webserver that supports CGI. If you are on a
shared host then one will probably have already been setup for you,
otherwise I recommend you install lighttpd or apache (two of the most popular options).
Further down this document is the
section "Tip: Testing CGI" that will make your life easier.
(2) Choose two URLs for minisleep to use. One URL for all of
the normal static pages to be under and one special URL for the editor's CGI
script. Valid choices include:
http://example.com/minisleep/
http://example.com/minisleep.cgi
http://example.com/
http://example.com/cgi-bin/editor.cgi
http://example.com/bobs_barbarians/
http://example.com/cgi-bin/bruce.cgi
...etc...
Note: Many webservers only allow you to enable HTTP auth for folders, not files. This means you may have to put the CGI file into its own special folder (eg cgi-bin/).
(3) Download
and extract your copy of minisleep somewhere safe. Do not extract it
into anywhere that your HTTP server will serve (as you would with many php
websites). Instead keep it somewhere such as your home directory where
other people cannot get access to it.
(4) Edit your minisleep 'config' to reflect your chosen URLs:
export URLPUBLIC='/bobs_barbarians'
export URLCGI='/cgi-bin/bobs_barbarians.cgi'
(5) Update minisleep's pages to reflect the changes made to this config file, otherwise the links on the pages will be broken:
$ source config
$ scripts/rebuild_all_pages.sh
(6) Add two symbolic links between your minisleep setup and your web server's WWW directory to reflect your chosen URLs. Examples include:
# On a shared host
ln -s ~/minisleep/public ~/public_html/bobs_barbarians
ln -s ~/minisleep/scripts/minisleep.cgi ~/public_html/cgi-bin/bobs_barbarians.cgi
# On my own server
ln -s ~/minisleep/public /var/www/html/bobs_barbarians
ln -s ~/minisleep/scripts/minisleep.cgi /var/www/html/cgi-bin/bobs_barbarians.cgi
(7) Configure your webserver to allow following symlinks. Some disable this by default.
At this point your install of minisleep should be working. Try it out in your browser.
(8) Enable HTTP auth for the editor URL (so that people need a username+password to edit pages).
For apache and many shared hosts: you can enable this feature using a .htaccess and a .htpasswd file. See the documentation of your webserver/host for more details.
Example (working) configurations for several webservers are included in the docs/ directory.
(9) Setup TLS (https) so that you can access and edit your website securely. If you do not do this then it is possible for attackers to sniff and steal login credentials whenever you use them, especially if you are on an untrusted network (eg open wifi).
Lets Encrypt is a popular free service for obtaining HTTPS certificates and many shared hosting providers automatically set you up with a free certificate anyway.
Managing HTTP authentication credentials (users)
The most common way of managing HTTP auth credentials is to use the 'htpasswd' utility. This tool "should" come with your HTTP server, but some distros only bundle a copy with apache. On Debian based distros it's separated into the apache2-utils package.
Use it like so:
$ htpasswd -c myauthfile.htpasswd bobuser # First time usage requries '-c' to create the file
$ htpasswd myauthfile.htpasswd another
$ htpasswd myauthfile.htpasswd thirduser
Htpasswd supports some better hash types than it's default of apr1 (a variant of MD5), but make sure your webserver actually supports them before you try to use them. I have found many webservers simply ignore what they don't understand.
Hiawatha comes with its own version of htpasswd called
wigwam.
If you have troubles getting a copy of htpasswd then a shell-script imitation is provided in the docs/ directory. It requires an openssl variant to be installed (generally true for any Linux server these days).
If all else fails: many HTTP servers also support 'plaintext' passwd files like this:
bob:bobs password in the clear
mary:turduckinator 3000
admin:password
If you are on a shared host then this may be unwise, as there's a higher chance of someone finding a way to read your files and find your passwords. Generally speaking: avoid using plaintext passwords.
Things you do not need to do
1. Tell minisleep where it's installed.
The symlinks are enough. Minisleep works out the rest.
I wish more website engines did this! Most require you to hardcode their locations (into multiple files too). That's just silly, the computer can do this work for you.
2. Setup an SQL database.
Minisleep keeps pages as files and folders. There is little to Minisleep that isn't hierarchical, so a relational database is not really beneficial.
Tip: Testing CGI
It's worth testing CGI with a simple script before trying to get Minisleep working.
Create a text file with the following contents:
#!/bin/sh
printf 'status: 200\n'
printf 'content-type: text/html\n'
printf '\n'
echo '<b> Moo said the cow </b>'
echo '<p> If you can read this then CGI is working. </p>'
Depending on your host & setup you will need to work out where to save it and under what name. Examples include:
If applicable: enable CGI for the relevant URL in your HTTP server's configuration. Examples for some webservers are in the docs/ directory, otherwise see your particular server's official documentation.
Make the script executable:
$ chmod a+x /var/www/html/mytest.cgi
Now browse to the relevant URL in your web browser. If everything is working then you will see:
If
instead you see the sourcecode to your script, are prompted to download
the script or get an error: CGI is not yet setup correctly.
Recommendation: Use https
(If you are running minisleep on your home LAN or in another controlled network then you can safely ignore this section).
Every
time you login to a website you will want to make sure your connection
is encrypted and secured. If it's not then people can steal your
username+password and do all sorts of naughty things to your website.
This isn't a problem unique to Minisleep, which is why the vast majority
of websites now support HTTPS.
Every
single HTTP server and environment has a different way of setting up
TLS/SSL/HTTPs. You also need to create or get a valid certificate -- as
of the time of writing
lets encrypt is a very popular free service.
If you are on a shared host then they may be able to do this for you (and some do it automatically for free without asking).