centos7安装nginx教程

centos7安装nginx教程

nginx版本:1.20.1

1、下载

wget http://nginx.org/download/nginx-1.20.1.tar.gz

2、安装

yum install pcre-devel openssl-devel -y   #安装依赖包

tar -xzf nginx-1.20.1.tar.gz

cd nginx-1.20.1

./configure --prefix=/usr/local/nginx --with-stream --with-http_ssl_module

make

make install

 

 

增加with-http_sub_module模块("sub_filter"

 

./configure --prefix=/usr/local/nginx --with-stream --with-http_ssl_module --with-http_sub_module

 

 

3、nginx配置

worker_processes  4;

 

pid        logs/nginx.pid;

 

events {

    worker_connections  1024;

}

#tcp端口转发

stream {
  upstream tcpmq {
  server 192.168.1.21:30016;
  }
  server {
  listen 12345;
  proxy_connect_timeout 5s;
  proxy_timeout 20s;
  proxy_pass tcpmq;
  }
}

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;

    client_max_body_size 10m;

    keepalive_timeout  65;

    gzip  on;

   

    upstream schedule-server {

        server 10.210.11.75:8087;

    }

 

    include vhost/*.conf;

 

}

4、启动

/usr/local/nginx/sbin/nginx

posted @ 2021-09-08 09:17  钱哥的博客  阅读(615)  评论(0编辑  收藏  举报