thttpd Web server 使用


httpd 是 busybox 中自帶的 web server,功能弱,不支持認證和 CGI。
thttpd 支持認證 CGI,功能比較全,所以選擇 thttpd 作為 web server。

下面是 thttp 的介紹:


            thttpd - tiny/turbo/throttling HTTP server
                    version 2.25b of 29dec2003

thttpd is a simple, small, portable, fast, and secure HTTP server.

Simple: It handles only the minimum necessary to implement HTTP/1.1.

Small: See the size comparison chart at
http://www.acme.com/software/thttpd/notes.html#sizes.  It also has a
very small run-time size, since it does not fork and is very careful about
memory allocation.

Portable: It compiles cleanly on FreeBSD 2.x/3.x, SunOS 4.1.x, Solaris 2.x,
BSD/OS 2.x, Linux 1.2.x, OSF/1 (on a 64-bit Alpha), and no doubt many others.

Fast: In typical use it's about as fast as the best full-featured servers
(Apache, NCSA, Netscape).  Under extreme load it's much faster.

Secure: It goes to great lengths to protect the web server machine
against attacks and breakins from other sites.

It also has one extremely useful feature (URL-traffic-based throttling) that
no other server currently has.

See the manual entry for more details.  See the INSTALL file for
configuration and installation instructions.  Check the web page
(http://www.acme.com/software/thttpd/) for updates, or add yourself to
the mailing list by sending a "subscribe" to thttpd-announce-request@mail.acme.com.

Comments to:
    Jef Poskanzer  jef@mail.acme.com  http://www.acme.com/jef/


下載 source code & compiler 後(方法)
將 contrib/redhat-rpm/thttpd.conf 複製到 target board 的 /etc/

修改 thttpd.conf 你所需要的設定

# This section overrides defaults
dir=/home/httpd/html
chroot                                                             ## chroot 要不要拿掉,不知道,不知道哪裡有差
user=httpd# default = nobody
logfile=/var/log/thttpd.log
pidfile=/var/run/thttpd.pid
# This section _documents_ defaults in effect
port=8000                                                    ## web server port number
# nosymlink# default = !chroot
# novhost
# nocgipat
cgipat=/cgi-bin/*                                          ## cgi 的路徑,以 dir 為根目錄
# nothrottles
# host=0.0.0.0
# charset=iso-8859-1

# thttpd -C /etc/thttpd.conf
執行後,便可以用 web browser 就可瀏覽。

將 index.html 複製到 target board 的 /home/httpd/htm/
將 cgi-bin/printenv 複製到 target board 的 /home/httpd/htm/cgi-bin/


再用web browser 瀏覽,如果出現下面
403 forbidden.
The requested URL '/' resolves to a file which is marked executable but is not a CGI file;
retrieving it is forbidden.


 chmod -x /home/httpd/htm/index.html
  chmod 755 /home/httpd/htm/cgi-bin/printenv 

http://ip-address:8000
http://ip-address:8000/cgi-bin/printenv



reference: http://personlin118.pixnet.net/blog/post/846126-thttpd%E4%BD%BF%E7%94%A8%E4%BB%8B%E7%B4%B9




留言

這個網誌中的熱門文章

NMEA標準格式 -- GPS

網路 Transformer 的用途

cut,sed,awk 字串處理