>  기사  >  백엔드 개발  >  nginx + tomcat7 클러스터 환경 구성

nginx + tomcat7 클러스터 환경 구성

WBOY
WBOY원래의
2016-08-08 09:31:21962검색

CentOS linux에서 tomcat7을 정상적으로 구성

tomcat7을 시작합니다. 액세스 주소는

입니다.

192.168.1.207:8080

192.168.1.208:8080

  • 다음 주소에서 nginx 관련 버전을 다운로드하세요: http://nginx.org/en/download.html 저는 개인적으로 nginx-1.6.2.tar.gz를 사용합니다
  • 리눅스 서버에 nginx 설치 파일을 업로드합니다.
  • 압축 해제 명령 실행: tar -zxvf nginx-1.6.2.tar.gz
  • nginx 설치에 필요한 관련 패키지 명령:
  • yum install -y pcre-devel openssl-devel
  • yum install gcc-c++

nginx 설치 환경 구성:

다음 명령을 실행합니다:

  1. cd nginx- 1.6.2
  2. ./configure --with-http_stub_status_module --with-http_ssl_module

다음 정보인 경우 나타나면 설치 환경이 성공적으로 구성되었음을 나타냅니다.

nginx 경로 접두사: "/usr/local/nginx"
nginx 바이너리 파일: "/usr/local/nginx/sbin/nginx"
nginx 구성 접두사: "/usr/local/nginx/conf"
nginx 구성 파일: "/usr/local/nginx/conf/nginx.conf"
nginx pid 파일: "/usr/local/nginx/logs/nginx.conf" pid"
nginx 오류 로그 파일: "/usr/local/nginx/logs/error.log"
nginx http 액세스 로그 파일: "/usr/local/nginx/logs/access.log"
nginx http 클라이언트 요청 본문 임시 파일: "client_body_temp"
nginx http 프록시 임시 파일: "proxy_temp"
nginx http fastcgi 임시 파일: "fastcgi_temp"
nginx http uwsgi 임시 파일: "uwsgi_temp"
nginx http scgi 임시 파일: "scgi_temp"

nginx 설치

명령 실행: make && make install

성공적인 설치를 나타내는 다음 메시지가 나타납니다.


test -f '/usr/local/nginx/conf/nginx.conf ' || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx. conf.default'
test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/nginx/logs'
test -d '/usr /local /nginx/logs' || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/nginx/logs '
make[1]: `/web/nginx-1.6.2' 디렉토리 종료

시작: /usr/local/nginx/sbin/nginx
닫기:/usr/local/nginx/sbin/nginx -s 중지

nginx 서비스 다시 시작:/usr/nginx/sbin/nginx -s reload

구성nginx로드 밸런싱

실행 명령: vi /usr/local/nginx/sbin/nginx/conf/nginx.conf

수정됨:

worker_processes 2 ;
이벤트 {
Worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive _timeout 65;
#start
업스트림 192.168.1.208{
#세션 문제 해결
ip_hash;
서버 192.168.1.207:8080 가중치=1;
서버 192.168.1.208:8080 가중치=1;
}
#end
server {
listening 80;
server_name 192.168.1.208;
location / {
root html;           #요청은 다음과 같습니다. mysvr

 proxy_pass http://192.168.1.208;
 proxy_redirect default;
에서 정의한 서버 목록으로 리디렉션됩니다. #The timeout 프록시 서버 연결 시 제한 시간은 75초를 초과할 수 없습니다. 한 서버가 충돌하면 10초 후에 다른 서버로 전달됩니다.
Proxy_connect_timeout 10;
} error_page 500 502 503 504 /50x.html;
위치 = /50x.html {
루트 html ;
}
}
}

저장하고 종료합니다.

nginx 서비스를 시작하세요.

http://

192.168.1.208/application name을 방문하세요.

위 내용은 관련 내용을 포함하여 nginx + tomcat7 구성 클러스터 환경을 소개하고 있어 PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.