网上大部分文章都是yum(Linux)或者用brew安装。本人机器macos 10.15.2,刚开始使用brew安装不成功,于是选择离线安装。安装Nginx需要用到pcre和openssl,需要提前准备这两个文件。

1.安装openssl

到官网下载安装包,解压后切换到openssl的目录,执行以下命令:

./config --prefix=/usr/local/openssl

看到以下信息表示配置成功。

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************

然后执行以下命令:

make && make install

接着是漫长的等待。如果提示权限:

Cannot create directory /usr/local/openssl: Permission denied

执行以下命令:

sudo chown -R $(whoami) /usr/local/

2.安装pcre

仍然采用离线的方式安装,到下面的地址下载安装包:

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.zip

解压后,切换到解压后的目录输入以下命令:

./configure --prefix=/usr/local/pcre --enable-utf8 --enable-unicode-properties

3.安装nginx

到nginx官网下载安装包解压,并切换到安装目录,执行以下命令:

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

然后屏幕呼呼啦啦一堆代码,最后几行如下:

/configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

啊哈,出错了,提示缺少pcre库,刚才明明已经安装了,说明姿势不对,换个姿势重来。上面的命令不完整,需要指定pcre的目录和openssl的目录,但是这个目录不是安装后的目录,而是刚开始解压的后的位置。执行以下命令(注意with):

./configure --prefix=/usr/local/nginx --with-pcre=/Users/imac/software/pcre-8.36 --with-openssl=/Users/imac/software/openssl-1.1.1n

出现以下内容说明成功

Configuration summary+ using PCRE library: /Users/imac/software/pcre-8.36+ using OpenSSL library: /Users/imac/software/openssl-1.1.1n+ using system zlib librarynginx path prefix: "/usr/local/nginx"nginx binary file: "/usr/local/nginx/sbin/nginx"nginx modules path: "/usr/local/nginx/modules"nginx configuration prefix: "/usr/local/nginx/conf"nginx configuration file: "/usr/local/nginx/conf/nginx.conf"nginx pid file: "/usr/local/nginx/logs/nginx.pid"nginx error log file: "/usr/local/nginx/logs/error.log"nginx http access log file: "/usr/local/nginx/logs/access.log"nginx http client request body temporary files: "client_body_temp"nginx http proxy temporary files: "proxy_temp"nginx http fastcgi temporary files: "fastcgi_temp"nginx http uwsgi temporary files: "uwsgi_temp"nginx http scgi temporary files: "scgi_temp"

执行以下命令:

make && make install

安装成功以后会在/usr/local下出现nginx目录

4、启动nginx

切换到/usr/local/nginx目录,执行以下命令(执行第二条需要数据密码)

cd /usr/local/nginx
sudo sbin/nginx

访问localhost,出现以下界面说明启动成功:

如果是用brew安装出现404,请切换源之后再安装:

brew install nginx
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openssl%401
#=#=#
curl: (22) The requested URL returned error: 404
Error: Failed to download resource "openssl@1.1"
Download failed: https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openssl%401.1-1.1.1g.catalina.bottle.tar.gz

清华源最近好像有问题,请参考另一篇文章macos中brew切换到阿里源_Apple_羊先森的博客-CSDN博客macos中brew切换到阿里源https://blog.csdn.net/caicaimaomao/article/details/123662715

macos 安装nginx相关推荐

  1. 低版本MacOS安装Nginx

    笔者MacOs版本: 10.14.6 背景 高版本MacOs可以直接使用 brew install nginx 进行安装,低版本执行此命令会提示Os is old version导致无法安装,网上又找 ...

  2. MacOS开发必备工具brew,安装nginx反向代理,替代linux工具 apt-get和 yum...

    Mac os开发者必备工具 brew,替代Linux系统中的 apt-get和yum工具,本文介绍Mac电脑安装Homebrew,并下载安装软件nginx反向代理过程. 1.安装Homebrew 在苹 ...

  3. ant centos环境下 编译没有将配置文件加载_你可能忽略的macOS下brew安装nginx细节解读,干货

    大家好,我是路程lucky,热爱开发.设计.学习.生活.爱捣鼓的web前后端工程师,为您带来原创文章,欢迎持续关注~ 今天我们聊一聊macOS下的brew安装nginx,本文重点关注的是安装的细节的解 ...

  4. [学习记录] macOS下的Nginx安装 Nginx基本知识

    [学习记录] macOS下的Nginx安装 && Nginx基本知识 一. 安装相关 1. 安装:直接通过brew安装即可 2. 启动: 3. 成功运行判断: 4. 改端口号:由于80 ...

  5. macOS下nginx配合obs做推流直播.md

    这篇探索起源于给妹子看高清电影 动辄10G的1080P电影对于网速不够快又懒得找高清资源的妹子来说并不方便看 而pandaTV等直播平台显然是不可以直播电影的,于是我就按照google的方法自己推流1 ...

  6. CentOS7安装Nginx及其相关

    一.安装所需环境 gcc 安装 安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装. yum install gcc-c++ PCRE pcr ...

  7. Asp.Net Core 发布和部署( MacOS + Linux + Nginx )

    前言 在上篇文章中,主要介绍了 Dotnet Core Run 命令,这篇文章主要是讲解如何在Linux中,对 Asp.Net Core 的程序进行发布和部署. 有关如何在 Jexus 中进行部署,请 ...

  8. 在Ubuntu中手动安装nginx+nextcloud

    在Ubuntu中手动安装nginx+nextcloud 前言 什么是NextCloud? NextCloud功能 先决条件 步骤1:在Ubuntu 20.04上下载NextCloud 步骤2:在Mar ...

  9. Centos7.4安装Nginx

    Centos7.4安装Nginx 使用yum命令 一.安装准备 首先由于nginx的一些模块依赖一些lib库,所以在安装nginx之前,必须先安装这些lib库,这些依赖库主要有g++.gcc.open ...

最新文章

  1. HDU - 3078 Network 倍增LCA
  2. Seam的中文化支持
  3. SQL Server 2008 R2中文版快速安装
  4. 信道编码之差错控制方式
  5. [原创]敏捷管理实践看板思维导图
  6. python开发小型数据库_python数据库编程小应用
  7. 数据仓库—stg层_手把手教你创建BI数据仓库STG层
  8. 【ABP杂烩】Extensions后缀扩展方法
  9. HDOJ--2544--最短路
  10. Linux 小知识翻译 - 「GCC」
  11. oracle 9i/10g/11g(11.2.0.3)安装包和PATCH下载地址汇总
  12. VB6.0精简版调用matlab进行数值计算:
  13. L2-029 特立独行的幸福 (25 分) 搜索回溯
  14. 高德地图 天气java_高德地图API获取天气
  15. 和block循环引用说再见
  16. 调用android的拍照或本地相册选取再实现相片上传服务器,Android调用系统相机、本地相册上传图片(头像上传(裁剪)、多张图片上传)...
  17. MySQL查询近12个月数据,无则补0
  18. python自学视频与excel_小白也能学习的 python pandas excel 处理[视频]
  19. 2021.05.05青蛙过河
  20. [转]列式数据库之infobright以及架构

热门文章

  1. Uva-755-487--3279
  2. 从Cell学单细胞转录组分析(一):开端
  3. 一个对JAVA不熟悉导致实现造轮子的悲惨故事
  4. abb机器人过载报错_ABB机器人电动机在运行时电流过大导致报警,存在过载现象...
  5. Fundamental Components Of An Event-Driven Archi...
  6. 取mailq队列的邮件
  7. 计算机组成原理——除法运算
  8. 树莓派3B--树莓派屏幕的安装
  9. CMIIT ID是什么意思
  10. 台达PLC modbus通讯地址