mac 安装nginx

1. 安装PCRE(这个简单不多说了)

pcre-8.34.tar解压后

cd 到对应目录下。

cd ~
cd pcre-8.34

我直接安装在local里面

sudo ./configure --prefix=/usr/local

sudo make
sudo make install

2、安装或者更新Mac的openssl

我是直接删除掉原有的openssl再重新编译安装。

sudo rm -rf /usr/local/openssl 删除 自己寻找下mac里面的目录,如果没有则跳过这个。

http://www.openssl.org 下载最新的版本

解压之,cd openssl的文件目录

./config --prefix=/usr/local/openssl 指定安装目录 会报下面的警告

Configured for darwin-i386-cc.

wanzhihuideMacBook-Pro:openssl-1.0.2e wanzhihui$ sudo ./config --prefix=/usr/local/ --openssldir=/usr/local/openssl darwin64-x86_64-cc

Operating system: i686-apple-darwinDarwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64

WARNING! If you wish to build 64-bit library, then you have to

         invoke './Configure darwin64-x86_64-cc' *manually*.

         You have about 5 seconds to press Ctrl-C to abort.

网上找好了好多都没很好解决。最后发现是

openssl/config脚本猜对你的系统是64位,但是 会根据$KERNEL_BITS来判断是否开启x86_64编译,默认 是不开启的(很奇怪的设置,虽然会给你5秒时间停止编译并手动开启),所以你生成的openssl库文件是32位的,最后静态链接到nginx会出错。目 前看来没有很好的方法把x86_64的参数传到openssl配置文件中 (openssl/config 猜测os架构,设置编译的参数是32位还是64位,默认是32位,然后调用openssl/Configure生成Makefile)

我的解决方法:

找到makefile 将里面的PLATFORM=dist改成

PLATFORM=darwin64-x86_64-cc

在终端工具中再敲入

export KERNEL_BITS=64

sudo ./config darwin64-x86_64-cc  --prefix=/usr/local/openssl 

配置完成

sudo make

编译完成

sudo make install

安装

不编译64位的在安装nginx时会报链接错误。

-L/usr/local/lib -lpcre /usr/local/openssl/lib/libssl.a /usr/local/openssl/lib/libcrypto.a -lz

ld: warning: ignoring file /usr/local/openssl/lib/libssl.a, file was built for archive which is not the architecture being linked (x86_64): /usr/local/openssl/lib/libssl.a

ld: warning: ignoring file /usr/local/openssl/lib/libcrypto.a, file was built for archive which is not the architecture being linked (x86_64): /usr/local/openssl/lib/libcrypto.a

Undefined symbols for architecture x86_64:

  "_ASN1_GENERALIZEDTIME_print", referenced from:

      _ngx_ssl_stapling_ocsp_handler in ngx_event_openssl_stapling.o

  "_ASN1_d2i_bio", referenced from:

      _ngx_ssl_stapling in ngx_event_openssl_stapling.o

  "_BIO_ctrl", referenced from:

      _ngx_ssl_get_raw_certificate in ngx_event_openssl.o

      _ngx_ssl_get_serial_number in ngx_event_openssl.o

      _ngx_ssl_stapling_ocsp_handler in ngx_event_openssl_stapling.o

  "_BIO_free", referenced from:

这样的错误。所以openssl一定要生成正确。

安装nginx

下载最新版本nginx版本 http://nginx.org

1、解压文件,并cd 到目录

2、./configure  --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=/usr/local/openssl

3、配置完成 sudo make

4、编译完成 sudo make install

如果PCRE 有自己的指定目录则需要在configure 后面加入路径配置。

这样就可以在local 目录下看到

local xxxx $ ls

bin include lib nginx openssl share ssl

说明安装成功。

sudo /usr/local/nginx/sbin/nginx 启动命令

用浏览器打开 http://localhost 则会出现

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.

  
--关闭命令

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

配置完成!















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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

虾米神探

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值