Il fournit les fonctionnalités suivantes:
foo@bar> git clone git://repo.bsdsx.fr/mohawk foo@bar> #ou alors foo@bar> git clone http://git.etoilebsd.net/mohawk foo@bar> #ou alors foo@bar> fetch http://mohawk.bsdsx.fr/sources/mohawk-0.8.tgz && tar xvf mohawk-0.8.tgz foo@bar> cd mohawk foo@bar> make yacc -d -o parse.c parse.y lex -t token.l > token.c cc -O2 -Wall -o mohawk.o -c mohawk.c cc -O2 -Wall -o parse.o -c parse.c cc -O2 -Wall -o token.o -c token.c cc mohawk.c token.c parse.c -lutil -lcrypt -lsbuf -o mohawkOn obtient un binaire que l'on peut qualifier de léger:
dsx@x86-64>ldd mohawk
mohawk:
libutil.so.8 => /lib/libutil.so.8 (0x800654000)
libcrypt.so.5 => /lib/libcrypt.so.5 (0x800764000)
libsbuf.so.5 => /lib/libsbuf.so.5 (0x80087d000)
libc.so.7 => /lib/libc.so.7 (0x80097f000)
dsx@x86-64>ls -l mohawk
-rwxr-xr-x 1 dsx wheel 64296 Apr 15 07:13 mohawk
dsx@x86-64>file mohawk
mohawk: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 8.2, stripped
dsx@x86-32>ls -l mohawk
-rwxr-xr-x 1 dsx wheel 55616 Apr 15 07:23 mohawk
dsx@x86-32>file mohawk
mohawk: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 8.1, stripped
dsx@ia-64>ls -l mohawk
-rwxr-xr-x 1 dsx wheel 138344 Apr 15 07:12 mohawk
dsx@ia-64>file mohawk
mohawk: ELF 64-bit LSB executable, IA-64, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 8.2 (802502), stripped
dsx@sparc64>ls -l mohawk
-rwxr-xr-x 1 dsx wheel 80672 Apr 15 09:11 mohawk*
dsx@sparc64>file mohawk
mohawk: ELF 64-bit MSB executable, SPARC V9, relaxed memory ordering, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 8.1, stripped
Merci à rhaamo pour le sparc64 :)
foo@bar> cat simple.conf
vhost default {
rootdir /tmp
}
foo@bar> ./mohawk -c simple.conf
mohawk: Cannot open or create pidfile '/var/run/mohawk.pid': Permission denied
foo@bar> sudo ./mohawk -c simple.conf
foo@bar> netstat -an -p tcp | grep '*.80'
tcp4 0 0 *.80 *.* LISTEN
tcp6 0 0 *.80 *.* LISTEN
Le serveur est en écoute du port 80 sur toutes les interfaces, en ipv4 et ipv6.
Un simple 'fetch -o - http://localhost/' doit retourner un listing du répertoire '/tmp'.
Les logs confirment que tout va bien:
foo@bar> grep mohawk /var/log/messages Mar 24 19:51:07 bar mohawk[131]: localhost ::1 - "GET / HTTP/1.1" 200 11877En cas de soucis, il suffit d'utiliser le mode 'debug':
foo@bar> sudo pkill mohawk foo@bar> sudo ./mohawk -c simple.conf -d mohawk: started as root without requesting chroot(), warning only Connect on ::[:80] Connect from '::1' Debug: vhost '*' Debug: script_name: '/not_exist' ^Cmohawk: exiting due to signal 2
foo@bar> make prereq tar: Removing leading '/' from member names tar: Removing leading '/' from member names foo@bar> find /tmp/chroot/ /tmp/chroot/ /tmp/chroot/document_root /tmp/chroot/document_root/index.html /tmp/chroot/virtual /tmp/chroot/virtual/bapt.example.com /tmp/chroot/virtual/bapt.example.com/bapt.html /tmp/chroot/virtual/bsdsx.example.com /tmp/chroot/virtual/bsdsx.example.com/bsdsx.html /tmp/chroot/www_virtual /tmp/chroot/www_virtual/localhost /tmp/chroot/www_virtual/localhost/directory /tmp/chroot/www_virtual/localhost/directory/parse.c /tmp/chroot/www_virtual/localhost/directory/parse.y /tmp/chroot/www_virtual/localhost/directory/token.c /tmp/chroot/www_virtual/localhost/directory/token.l /tmp/chroot/www_virtual/localhost/directory/mohawk.c /tmp/chroot/www_virtual/localhost/directory/parse.h /tmp/chroot/www_virtual/localhost/directory/mohawk.h /tmp/chroot/www_virtual/localhost/private /tmp/chroot/www_virtual/localhost/private/private.html /tmp/chroot/www_virtual/localhost/private/.htpasswd /tmp/chroot/www_virtual/localhost/index.html /tmp/chroot/www_virtual/localhost/dirlist.css /tmp/chroot/www_virtual/localhost/print_env.sh /tmp/chroot/etc /tmp/chroot/etc/auth.conf /tmp/chroot/libexec /tmp/chroot/libexec/ld-elf.so.1 /tmp/chroot/lib /tmp/chroot/lib/libc.so.7 /tmp/chroot/lib/libedit.so.7 /tmp/chroot/lib/libncurses.so.8 /tmp/chroot/bin /tmp/chroot/bin/sh /tmp/chroot/usr /tmp/chroot/usr/bin /tmp/chroot/usr/bin/envUne fois rajouté '127.0.0.1 bapt.example.com bsdsx.example.com' dans '/etc/hosts', on peut utiliser le fichier de configuration fourni:
foo@bar> sudo ./mohawk -c mohawk.conf -dLes requêtes suivantes ne devraient pas retourner d'erreur:
fetch -q -o - http://localhost:7777/ fetch -q -o - http://bapt.example.com:8888/bapt.html fetch -q -o - http://bsdsx.example.com:7777/private/status fetch -q -o - http://localhost:8888/directory fetch -q -o - 'http://localhost:8888/non-exists/foo?bar=bar' fetch -q -o - 'http://foo:bar@localhost:8888/private/private.html'
foo@bar> sudo make install install -d /usr/local/sbin install -d /usr/local/bin install -d /usr/local/etc/rc.d install -m 555 mohawk /usr/local/sbin/ install -m 555 rc.d/mohawk /usr/local/etc/rc.d/ install -m 555 htpasswd.sh /usr/local/bin/mhtpasswd.sh install -d /usr/local/man/man8 install -d /usr/local/man/man1 install -m 444 htpasswd.1 /usr/local/man/man1/mhtpasswd.1 foo@bar> echo 'mohawk_enable="YES"' >> /etc/rc.confAttention, aucun fichier ne configuration n'est copié/installé/généré. Par défault, le script de démarrage fait référence à '/usr/local/etc/mohawk.conf'. Un port est également disponible: www/mohawk (merci bapt :)
foo@bar> sudo mkdir /var/log/mohawk && sudo touch /var/log/mohawk/mohawk.log foo@bar> grep mohawk /etc/syslog.conf !mohawk *.* /var/log/mohawk/mohawk.log foo@bar> sudo /etc/rc.d/syslogd reload foo@bar> grep mohawk /etc/newsyslog.conf /var/log/mohawk/mohawk.log 644 7 * @T00 JNComme indiqué dans syslogd, on pourra rajouter l'option '-c':
foo@bar> grep syslogd /etc/rc.conf syslogd_flags="-s -c"
set chroot /usr/home/dsx/chroot
set user nobody
set mime /usr/home/dsx/etc/mime.txt
vhost default {
set rootdir /document_root
set index_name { index.html }
set dirlist_css_url /dirlist.css
set charset iso-8859-1
}
vhost mohawk.bsdsx.fr {
set rootdir /virtual
set no_log { *.ico *.css /robots.txt }
set x_forwarded_for on
set mohawk_name "On ne regarde pas sous les jupes des filles"
}