使用Tengine代替nginx作为web server

发布时间:2017-07-05 10:43:52编辑:丝画阁阅读(310)

enginx是淘宝在nginx的基础做了改进和优化的web server,对于阿里的技术,我还是相当认可的。

详情可以访问这里点击打开链接。下面开始安装

  1. 下载源代码并编译安装。详细参数可以通过./configure --help查阅
    [java]
    1. wget http://tengine.taobao.org/download/tengine-1.5.2.tar.gz
    2. wget http://www.canonware.com/download/jemalloc/jemalloc-3.5.1.tar.bz2
    3. tar zxf tengine-1.5.2.tar.gz
    4. tar jxf jemalloc-3.5.1.tar.bz2
    5. cd tengine-1.5.2
    6. ./configure --prefix=/usr/local/tengine --with-jemalloc=../jemalloc-3.5.1 --dso-path=/usr/local/tengine/modules --dso-tool-path=/usr/local/tengine/modules --with-http_concat_module
    7. make
    8. make install

  2. 启动脚本(如果不习惯tengine这个名称可以改为nginx)
    [java]
    1. cat > /etc/init.d/tengine << EOF
    2. #!/bin/bash
    3. # nginx Startup script for the Nginx HTTP Server
    4. # it is v.0.0.2 version.
    5. # chkconfig: - 85 15
    6. # description: Nginx is a high-performance web and proxy server.
    7. # It has a lot of features, but it's not for everyone.
    8. # processname: nginx
    9. # pidfile: /var/run/nginx.pid
    10. # config: /usr/local/nginx/conf/nginx.conf
    11. nginxd=/usr/local/tengine/sbin/nginx
    12. nginx_config=/usr/local/tengine/conf/nginx.conf
    13. nginx_pid=/usr/local/tengine/logs/nginx.pid
    14. RETVAL=0
    15. prog="nginx"
    16. # Source function library.
    17. . /etc/rc.d/init.d/functions
    18. # Source networking configuration.
    19. . /etc/sysconfig/network
    20. # Check that networking is up.
    21. [ ${NETWORKING} = "no" ] && exit 0
    22. [ -x $nginxd ] || exit 0
    23. # Start nginx daemons functions.
    24. start() {
    25. if [ -e $nginx_pid ];then
    26. echo "nginx already running...."
    27. exit 1
    28. fi
    29. echo -n $"Starting $prog: "
    30. daemon $nginxd -c ${nginx_config}
    31. RETVAL=$?
    32. echo
    33. [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
    34. return $RETVAL
    35. }
    36. # Stop nginx daemons functions.
    37. stop() {
    38. echo -n $"Stopping $prog: "
    39. killproc $nginxd
    40. RETVAL=$?
    41. echo
    42. [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid
    43. }
    44. reload() {
    45. echo -n $"Reloading $prog: "
    46. #kill -HUP `cat ${nginx_pid}`
    47. killproc $nginxd -HUP
    48. RETVAL=$?
    49. echo
    50. }
    51. # See how we were called.
    52. case "$1" in
    53. start)
    54. start
    55. ;;
    56. stop)
    57. stop
    58. ;;
    59. reload)
    60. reload
    61. ;;
    62. restart)
    63. stop
    64. start
    65. ;;

    66. status)
    67. status $prog
    68. RETVAL=$?
    69. ;;
    70. *)
    71. echo $"Usage: $prog {start|stop|restart|reload|status|help}"
    72. exit 1
    73. esac
    74. exit $RETVAL
    75. EOF


http://tengine.taobao.org/



关键字