您现在的位置是:首页 > 文章详情

Mac OS X 10.15 编译和安装 Nginx

日期:2020-02-28点击:468

想在自己电脑里装个 Nginx 来进行各种测试,下面是详细的过程记录:

1. 下载软件

首先建个临时目录 nginx-src 并下载所需软件的源码进行配置

mkdir nginx-src cd nginx-src wget http://nginx.org/download/nginx-1.17.8.tar.gz wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz tar zxvf *.gz cd nginx-1.17.8 ./configure --with-pcre=../pcre-8.41/ --with-http_ssl_module --with-openssl=../openssl-1.1.0g --prefix=/Users/winterlau/nginx

这里我们将 nginx 安装在 /Users/winterlau/nginx 目录下,prefix 指定的路径请使用绝对路径

2. 错误处理

如果在执行 configure 脚本时报如下错误:

checking for OS  + Darwin 19.2.0 x86_64 checking for C compiler ... not found ./configure: error: C compiler cc is not found

尝试执行 gcc 出如下错误

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), ​​​​​​​missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

执行:xcode-select --install  根据界面提示操作

3. 继续安装

./configure --with-pcre=../pcre-8.41/ --with-http_ssl_module --with-openssl=../openssl-1.1.0g --prefix=/Users/winterlau/nginx

可看到相关信息如下:

Configuration summary   + using PCRE library: ../pcre-8.41/   + using OpenSSL library: ../openssl-1.1.0g   + using system zlib library

开始编译安装

make make install

4. 启动 Nginx 并测试

由于默认的 nginx 运行在 80 端口上,因此需要有管理员的权限:

cd ../../nginx sudo sbin/nginx

打开浏览器访问 http://localhost

收工!

原文链接:https://my.oschina.net/javayou/blog/3178944
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章