博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ubuntu 17.04 编译安装 Nginx 1.9.9
阅读量:7105 次
发布时间:2019-06-28

本文共 2819 字,大约阅读时间需要 9 分钟。

hot3.png

Nginx

Ubuntu 17.04 编译安装 Nginx 1.9.9

安装

安装依赖

$ apt-get update$ apt-get install build-essential libtool libpcre3 libpcre3-dev zlib1g-dev openssl openssl-devel```		### 下载并解压```sh	$ cd /opt/$ wget http://nginx.org/download/nginx-1.9.9.tar.gz$ tar zxvf nginx-1.9.9.tar.gz```	### 编译编译时候可以指定编译参数,参考文章尾部:**常用编译选项**```sh$ cd nginx-1.9.9$ ./configure --prefix=/usr/local/nginx ```	### 安装```sh$ make$ make && make install```	默认安装在`/usr/local/nginx`里面有四个目录: - conf: 配置文件夹,最重要文件是nginx.conf - html: 静态网页文件夹 - logs: 日志文件夹 - sbin: nginx 的可执行文件,启动、停止等操作 ## 常用命令### 正确性检查每次修改nginx配置文件后都要进行检查```sh$ /usr/local/nginx/sbin/nginx -t
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

启动

$ /usr/local/nginx/sbin/nginx

浏览器输入本机IP ,看到如下内容证明安装成功

Welcome to nginx!If you see this page, the nginx web server is successfully installed and working. Further configuration is required.For online documentation and support please refer to nginx.org.Commercial support is available at nginx.com.Thank you for using nginx.

停止

$ /usr/local/nginx/sbin/nginx -s stop

重启

$ /usr/local/nginx/sbin/nginx -s reload

常用编译选项

./configure \--prefix=/home/nginx \--sbin-path=/usr/sbin/nginx \--user=nginx \--group=nginx \--conf-path=/etc/nginx/nginx.conf \--error-log-path=/home/log/nginx/error.log \--http-log-path=/home/log/nginx/access.log \--with-http_ssl_module \--with-http_gzip_static_module \--with-http_stub_status_module \--with-http_realip_module \--pid-path=/home/run/nginx.pid \--with-pcre=/home/software/pcre-8.35 \--with-zlib=/home/software/zlib-1.2.8 \--with-openssl=/home/software/openssl-1.0.1i

选项说明

--prefix=/home/nginx \ Nginx安装的根路径,所有其它路径都要依赖该选项--sbin-path=/usr/sbin/nginx \ nginx的可执行文件的路径(nginx)--user=nginx \ worker进程运行的用户--group=nginx \ worker进程运行的组--conf-path=/etc/nginx/nginx.conf \  指向配置文件(nginx.conf)--error-log-path=/var/log/nginx/error.log \ 指向错误日志目录--http-log-path=/var/log/nginx/access.log \  设置主请求的HTTP服务器的日志文件的名称--with-http_ssl_module \  使用https协议模块。默认情况下,该模块没有被构建。前提是openssl与openssl-devel已安装--with-http_gzip_static_module \  启用ngx_http_gzip_static_module支持(在线实时压缩输出数据流)--with-http_stub_status_module \  启用ngx_http_stub_status_module支持(获取nginx自上次启动以来的工作状态)--with-http_realip_module \  启用ngx_http_realip_module支持(这个模块允许从请求标头更改客户端的IP地址值,默认为关)--pid-path=/var/run/nginx.pid \  指向pid文件(nginx.pid)设置PCRE库的源码路径,如果已通过yum方式安装,使用–with-pcre自动找到库文件。使用–with-pcre=PATH时,需要从PCRE网站下载pcre库的源码(版本4.4 – 8.30)并解压,剩下的就交给Nginx的./configure和make来完成。perl正则表达式使用在location指令和 ngx_http_rewrite_module模块中。--with-pcre=/home/software/pcre-8.35 \ 指定 zlib(版本1.1.3 – 1.2.5)的源码解压目录。在默认就启用的网络传输压缩模块ngx_http_gzip_module时需要使用zlib 。--with-zlib=/home/software/zlib-1.2.8 \指向openssl安装目录--with-openssl=/home/software/openssl-1.0.1i

Contact

  • 作者:鹏磊
  • 出处:
  • Email:
  • 版权归作者所有,转载请注明出处
  • Wechat:关注公众号,搜云库,专注于开发技术的研究与知识分享

关注公众号-搜云库

转载于:https://my.oschina.net/yanpenglei/blog/1601573

你可能感兴趣的文章
函数指针
查看>>
MongoDB聚合运算之mapReduce函数的使用(11)
查看>>
Docker简明教程(转)
查看>>
Java -- 获取MAC地址
查看>>
URL中的#
查看>>
Linux下Jenkins服务器搭建
查看>>
iOS知识点汇总
查看>>
一起谈.NET技术,MonoTouch中的MVC简介
查看>>
Sql Server导入Access数据库报不可识别的数据库格式 Microsoft JET Database Engine
查看>>
目标检測的图像特征提取之(一)HOG特征
查看>>
jdbctemplate中的query(sql,params,mapper)与queryForList(sql,params,class)区别
查看>>
Type mismatch: cannot convert from java.sql.PreparedStatement to com.mysql.jdbc.PreparedStatement
查看>>
chrome 谷歌浏览器插件损坏
查看>>
ArcGIS API for Silverlight 当DataGrid选中项时,地图聚焦弹出窗口,并可以播放音频文件...
查看>>
BWA MEM算法
查看>>
Linux基础命令---chkconfig
查看>>
微信api 源码分享
查看>>
博客计划【推荐系统】
查看>>
Android开发之旅:android架构
查看>>
新闻发布系统,真正了解了么?
查看>>