Nginx 설정 방법

4096 단어 지식 관리
1. 다운로드
wget https://public-storage-bucket.oss-cn-beijing.aliyuncs.com/software/nginx-1.13.11.tar.gz
2. 스트레스 해소:
tar -xvf
시작: / usr / local / nginx / sbin / nginx - c / usr / local / nginx / conf / nginx. conf
3. 해당 설정 설치
yum -y install pcre-devel
yum install -y zlib-devel
yum -y install openssl openssl-devel
./configure --with-http_ssl_module
make
make install
기본 설치 경로:
/usr/local/nginx
4. 프로필 수정
cd //usr/local/nginx/conf/nginx.conf
#user nobody; worker_processes 1;
#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  0;
keepalive_timeout  65;

gzip  on;

 upstream village.web3do.com {
    server 127.0.0.1:8081;
}

upstream expert.web3do.com {
    server 127.0.0.1:8082;
}

upstream company.web3do.com {
    server 127.0.0.1:8083;
}

upstream site.web3do.com {
    server 127.0.0.1:8084;
}

 server {
    listen       80;
    server_name  village.web3do.com;

    location / {
    proxy_connect_timeout   3;  
        proxy_send_timeout      30;  
        proxy_read_timeout      30;  
        proxy_pass http://village.web3do.com;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

}

server {
    listen       80;
    server_name  expert.web3do.com;

    location / {
    proxy_connect_timeout   3;  
        proxy_send_timeout      30;  
        proxy_read_timeout      30;  
        proxy_pass http://expert.web3do.com;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

}
server {
    listen       80;
    server_name  company.web3do.com;

    location / {
    proxy_connect_timeout   3;  
        proxy_send_timeout      30;  
        proxy_read_timeout      30;  
        proxy_pass http://company.web3do.com;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

}

server {
    listen       80;
    server_name  site.web3do.com;

    location / {
    proxy_connect_timeout   3;  
        proxy_send_timeout      30;  
        proxy_read_timeout      30;  
        proxy_pass http://site.web3do.com;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

}

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}


# HTTPS server
#server {
#  listen 443;
#   server_name sjbapi.jishufang.com;
#   ssl on;
#   root html;
#   index index.html index.htm;
#   ssl_certificate   /usr/local/nginx/cert/api-test/214808830740902.pem;
#   ssl_certificate_key  /usr/local/nginx/cert/api-test/214808830740902.key;
#   ssl_session_timeout 5m;
#   ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#   ssl_prefer_server_ciphers on;
#   location / {
#   root html;
#   index index.html index.htm;
#   proxy_pass http://sjbapi.jishufang.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;
#   proxy_set_header Via "nginx";
#   }
#}

}
5. 다시 시작
/usr/local/nginx/sbin/nginx -s reload
6. 방문
주의사항: C + + 컴 파일 환경 이 없 는 서버 도 있 습 니 다.
yum -y install gcc
yum -y install gcc-c++
yum install make

좋은 웹페이지 즐겨찾기