Ben's

thttpd config 본문

리눅스

thttpd config

Ben Ko (SINCE 2013) 2013. 4. 16. 20:37
728x90

http://pbraun.nethence.com/unix/www/thttpd.html

 

%imgsrc /images/bill.gif

Change the colors

Eventually change the default green background to white,

grep -r COLOR *
vi libhttpd.c

and clean up the BODY tags (two occurences).


note. one could also edit the defaults,

#vi config.h

but they're fine. Even INDEX_NAMES eventually points to index.cgi, already.



Compilation

Create the needed groupthttpd user and group,

groupadd www

note. otherwise you would get this error doing 'make install',

chgrp: invalid group: `www'

Compile and install,

./configure
make clean
make
mkdir -p /usr/local/man/man1/
make install

note. if you get this error doing 'make',

htpasswd.c:52: error: conflicting types for 'getline'

replace 'getline' by 'my_getline' in extras/htpasswd.c (two occurences).



Configuration

Create the web dir and some user,

mkdir -p /var/www/
useradd -g www -d /var/www/ -s /sbin/nologin thttpd

Configure thttpd,

vi /etc/thttpd.conf

like,

dir=/var/www
chroot
user=thttpd
logfile=/var/log/thttpd.log
pidfile=/var/run/thttpd.pid
vhost
charset=utf-8
cgipat=**.cgi

Note. other charsets: 8859-1, 8859-15


Create a virtual host,

mkdir /var/www/host.example.net/

Note. directory listing is enabled as long the directory has the 'x' permission



Usage

Start the daemon,

thttpd -C /etc/thttpd.conf

enable it at boot time,

cat >> /etc/rc.local <<EOF9
echo -n starting thttpd...
/usr/local/sbin/thttpd -C /etc/thttpd.conf && echo done
EOF9

Check the vhost is working. Open your web browser to the URL e.g.,

http: //host.example.net


Todo

Configure a minimal chrooted CGI environment,

mkdir -p /var/www/bin/
cp /bin/ksh /var/www/bin/
cp /bin/cat /var/www/bin/
ldd /var/www/bin/ksh
ldd /var/www/bin/cat
...
mkdir tmp/
chmod 777 tmp
chmod +t tmp
(cd /; tar cvf - dev/tty) | (cd /var/www; tar xvf -)

test it,

chroot /var/www /bin/ksh
cat <<EOF9
check
EOF9
exit

 

 

 

'리눅스' 카테고리의 다른 글

real time 웹로그 보는 툴  (0) 2013.06.04
iftop  (0) 2013.04.22
rm --preserve-root 옵션 소개  (0) 2013.04.08
mv --strip-trailing-slashes 옵션 소개  (0) 2013.04.05
성능 튜닝  (0) 2013.01.21