tengine 安裝

1.安裝依賴包css

yum install gcc gcc-c++ autoconf automake openssl   openssl-develhtml

2.上傳解壓 tengine並進入nginx

3.而後執行, ./configure --prefix=/usr/local/nginx並編譯make & make install  完成安裝c++

4.啓動tengine,進入目錄查看web

關閉後再設置開機自動啓動,不然會出現問題!vim

5.設置開機啓動  vim /etc/init.d/nginxtomcat

或者(http://blog.csdn.net/awj3584/article/details/38036539)bash

#加入以下內容cookie

#!/bin/bash
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
  
# Source function library.
. /etc/rc.d/init.d/functions
  
# Source networking configuration.
. /etc/sysconfig/network
  
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
  
TENGINE_HOME="/usr/local/nginx/"
nginx=$TENGINE_HOME"sbin/nginx"
prog=$(basename $nginx)
  
NGINX_CONF_FILE=$TENGINE_HOME"conf/nginx.conf"
  
[ -f /etc/sysconfig/nginx ] && /etc/sysconfig/nginx
  
lockfile=/var/lock/subsys/nginx
  
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
  
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
    killall -9 nginx
}
  
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
  
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
  
force_reload() {
    restart
}
  
configtest() {
    $nginx -t -c $NGINX_CONF_FILE
}
  
rh_status() {
    status $prog
}
  
rh_status_q() {
    rh_status >/dev/null 2>&1
}
  
case "$1" in
start)
    rh_status_q && exit 0
    $1
;;
stop)
    rh_status_q || exit 0
    $1
;;
restart|configtest)
    $1
;;
reload)
    rh_status_q || exit 7
    $1
;;
force-reload)
    force_reload
;;
status)
    rh_status
;;
condrestart|try-restart)
    rh_status_q || exit 0
;;
*)
  
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esacsession

6.設置權限並開機自動啓動(

或者:

[root@example ~]# cp nginx /etc/init.d/
[root@example ~]# chmod 755 /etc/init.d/nginx
[root@example ~]# chkconfig --add nginx

三、nginx啓動、中止、無間斷服務重啓

[root@example ~]# service nginx start

[root@example ~]# service nginx stop

[root@example ~]# service nginx reload

chmod +x /etc/init.d/nginx

chkconfig nginx on

service nginx start

7. tengine 配置tomcat 集羣:

    1.安裝jdk  並上傳tomcat,設置環境變量(這次略過)

    2.設置配置文件,tengine.conf,具體ip地址根據本身的需求配置

 

#user  nobody;
worker_processes  auto; #進程數量:和cpu核數綁定
events {
    worker_connections  2048; #鏈接worker數
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    upstream
nginx{
       session_sticky cookie=uid fallback=on path=/  mode=insert option=indirect;
       server 192.168.189.203:8080   weight=1;
       server 192.168.189.203:8081   weight=1;
       check interval=3000 rise=2 fall=5 timeout=1000 type=http;
       check_http_send "HEAD /index.jsp HTTP/1.0\r\n\r\n";
       check_http_expect_alive http_2xx http_3xx;
    }
    server {
        listen       80;
server_name  10.37.49.185;#訪問nginx的ip
        location / {
            session_sticky_hide_cookie upstream=nginx;
            proxy_pass
http://nginx;
            proxy_set_header  Host  $host;
            proxy_set_header X-Real-IP $remote_addr;
            root   html;
            index  index.html index.htm;
        }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ #實現靜態資源訪問

    { 

      root /data/tomcat/webapps/; #靜態資源路徑

      if (-f $request_filename) { 

        expires 1d; 

        break; 

      } 

     }  

       location /status {
         check_status ;#多個tomcat的健康檢查
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

截圖說明:

相關文章
相關標籤/搜索