Test Article--THTTPD installation and commissioning

Source: Internet
Author: User
Tags addgroup benchmark bz2 mkdir

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

THTTPD is a very small lightweight web server, it is very simple, just provide http/1.1 and simple CGI support, on its official website has a comparison with other Web server (such as Apache, Zeus, etc.) of the contrast chart +benchmark, You can refer to the reference. In addition, the THTTPD is similar to lighttpd, and instead of using fork () to derive subprocess processing for concurrent requests, it is implemented using multiplexing (multiplex) technology. So the performance is very good.

THTTPD supports a variety of platforms such as FreeBSD, SunOS, Solaris, BSD, Linux, OSF, etc. For small Web servers, the speed seems to be synonymous with the benchmark provided by the official station, it can be said that: thttpd at least as fast as the mainstream Web server, under high load faster, because its resource consumption is small.

THTTPD also has a more compelling feature: URL-based file traffic throttling, which is very convenient for download traffic control. Like Apache, you have to use plug-ins to achieve less efficiency than thttpd.

one. Installation

# 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 Compiles an error because Getline has joined POSIX 2008 and can rename the getline inside extras/htpasswd.c to Get_line or something else.

The name in HTPASSWD.C is the same as the name of the getline in the Stdio.h standard library, resulting in a conflict.

The modified method is to HTPASSWD.C, modify the Getline. Getline in HTPASSWD.C is a static type function that only appears in this file. Find the Getline, and modify it to get_line.

HTPASSWD.C 52nd row definition

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

HTPASSWD.C Line 192th Call

while (!) ( Getline (line,max_string_len,f))) {

Re-make

#make


# AddGroup www//need to create WWW group if prompted Addgroup:command not found

can use

#/usr/sbin/useradd www

# make Install

Make install will report no/usr/local/man/man1 errors, so to

# mkdir Man1

# CD/USR/LOCAL/THTTPD

# mkdir {Etc,logs}

#cd./conf

#vim thttpd.conf

Port=80
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

To see if a process starts

# PS aux | grep thttpd


#vim throttle.conf
*.jpg|*.gif 50000 # for all jpg gif speed limit 50,000 bytes per second
*.mpg 20000 # Speed limit of access to all MPG files 20,000 bytes per second
dir/* 20000 # 20,000 bytes to access all files in the dir/directory for one second


PHP has thttpd compile options, can be used as THTTPD module, so that the php-fpm more than nginx lighttpd Save resources, the corresponding speed is fast. But currently thttpd support for PHP is limited to the version requirements, the search for a talent has 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. Debug thttpd with GdB

Modify the makefile after configure

Default is

CCOPT =-o2

Revision changed to

CCOPT =-g-o0

and modify the THTTPD.C

Increase:

debug=1;

In

if (! Debug)

Before

Because debug is enabled, this does not generate daemons, or it is not easy to debug.

Enable THTTPD

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

Attach GDB Process

#gdb-P Thttpd-pid

(GDB) Break main

(GDB) R

(GDB) L

You can see the code already, or you can print the variable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.