linux 下安装nginx

yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

yum -y install openssl openssl-devel
若出现error: the HTTP gzip module requires the zlib library
yum install -y zlib-devel

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

指定路径安装nginx./configure --prefix=/home/SpringBoot/nginx/nginx --with-http_ssl_module --with-stream

make && make install

  1. wget http://nginx.org/download/nginx-1.2.0.tar.gz
    2.tar zxvf nginx-1.2.0.tar.gz
    3.cd nginx-1.2.0
    4…/configure --with-stream
    若出现error: the HTTP rewrite module requires the PCRE library.
    yum -y install pcre-devel
    若出现error: the HTTP gzip module requires the zlib library
    yum install -y zlib-devel
    出现错误,一般都是少插件,yum install -y 即可
    代理tcp,需要使用stream,所以这里要加–with-stream
    5.make
    6.make install
    7.Nginx 默认安装到/usr/local/nginx
    8.配置文件在 nginx.conf
    8.cd /usr/local/nginx/sbin
  2. 启动 ./nginx -c /usr/local/nginx/conf/nginx.conf
    10.停止 ./nginx -s stop
    11.重启 ./nginx -s reload
    12.平滑重启 kill -HUP 主进程
    13.从容的停止:kill -QUIT 主进程
    14.快速停止:kill -TERM 主进程
    15 ./nginx -t 检查配置文件 ./nginx -t -c /usr/local/nginx/conf/nginx.conf

Ubuntu系统Nginx的安装方式
一、直接apt安装
** 如果本机安装了nginx,卸载nginx

apt-get --purge autoremove nginx

检查本机是否还有nginx程序在后台运行,如果有直接kill掉。

ps -ef | grep nginx

1、默认版本安装
方便简单,很多依赖都自动给安装好了,一个命令即可:

apt-get update

apt-get install nginx

2、选择其它版本安装
首先查看有什么版本

apt-get update

apt-cache show nginx

在这里插入图片描述

发现有2个版本可以安装,还伴随了其他版本信息的显示。然后选择我们想要的版本按照即可

apt-get install nginx=1.18.0-0ubuntu1.3

3、目录说明
/usr/sbin/nginx:主程序,启动文件
/etc/nginx:存放配置文件
/var/www/html:存放项目目录
/var/log/nginx:存放日志

一般自动安装配置文件目录和主程序目录不变,因为版本原因,其它目录可能会变,但是都可以从配置文件里ngxin.conf里找到对应的位置。

4、nginx管理命令
service nginx start

service nginx restart

service nginx stop
————————————————
版权声明:本文为CSDN博主「IT东东歌」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u014225032/article/details/125283332

使用
#http://www.hbzwfw.gov.cn/default/
#代理转换服务器

server {
        listen       9000;
        server_name  www.hbzwfw.gov.cn;
        #server_name  192.168.200.4;
        #限制上传文件的大小
     client_max_body_size 50m; 
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        
        location /default/newAj/ {
            proxy_pass   http://192.168.200.4:9001/newAj/;
        }
        location /default/fujian {
            proxy_pass   http://192.168.200.5:8000/;
        }
        location /default/ {
               proxy_pass   http://192.168.200.4:19000/default/;
               proxy_set_header   Host             $host;
               proxy_set_header   X-Real-IP        $remote_addr;
               proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
    }

#stream代理可以代理mysql端口转发

stream{
        upstream socket_proxy{
                 server 193.168.237.8:9001;
        }
        server{
                 listen 9004;
                 proxy_pass socket_proxy;
        }
}

##静态资源代理

        location / {
           autoindex on;   #启用目录列表功能
           autoindex_exact_size off; #显示出文件的确切大小,单位是bytes.改为off后,显示出文件的大概大小
           autoindex_localtime on;   #默认为off,显示的文件的GMT时间. 改为on后,显示的是文件的服务器时间
        
            #root   E:/layui/layui-master/;
            root    E:/layui/data/;
            #root   html;
            index  index.html index.htm;
        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值