如何配置Nginx

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

你可能感兴趣的:(知识管理)