一、编译安装模块

如果是原有包中就有的模块,编译时,
./configure --with-xxx 就可以,
如果是第三方模块,可使用 --add-module,
如果有多个模块的话,只需要多次使用-add-module指令即可.

二、下载源码包image_fliter和echo模块

nginx源码下载
http://nginx.org/en/download.html echo模块下载
https://github.com/openresty/echo-nginx-module/tags 解压
gzip -d xxx.tar.gz
tar -zvxf xxx.tar xxx

三.编译

1.安装依赖:

brew install pcre
brew install gd #image filter依赖gd
brew link --force openssl #避免编译openssl时报错

2.cd nginx源码目录

./configure xxx
--prefix 设置编译目录

3.查看原有nginx编译参数

nginx -V

4.添加编译module

./configure \
--with-http_image_filter_module \
--with-debug \
--add-module=/Users/fanfan/web/software/echo-nginx-module-0.61 \
原有编译参数, (注意修改版本目录) ./configure \
--prefix=/usr/local/Cellar/nginx/1.12.2 \
--with-http_ssl_module \
--with-pcre \
--sbin-path=/usr/local/Cellar/nginx/1.12.2/bin/nginx \
--with-cc-opt='-I/usr/local/opt/pcre/include -I/usr/local/opt/openssl@1.1/include' \
--with-ld-opt='-L/usr/local/opt/pcre/lib -L/usr/local/opt/openssl@1.1/lib' \
--conf-path=/usr/local/etc/nginx/nginx.conf \
--pid-path=/usr/local/var/run/nginx.pid \
--lock-path=/usr/local/var/run/nginx.lock \
--http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp \
--http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp \
--http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp \
--http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp \
--http-log-path=/usr/local/var/log/nginx/access.log \
--error-log-path=/usr/local/var/log/nginx/error.log \
--with-http_gzip_static_module --with-http_v2_module \
--with-http_image_filter_module \
--with-debug \
--add-module=/Users/fanfan/web/software/echo-nginx-module-0.61 ------------------------------------------------------------------------------ ./configure --prefix=/usr/local/nginx-1.4.1 --with-http_stub_status_module \
--with-http_realip_module --with-http_image_filter_module --with-debug

5.make

四.安装

1.如果之前未安装nginx

make install

2.如果之前通过brew安装过nginx

/usr/local/bin/nginx   /usr/local/Cellar/nginx/xxx/bin/nginx
/usr/local/opt/nginx /usr/local/Cellar/nginx/xxx
修改软连接,直接指向新的nginx

3.替换编译文件的方式

这种方式,只是替换了bin文件,目录还是原来的

#备份原来的binary
cp /usr/local/opt/nginx/bin/nginx /usr/local/opt/nginx/bin/nginx.bak
#先cd到nginx源码目录
sudo cp objs/nginx /usr/local/opt/nginx/bin/nginx
rm /usr/local/bin/nginx
ln -s /usr/local/opt/nginx/bin/nginx /usr/local/bin/nginx

4.建立版本目录方式

$ cp -r /usr/local/Cellar/nginx/1.8.0 /usr/local/Cellar/nginx/1.9.10
#先cd到nginx源码目录
$ sudo cp objs/nginx /usr/local/Cellar/nginx/1.9.10/bin
#更新/usr/local/opt/nginx
$ rm /usr/local/opt/nginx
$ ln -s /usr/local/Cellar/nginx/xxx /usr/local/opt/nginx
#更新/usr/local/bin/nginx
$ rm /usr/local/bin/nginx
$ ln -s /usr/local/opt/nginx/bin/nginx /usr/local/bin/nginx

5.编辑/Library/LaunchDaemons/homebrew.mxcl.nginx.plist

好像也不用编辑
launchctl load -F /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

五.验证nginx

nginx -V / nginx -v

yld: Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib

nginx版本依赖 jpeg 8d的版本,而brew install jpeg 的时候,安装的是新版9b
可转换成上一版本即可
brew switch jpeg 8d 或者 因为其他版本安装出现此问题,可重新安装,rebuild source,
这样使用的就是最新版本的依赖
brew cleanup //更新cellar
brew reinstall php71 --build-from-source https://stackoverflow.com/questions/32703296/dyld-library-not-loaded-usr-local-lib-libjpeg-8-dylib-homebrew-php

六.重启nginx

nginx -t //验证配置文件是否正确
有可能会有权限问题,启动时,以root用户启动即可
sudo brew services restart nginx

七.参考链接

https://blog.chionlab.moe/2016/02/02/compile-nginx-on-osx/
https://blog.haohtml.com/archives/12349

nginx编译安装on mac的更多相关文章

  1. nginx编译安装

    Nginx编译安装 1.nginx官网:http://wiki.nginx.org/Install下载:http://nginx.org/en/download.html 2.编译安装# wget h ...

  2. LNMP平台搭建之一:nginx编译安装

    参考博客:https://www.cnblogs.com/zhang-shijie/p/5294162.html   jack.zhang 一.环境说明 系统环境:centos6.5 [root@lo ...

  3. Nginx编译安装lua-nginx-module

    lua-nginx-module 模块可以将Lua的强大功能嵌入NGINX服务器. 下载Nginx源码 如果已安装Nginx,需要查看当前安装版本的编译参数: $ /usr/local/nginx/s ...

  4. Nginx编译安装:

    第三方模块 在nginx.org   --------  wiki  找 --add-module=   添加 Nginx编译安装: 安装开发环境 ]# yum groupinstall " ...

  5. [nginx]编译安装及安全优化

    nginx配置-最后整理版 nginx_upstream_check_module nginx-module-vts nginx打补丁 nginx编译安装 - 下载 cd /usr/local/src ...

  6. Linux下nginx编译安装教程和编译参数详解

    这篇文章主要介绍了Linux下nginx编译安装教程和编译参数详解,需要的朋友可以参考下 一.必要软件准备1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码代码如下: # y ...

  7. 20190418 CentOS7实用技能综合:系统安装 + WinScp客户端连接 + 防火墙端口号iptables + Nginx编译安装 + MySQL编译安装 + Redis编译安装 + MongoDB编译安装 + ActiveMQ/RocketMQ/RabbitMQ编译安装 + ...各类常用生产环境软件的编译安装

    系统安装 + WinScp客户端连接 + 防火墙端口号iptables + Nginx编译安装 + MySQL编译安装 + Redis编译安装 + MongoDB编译安装 + ActiveMQ/Roc ...

  8. Nginx编译安装第三方模块http_substitutions_filter_module2222

    Nginx编译安装第三方模块http_substitutions_filter_module Rming -- 阅读 安装 Http 编译 module filter nginx 模块 >> ...

  9. Nginx编译安装第三方模块http_substitutions_filter_module

    Nginx编译安装第三方模块http_substitutions_filter_module 分类:服务器技术  作者:rming  时间:-- . >>ngx_http_substitu ...

随机推荐

  1. LeetCode(59):螺旋矩阵 II

    Medium! 题目描述: 给定一个正整数 n,生成一个包含 1 到 n2 所有元素,且元素按顺时针顺序螺旋排列的正方形矩阵. 示例: 输入: 3 输出: [ [ 1, 2, 3 ], [ 8, 9, ...

  2. Neural style transfer

    网络风格迁移 作者:无用 本文通过学习吴恩达视频所做笔记 目录 简介 可视化卷积层 构建风格迁移网络 一.网络风格迁移简介 二.可视化卷积层 可视化深层卷积网络???这个问题我看过一篇文章,我会在后补 ...

  3. php 爬取数据

    简单. 灵活.强大的PHP采集工具,让采集更简单一点. 简介: QueryList使用jQuery选择器来做采集,让你告别复杂的正则表达式:QueryList具有jQuery一样的DOM操作能力.Ht ...

  4. vim的基本用法

  5. 微服务的发现与注册--Eureka

    目录 服务提供者.服务消费者.服务发现组件三者之间的关系 Eureka 简介 Eureka Server Eureka Client 编写Eureka Server 将微服务注册到Eureka Ser ...

  6. jQuery源码中的“new jQuery.fn.init()”什么意思?

    所有文章搬运自我的个人主页:sheilasun.me 引子 最近打算试试看看jQuery的源码,刚开个头就卡住了.无论如何都理解不了jQuery源码入口部分中的 return new jQuery.f ...

  7. AOJ 2170 Marked Ancestor[并查集][离线]

    题意: 给你一颗N个节点的树,节点编号1到N.1总是节点的根.现在有两种操作: M v: 标记节点v Q v: 求出离v最近的标记的相邻节点.根节点一开始就标记好了. 现在给一系列操作,求出所有Q操作 ...

  8. html的header结构和实例

    HTML header结构 <html> <head> <!-- base标签为页面上的所有链接规定默认地址或默认目标. 通常情况下,浏览器会从当前文档的 URL 中提取 ...

  9. Unity3D 中的面向对象设计 {游戏对象(创建、删除、获取),以及添加修改组件}

    一.创建游戏对象 游戏对象分三种:(1) 将物体模型等资源由Project工程面板拖拽到Hierarchy层次面板中 (2) 由GameObject菜单创建Unity自带的游戏对象,如Cube.Cam ...

  10. jquery $与jQuery

    jquery的兼容 ie8 <script type="text/javascript" src="<%=path%>/js/jquery-3.1.1. ...