nginx安裝配置+叢集tomcat:Centos和windows環境

來源:互聯網
上載者:User

標籤:

版本:nginx-1.8.0.tar.gz官網:http://nginx.org/en/download.html      版本:apache-tomcat-6.0.44.tar.gz 官網:http://tomcat.apache.org/ 1、安裝指令碼:        # yum clean all   # yum makecache# yum update # yum install wget# wget -c http://nginx.org/download/nginx-1.7.9.tar.gz # find -name nginx# yum remove nginx # cd /下載目錄# tar -zxv -f nginx-1.7.9.tar.gz # rm -rf nginx-1.7.9.tar.gz# mv nginx-1.7.9  /usr/local/nginx # yum install gcc-c++
# yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel # cd /usr/local/nginx# ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf# make && make install 2、啟動/重啟/停止/        啟動:# /usr/local/nginx/sbin/nginx 重啟:# /usr/local/nginx/sbin/nginx -s reload 停止:#查詢nginx主進程號 :ps -ef | grep nginx#停止進程 :kill -QUIT 主進程號 
#快速停止 :kill -TERM 主進程號 
#強制停止 :pkill -9 nginx 3、開機啟動,啟動指令碼        

1、編寫開機啟動指令碼,在/etc/init.d/目錄:vi /etc/init.d/nginx    

2、變更指令碼許可權:chmod 775 /etc/init.d/nginx或:chmod a+x /etc/init.d/nginx     (a+x ==> all user can execute 所有使用者可執行)
3、編寫指令碼內容: #################################!/bin/bash# nginx Startup script for the Nginx HTTP Server# it is v.0.0.2 version.# chkconfig: - 85 15# description: Nginx is a high-performance web and proxy server.#              It has a lot of features, but it‘s not for everyone.# processname: nginx# pidfile: /var/run/nginx.pid# config: /usr/local/nginx/conf/nginx.confnginxd=/usr/local/nginx/sbin/nginxnginx_config=/usr/local/nginx/conf/nginx.confnginx_pid=/var/run/nginx.pidRETVAL=0prog="nginx"# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ ${NETWORKING} = "no" ] && exit 0[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ];then   echo "nginx already running...."   exit 1fi   echo -n $"Starting $prog: "   daemon $nginxd -c ${nginx_config}   RETVAL=$?   echo   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx   return $RETVAL}# Stop nginx daemons functions.stop() {        echo -n $"Stopping $prog: "        killproc $nginxd        RETVAL=$?        echo        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid}# reload nginx service functions.reload() {    echo -n $"Reloading $prog: "    #kill -HUP `cat ${nginx_pid}`    killproc $nginxd -HUP    RETVAL=$?    echo}# See how we were called.case "$1" instart)        start        ;;stop)        stop        ;;reload)        reload        ;;restart)        stop        start        ;;status)        status $prog        RETVAL=$?        ;;*)        echo $"Usage: $prog {start|stop|restart|reload|status|help}"        exit 1esacexit $RETVAL####################### 4、設定開機啟動:chkconfig nginx on或:vi /etc/rc.local 加入一行 /etc/init.d/nginx start 儲存並退出,下次重啟會生效。 5、這樣在控制台就很容易的操作nginx了:查看Nginx目前狀態、啟動Nginx、停止Nginx、重啟Nginx…/etc/init.d/nginx status/etc/init.d/nginx start/etc/init.d/nginx stop/etc/init.d/nginx restart 4、nginx負載平衡配置:叢集tomcat          windows下直接解壓,點擊nginx.exe即可啟動,常用命令如下(.exe可去掉)【此為後台運行方式;windows下nginx不自己註冊系統服務,需要依賴第三方工具處理註冊表資訊比較複雜;】:cd nginx目錄下;啟動:nginx.exe 或雙擊停止:nginx.exe -s stop重新載入:nginx.exe -s reload退出:nginx.exe -s quit;

 

nginx安裝配置+叢集tomcat:Centos和windows環境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.