Nginx 安装笔记

nginx下载:http://nginx.org/en/download.html

       需要依赖包,pcre (重定向rewrite功能支持), openssl(https功能支持)

       1.tar –xzvf nginx1.10-tar.gz

       2.进入nginx1.10目录执行:

       ./configurate–help查看参数信息

     ./configure --prefix=/usr/local/nginx --with-openssl=/usr/local/openssl --with-http_stub_status_module --with-pcre=/usr/local/pcre-8.38/  --with-http_image_filter_module  --without-http_gzip_module --add-module=/usr/local/fastdfs-nginx-module/src --with-http_ssl_module

例:

./configure--prefix=/mnt/nginx --with-http_stub_status_module --with-pcre=/mnt/pcre-8.38/--without-http_gzip_module --with-http_ssl_module

--with-http_ssl_module 支持https时需要使用的模块,可以通过 —with-openssl指定openssl位置,不指定则使用系统默认。

--perfix:配置编译,安装目录

--with-ipv6 加上支持ipv6协议

--with-http_stub_status_module : 查看监控http请求连接状态的模块,

                                                    location /nginx_status {
                                                        stub_status on;
                                                        access_log off;
                                                     }

--with-openssl : 指定openssl安装位置

--with-http_image_filter_module:安装imagefilter模块,以后可以提供图片缩略图。

--without-http_gzip_module:不适用gzip模块。

--add-module=/usr/local/fastdfs-nginx-module/src: 添加fastdfs模块支持fastdfs系统

       3.make编译,然后makeinstall 安装即可。

       4.进入usr/local/nginx/sbin 命令:./nginx启动即可。

       5.按照需要配置usr/local/nginx/conf/nginx.conf文件。

       6.例子: 如要负载到tomcat ,修改nginx.conf添加如下:

           location/ {   

                    proxy_connect_timeout   3;   

                    proxy_send_timeout      30;   

                    proxy_read_timeout      30;   

                    proxy_pass http://localhostHi

            }

 

           upstream localhostHi {      

                server localhost:8080 weight=10;   

               #server localhost:8081 weight=10;   

           }

 

              红色部分的域名必须一致,是负载域名。

              完成后重启nginx,直接访问ip即可,不需要加8080端口了,因为nginx默认监听在80端口,浏览器访问默认是80端口。

              重新加载配置文件: ./nginx –s reload

                注意: nginx处理response code > 300的错误时, 需要启用:proxy_intercept_errors on; 该配置默认关闭,

               可用于:http, server, location内

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值