首页 > linux > 轻量型thttpd+php5

轻量型thttpd+php5

2010年10月25日 eric 发表评论 阅读评论

thttpd是一个非常小巧的轻量级web server,它非常非常简单,仅仅提供了HTTP/1.1和简单的CGI支持,thttpd 也类似于lighttpd,对于并发请求不使用fork()来派生子进程处理,而是采用多路复用(Multiplex)技术来实现。因此效能很好。thttpd还有一个较为引人注目的特点:基于URL的文件流量限制,这对于下载的流量控制而言是非常方便的。象Apache就必须使用插件实现,效率较thttpd低。
php有 thttpd 编译选项,可以作为thttpd模块,这样就比nginx lighttpd 的 php-fpm 更节省资源,相应速度要快!但是目前 thttpd 对PHP的支持限于版本的要求,今天搜索搜索到有一达人出了php5.2.11版本的补丁。

下载php-5.2.11-thttpd-2.25b

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

下载 thttpd-2.25b

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

1. 创建用户

thttpd $> groupadd -g 33 www
thttpd $> useradd -g 33  www

2. 编译php-5.2.11 作为 thttpd模块

thttpd $> tar jxvf php-5.2.11-thttpd-2.25b.tar.bz2
thttpd $> cd php-5.2.11
thttpd $> ./configure --prefix=/usr/local/php5 --with-thttpd=/root/thttpd-2.25b   #这里我就默认安装的,你需要什么模块自行添加
thttpd $> make
thttpd $> make install

3.安装 thttpd-2.25b

thttpd $> tar zxvf thttpd-2.25b.tar.gz
thttpd $> cd thttpd-2.25b
thttpd $> ./configure --prefix=/usr/local/thttpd
thttpd $> sed -i 's#getline#get_line#g' extras/htpasswd.c            #在这里必须要修改一下htpasswd.c源码,不然会出现
htpasswd.c:52: error: conflicting types for 'getline'
/usr/include/stdio.h:655: error: previous declaration of 'getline' was here
htpasswd.c:52: error: conflicting types for 'getline'
/usr/include/stdio.h:655: error: previous declaration of 'getline' was here
make[1]: *** [htpasswd.o] Error 1
make[1]: Leaving directory `/root/thttpd-2.25b/extras'
make: *** [subdirs] Error 2
原因是getline 已加入 POSIX 2008,可以把extras/htpasswd.c 里面的getline重命名为get_line或别的。
解决错误参考 :http://blog.lytsing.org/archives/387.html
thttpd $> mkdir -p /usr/local/thttpd/man/man1                        # 安装脚本没有这步,不然会报错!
thttpd $> make
thttpd $> make install

3.添加配置

thttpd $> cd /usr/local/thttpd
thttpd $> mkdir {etc,logs}
thttpd $> cd etc
thttpd $> vim thttpd.conf
port=80
user=www
chroot
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=/var/www
cgipat=/usr/local/thttpd/www/cgi-bin/*
thttpd $> vim throttle.conf
*.jpg|*.gif     50000                      # 对所有  jpg gif  限速   5万字节每秒
*.mpg           20000                      # 对访问所有的 mpg 文件限速 2万字节每秒
dir/*             20000                      # 对访问 dir/  目录下所有文件限速 一秒钟 2万个字节

4. 创建启动文件

thttpd $> vim /etc/init.d/thttpd
#!/bin/bash
COMMAND=/usr/local/thttpd/sbin/thttpd
CONFIG=/usr/local/thttpd/etc/thttpd.conf
PID=`cat /usr/local/thttpd/logs/thttpd.pid`
function_start_thttpd()
{
        printf "Starting THTTPD....\n"
        $COMMAND -C $CONFIG 2>&1 >/dev/null&
}
function_stop_thttpd()
{
        printf "Stoping THTTPD....\n"
        kill $PID
}

if [ "$1" = "start" ]; then
        function_start_thttpd
elif [ "$1" = "stop" ];then
        function_stop_thttpd
else
        printf "Usage: thttpd {start|stop}""
fi

5.访问测试
启动服务

thttpd $> /etc/init.d/thttpd start

在另一台电脑打开浏览器输入 IP

thttpd

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/278.html

分类: linux 标签: ,
  1. 2017年10月22日13:19 | #1

    Hi there, I enjoy reading all of your article post.
    I like to write a little comment to support you.

  2. 2017年10月22日22:56 | #2

    Simply want to say your article is as surprising.
    The clarity in your post is just excellent and i
    can assume you’re an expert on this subject. Well with your permission let me to grab your RSS feed to keep up to date with
    forthcoming post. Thanks a million and please continue the rewarding work.

  3. 2017年10月23日06:25 | #3

    Great beat ! I wish to apprentice while you amend your web site, how could i
    subscribe for a weblog site? The account helped me a applicable deal.

    I had been tiny bit acquainted of this your broadcast provided shiny clear concept

  4. 2017年10月23日08:06 | #4

    Acheter Viagra Europe viagra Cephalexin And Alchol Levitra Zonder Voorschrift

  5. 2017年10月23日11:57 | #5

    Hi there, You’ve done an incredible job. I’ll certainly digg it and personally
    suggest to my friends. I’m sure they will be benefited from this website.

  6. 2017年10月24日17:13 | #6

    Great article, just what I wanted to find.

  7. 2017年10月25日08:13 | #7

    Heya i am for the first time here. I came across this board
    and I find It truly useful & it helped me out much.
    I hope to give something back and help others like you helped me.

  8. 2017年10月25日20:19 | #8

    Hi there, i read your blog occasionally and i
    own a similar one and i was just curious if you get a lot of spam
    feedback? If so how do you protect against it, any plugin or anything you
    can advise? I get so much lately it’s driving me mad so any
    support is very much appreciated.

  9. 2017年10月27日01:41 | #9

    Fantastic beat ! I wish to apprentice even as you amend
    your site, how can i subscribe for a blog web site?

    The account aided me a appropriate deal. I were a little bit familiar of this your broadcast offered brilliant clear concept

  10. 2017年10月27日11:56 | #10

    Thanks a lot for sharing this with all people you actually understand what you are speaking about!
    Bookmarked. Kindly additionally consult with my web site =).
    We could have a link trade contract between us

  11. 2017年10月28日15:41 | #11

    Propecia Hormones Women Acheter Cytotec France viagra prescription Were To Buy Suprax And Sithromax

  12. 2017年10月28日21:21 | #12

    Hi there, just became aware of your blog through Google, and found that it is really informative.
    I’m going to watch out for brussels. I will appreciate if
    you continue this in future. Numerous people will be benefited from your writing.
    Cheers!

  13. 2017年10月29日06:29 | #13

    Teva Sildenafil Citrate Buy Prednisone Dose Pack Online Viagra Sales levitra online overnight delivery Priligy Au Kamagra Jelly Ireland Levitra Comparison

  14. 2017年10月31日12:58 | #14

    What i do not realize is if truth be told how you are now not really a lot more
    neatly-liked than you may be right now. You’re so intelligent.
    You understand thus significantly in the
    case of this matter, made me in my opinion believe it
    from a lot of numerous angles. Its like women and men are not involved until it’s one thing to accomplish with Lady gaga!
    Your individual stuffs nice. Always handle it up!

  15. 2017年10月31日21:13 | #15

    What’s up to every body, it’s my first go to see of this web site; this
    webpage carries awesome and actually excellent data designed for readers.

  16. 2017年10月31日21:52 | #16

    Donde Puedo Comprar Cytotec Sin Receta Viagra Super Aktiv wheretobuylevitrapills Cialis Por Gusto

  17. 2017年11月1日07:17 | #17

    Simply desire to say your article is as astounding.
    The clearness to your put up is simply excellent and i can suppose you are a professional in this subject.

    Well with your permission let me to clutch your RSS feed to keep updated with coming near near post.
    Thanks 1,000,000 and please carry on the enjoyable work.

  18. 2017年11月2日17:56 | #18

    I need to to thank you for this excellent read!! I absolutely loved every bit of
    it. I have you saved as a favorite to look at new things you post…

  19. 2017年11月3日12:33 | #19

    Nice post. I was checking continuously this blog and I am impressed!
    Very useful information specially the last part :
    ) I care for such information a lot. I was seeking this particular info for a very long time.
    Thank you and good luck.

  20. 2017年11月3日17:52 | #20

    WOW just what I was searching for. Came here by searching for hello

  21. 2017年11月3日22:16 | #21

    Excellent post. I was checking continuously this blog and I am inspired!
    Very useful information particularly the ultimate phase :) I care for such
    info a lot. I used to be seeking this particular information for a long time.
    Thank you and good luck.

  22. 2017年11月4日09:16 | #22

    Greate article. Keep writing such kind of information on your blog.
    Im really impressed by your site.
    Hi there, You have done an incredible job. I will definitely digg it and in my opinion suggest to my friends.

    I’m sure they will be benefited from this site.

  23. 2017年11月5日09:58 | #23

    Thank you for the auspicious writeup. It in reality was a
    enjoyment account it. Look complex to more delivered agreeable from you!
    By the way, how can we communicate?

  24. 2017年11月5日19:24 | #24

    I was able to find good advice from your blog posts.

  25. 2017年11月6日02:09 | #25

    Definitely imagine that which you said. Your favorite justification seemed
    to be at the internet the simplest factor to remember of.
    I say to you, I definitely get irked while other people think about worries that they just do not know about.
    You managed to hit the nail upon the top and also
    defined out the entire thing with no need side-effects , other folks could
    take a signal. Will probably be back to get more. Thank you

  26. 2017年11月8日04:33 | #26

    Buy Fucidin Cream Prix Levitra En Ligne Fluoxetine 10mg Cash On Delivery cheap cialis Acquistare Cialis Online Sicuro Kamagra Soft Over Counter Prednisone

  27. 2017年11月8日09:09 | #27

    I am really grateful to the holder of this web site who has
    shared this enormous paragraph at at this place.

  28. 2017年11月11日18:34 | #28

    It’s awesome for me to have a website, which is useful
    for my experience. thanks admin

  29. 2017年11月11日19:42 | #29

    Are you all of them may be more buy in your residense?

  30. 2017年11月12日20:45 | #30

    Hi there, i read your blog occasionally and i own a similar one and i was just wondering if
    you get a lot of spam remarks? If so how do you prevent it,
    any plugin or anything you can suggest? I get so much lately it’s driving me mad so any assistance is very much appreciated.

  31. 2017年11月14日03:22 | #31

    Priligy Precio Online Cialis With No Prescription Keflex Insomnia [url=http://mailordervia.com]buy viagra[/url] Zithromax And Flu Viagra Generique Achat En Ligne

  32. 2017年11月21日22:26 | #32

    Priligy Vs Zoloft Cialis Generico Milano [url=http://ordercheapvia.com]viagra[/url] Online Viagra Und Cialis Kaufen

  33. 2017年11月24日19:51 | #33

    A fascinating discussion is definitely worth comment. I do
    believe that you should publish more about this subject matter, it might not be a
    taboo subject but usually people do not talk about these issues.
    To the next! Best wishes!!

  34. 2017年12月26日07:11 | #34

    casino games
    casino games
    online casino
    casino games
    casino games list

  35. 2017年12月29日17:43 | #35

    free casino games
    real money casino
    free casino games
    casino games
    online casino

  36. 2018年1月2日20:16 | #36

    the best casino
    casino online
    blackjack online casino

  37. 2018年1月6日18:34 | #37

    casino slots
    free slots no download no registration
    casino games online
    free slots games
    free casino games slot

  38. 2018年1月12日12:06 | #38

    where are autocad hatch patterns stored
    autodesk autocad
    autocad for mac student discount

  39. 2018年1月14日18:54 | #39

    I’ve learn some just right stuff here. Certainly price bookmarking for revisiting.

    I surprise how so much effort you place to make such a excellent
    informative site.

  40. 2018年1月15日05:50 | #40

    payday loans no credit check
    loans for bad credit
    loans for bad credit
    loans no credit check
    payday loans online no credit check

  41. 2018年1月18日22:53 | #41

    payday loans
    payday loans no credit check
    payday loans online
    payday loans no credit check
    payday loans online

评论分页
1 2 3 278
订阅评论
3+5= (必填)