THTTPD installation and debugging

http://www.acme.com/software/thttpd/

thttpd is a very small and lightweight web server, it is very, very simple, and only provides HTTP/ 1.1 and simple CGI support, there is a comparison chart + Benchmark with other web servers (such as Apache, Zeus, etc.) on its official website, you can refer to it. In addition, thttpd is also similar to lighttpd. For concurrent requests, fork() is not used to derive sub-processes, but multiplex technology is used to implement it. So the performance is very good.

thttpd supports multiple platforms, such as FreeBSD, SunOS, Solaris, BSD, Linux, OSF, etc. For small web servers, fast speed seems to be synonymous. Through the Benchmark provided by the official website, you can think that: thttpd is at least as fast as mainstream web servers and faster under high load because of its small resource footprint.

thttpd also has a more eye-catching feature: URL-based file flow restriction, which is very convenient for download flow control. Like Apache, it must be implemented using plug-ins, which is less efficient than thttpd.

1. Install

# wget http://www.acme.com/software/thttpd/thttpd- 2.25b.tar.gz

# tar zxvf thttpd-2.25b.tar.gz

#cd thttpd-2.25b

#./configure–prefix=/usr/local/thttpd

# make

CentOS 6.4 compile error, because getline has been added to POSIX 2008, you can rename getline in extras/htpasswd.c to get_line or something else.

The name in htpasswd.c is the same as the name of getline in the stdio.h standard library, which leads to a conflict.

The method of modification is to go to htpasswd.c and modify getline. The getline in htpasswd.c is a static type function, and the function will only appear in this file. Find getline in turn and modify it to get_line.


htpasswd.c line 52 definition

static int getline(char *s, int n, FILE *f) {

htpasswd.c line 192 call

while(!(getline(line,MAX_STRING_LEN,f))) {

Remake

#make

# addgroup www // If you need to create a www group, if prompted addgroup: command not found

can be used

# /usr/sbin/useradd www

# make install

When make install, there will be no error of /usr/local/man/man1, so please

#​mkdir man1

# cd /usr/local/thttpd

# mkdir {etc,logs}

#cd ./conf

#vim thttpd.conf

port=80< br> user=www
host=0.0.0.0
logfile=/usr/local/thttpd/logs/thttpd.log
pidfile=/usr/local/thttpd/logs/thttpd.pid
#throttles=/usr/local/thttpd/etc/throttle.conf
#urlpat=*.txt|*.mp3
#charset=utf-8
dir=/usr/www
cgipat =/usr/local/thttpd/www/cgi-bin/*

Start thttpd

# /usr/local/thttpd/sbin/thttpd -C /usr/local/thttpd/conf/thttpd.conf

View Whether the process is started

#ps aux | grep thttpd


#vim throttle.conf
*.jpg|*.gif 50000 # Limit the speed of all jpg gifs to 50,000 bytes per second
*.mpg 20000 # Limit the speed of access to all mpg files of 20,000 Bytes per second
dir/* 20000 # Limit the speed of accessing all files in the dir/ directory to 20,000 bytes per second

php has thttpd compilation option, which can be used as thttpd module, so It saves more resources than nginx lighttpd’s php-fpm, and the corresponding speed is faster! But currently thttpd’s support for PHP is limited to the version requirements, and a master has been searched for a php5.2.11 version of the patch.

# wget http://download2.3tera.net/oss/files/osm/thttpd-2.25b/php-5.2.11-thttpd-2.25b.tar.bz2

# tar jxvf php-5.2.11- thttpd-2.25b.tar.bz2

# cd php-5.2.11

# ./configure –prefix=/usr/local/php-5.2.11 –with-thttpd=/usr/thttpd-2.25b

# make && make install

Two. Use GDB to debug thttpd

Modify the Makefile after configure

The default is

CCOPT = -O2

Modify to

CCOPT = -g -O0

also modify thttpd.c

< p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; line-height:26px"> Add:< /p>

debug=1;

In

if (! debug )

Before

Because debug is enabled, the daemon process will not be generated, otherwise it is not convenient to debug!

Enable thttpd

# /usr/local/thttpd/sbin/thttpd -C /usr/local/thttpd/conf/thttpd.conf

Additional gdb process

#gdb -p thttpd- pid

(gdb) break main

(gdb) r

(gdb) l

It can be seen that the code can be viewed, and the variables can also be printed.

Original address: http://www.voidcn.com/article/p-gilydexa-pc.html

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1665 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.