nginx 소스 코드 설치 - centos 7
1. 지정 한 디 렉 터 리 에 가방 다운로드
wget http://nginx.org/download/nginx-1.16.1.tar.gz -P /tmp
2. 압축 해제 팩
tar -zxvf /tmp/nginx-1.16.1.tar.gz -C /tmp
3. 의존 팩 설치
yum -y install gcc
yum -y install zlib-devel
yum -y install pcre-devel
yum -y install openssl-devel
4. nginx 설정 컴 파일 설치
cd /tmp/nginx-1.16.1
./configure
make
make install
5. 기본 경로 로 시작
cd /usr/local/nginx/sbin
./nginx
6. 웹 페이지 방문 ip (selinux, iptables 를 먼저 닫 을 수 없습니다)
setenforce 0 # selinux
systemctl stop firewalld
7. 포트 변경
cd /usr/local/nginx/conf
vi nginx.conf
8. 시동 설정, 두 가지 방법 중 하 나 를 취하 면 됩 니 다.
방법 1: echo '/ usr / local / nginx / sbin / nginx' > / etc / rc. localchmod u + x / etc / rc. local 방법 2: [root@localhost# cat < EOF > / lib / system / system / ngix. service \ # Nginx 서비스 시스템 시작 파일 만 들 기 [Unit] 설명 = nginxAfter = network. target
[Service]Type=forkingExecStart=/usr/local/nginx/sbin/nginxExecReload=/usr/local/nginx/sbin/nginx -s reloadExecStop=/usr/local/nginx/sbin/nginx -s quitPrivateTmp=true
[Install]WantedBy=multi-user.targetEOF
systemctl daemon-reload && systemctl start nginx && \systemctl enable nginx && systemctl status nginx
9. nginx 는 간단 한 부하 균형 을 설정 합 니 다.
cat </usr/local/nginx/conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://192.168.1.10:8080;
proxy_pass http://192.168.1.10:8081;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
EOF
다음은 상용 설정 을 소개 합 니 다.
10. 정상 대리
// 80 192.168.10.10 80
upstream www.wukc.com{ // ,
server 192.168.10.10:80; // ip
}
server{
listen 80; // 80
location /{
proxy_pass http://www.wukc.com;
index index.html index.php;
}
}
11. 서로 다른 포트 에 따라 전송
// 80 192.168.10.10 80 , 8080 192.168.10.20 8080
upstream www.wukc.com{
server 192.168.10.10:80;
}
upstream www.wukc2.com{
server 192.168.10.20:8080;
}
server{
listen 80;
location /{
proxy_pass http://www.wukc.com;
index index.html index.php;
}
}
server{
listen 8080;
location /{
proxy_pass http://www.wukc2.com;
index index.html index.jsp;
}
}
12. 네 가지 부하 균형
1: : , down ,
upstream www.wukc.com{
server 192.168.10.10:80;
server 192.168.10.20:80;
}
server{
listen 80;
location /{
proxy_pass http://www.wukc.com;
index index.html index.php index.jsp;
}
}
2:ip_hash: ip hash , , session 。
upstream www.wukc.com{
ip_hash;
server 192.168.10.10:80;
server 192.168.10.20:80;
}
server{
listen 80;
location /{
proxy_pass http://www.wukc.com;
index index.html index.php index.jsp;
}
}
3:weight: ,weight , 。
upstream www.wukc.com{
server 192.168.10.10:80 weight=10;
server 192.168.10.20:80 weight=20;
}
server{
listen 80;
location /{
proxy_pass http://www.wukc.com;
index index.html index.php index.jsp;
}
}
4: fair : ,
upstream www.wukc.com{
server 192.168.10.10:80 weight=10;
server 192.168.10.20:80 weight=20;
fair;
}
server{
listen 80;
location /{
proxy_pass http://www.wukc.com;
index index.html index.php index.jsp;
}
}
13. 로 컬 퍼 가기 에이전트 (서로 다른 접미사 기반)
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
location ~ \.php$ { // .php , 800
proxy_pass http://127.0.0.1:800;
}
location ~ \.jsp$ { // .jsp , 8080
proxy_pass http://127.0.0.1:8080;
}
location ~ \.(jpg|png)$ { // .jpg .png , /img
root /img;
}
}
14. 서로 다른 방문 경로 가 서로 다른 서비스 설정 으로 전송
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# upstream,
upstream kubesphere{
server 172.21.210.10:30880;
}
upstream harbor{
server 172.21.210.20:80;
}
server {
listen 443;
server_name localhost;
location /kubesphere { # upstream
proxy_pass http://kubesphere; # upstream , upstream
}
location /harbor {
proxy_pass http://harbor;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.