nginx 설치 와 부하 균형
1, 컴 파일 nginx 1.4.5
./configure --help
--prefix=PATH set installation prefix
--user=USER set non-privileged user for worker processes
--group=GROUP set non-privileged group forworker processes
--with-http_ssl_module enable ngx_http_ssl_module
--with-http_stub_status_module enable ngx_http_stub_status_module ---지원 모니터링
--with-http_gzip_static_module enable ngx_http_gzip_static_module ---압축 지원
/ / 컴 파일 매개 변수
./configure --prefix=/usr/local/nginx --user=apache --group=apache --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module
make && make install
2.start nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
netstat -ntlp|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7539/nginx
3. 닫 기
cat /usr/local/nginx/logs/nginx.pid | xargs kill -TERM
다시 시작
cat /usr/local/nginx/logs/nginx.pid | xargs kill -HUP
HUP 다시 시작
TERM, INT 빠 른 정지
USR1 로그 파일 을 다시 열 어 로그 절단 에 사용 합 니 다.
USR2 부 드 러 운 업그레이드 실행 가능 프로그램
QUIT 침착하게 폐쇄 하 다
WINCH 작업 프로 세 스 를 여 유 롭 게 닫 습 니 다.
/ / 테스트 프로필
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
nginx 프로필 형식:
user apache apache;
worker_processes 2; ---cpu 핵 - 1
....
event{}
http{
....
upstream {}
server{}
}
#######################
1. IP 기반 가상 호스트
/ / 프로필 수정
vim /usr/local/nginx/cong/nginx.conf
server {
listen 10.10.54.231:80;
server_name 10.10.54.231;
root /var/www/html;
charset utf-8;
access_log logs/www.access.log main;
location / {
index index.html index.htm;
}
}
/ / IP 주소 추가
ifconfig eth0:0 10.10.54.231 netmask 255.255.255.0
2. 도 메 인 이름 기반 가상 호스트
http{
......
server {
listen 80;
server_name www.nclub.com;
charset utf-8;
access_log logs/www.access.log main;
location / {
index index.html index.htm;
root /var/www/html;
}
}
server {
listen 80;
server_name bbs.nclub.com;
location / {
root /var/www/bbs;
index index.html;
access_log logs/bbs.nclub.com.log;
}
}
}
3. tomcat 설치
[root@s01 jdk]# tar xvf apache-tomcat-7.0.52.tar.gz
[root@s01 jdk]# mv apache-tomcat-7.0.52 /usr/local/tomcat
/ / tomcat 에 JAVA 홈 디 렉 터 리 추가
[root@s01 bin]# vim /usr/local/tomcat/bin/catalina.sh ---96 줄
JAVA_HOME=/usr/java/jdk1.7.0_51
CATALINA_HOME=/usr/local/tomcat
/ / 자동 시작 스 크 립 트 만 들 기
[root@s01 bin]# cp catalina.sh /etc/init.d/tomcat
[root@s01 bin]# chmod +x /etc/init.d/tomcat
[root@s01 bin]# vim /etc/init.d/tomcat
[root@s01 bin]# chkconfig --add tomcat
/ / tomcat 설정 사용자 관리
[root@s01 conf]# pwd
/usr/local/tomcat/conf
[root@s01 conf]# vim tomcat-users.xml
4. nginx 부하 균형
/ / 프로필
vim /usr/local/nginx/conf/virtual/www.nclub.com.conf
user apache apache;
worker_processes 2;
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
gzip on;
include virtual/www.nclub.com.conf;
}
/ / 프로필
vim /usr/local/nginx/conf/virtual/www.nclub.com.conf
upstream www_nclub_com {
server 10.10.54.222:10080 max_fails=3 weight=1 fail_timeout=60s;
server 10.10.54.226:8090 max_fails=3 weight=2 fail_timeout=60s;
}
server {
listen 80;
server_name www.nclub.com;
charset utf-8;
access_log logs/www.access.log main;
index index.html;
location / {
proxy_pass http://www_nclub_com;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
######################
./configure --prefix=/usr/local/nginx --user=apache --group=apache --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module
make
make install
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.