linux下安装nginx

本文详细介绍了如何通过wget下载并配置Nginx1.2.0,处理模块依赖,如PCRE和zlib库,以及如何设置stream代理以支持TCP连接。还涵盖了配置文件示例,包括server块、静态资源代理和MySQL端口转发。
摘要由CSDN通过智能技术生成
  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

配置文件配置

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;
    }
  • 10
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值