当前位置:   article > 正文

MacOS 安装Nginx,记录安装过程及nginx编译过程_macos nginx编译

macos nginx编译

MacOS 安装Nginx,记录安装过程及nginx编译过程

MacOS安装nginx的方式有几种,可以通过brew install nginx的方式,也可以向本次记录的一样,采用下载nginx的tar.gz包,在本地进行编译。

1 下载nginx

wget https://nginx.org/download/nginx-1.18.0.tar.gz
tar zxf nginx-1.18.0.tar.gz 
cd nginx-1.18.0
  • 1
  • 2
  • 3

下载后进入到nginx的源码目录,

 $ ls
CHANGES    LICENSE    auto       configure  html       src
CHANGES.ru README     conf       contrib    man
  • 1
  • 2
  • 3

2 编译nginx

编译配置选项在这个名为configure的文件里面,里面设置了各种参数

ll
total 1520
-rw-r--r--   1 1001  1001   296K  4 21  2020 CHANGES
-rw-r--r--   1 1001  1001   451K  4 21  2020 CHANGES.ru
-rw-r--r--   1 1001  1001   1.4K  4 21  2020 LICENSE
-rw-r--r--   1 1001  1001    49B  4 21  2020 README
drwxr-xr-x  25 1001  1001   800B  4 21  2020 auto
drwxr-xr-x  11 1001  1001   352B  4 21  2020 conf
-rwxr-xr-x   1 1001  1001   2.4K  4 21  2020 configure
drwxr-xr-x   6 1001  1001   192B  4 21  2020 contrib
drwxr-xr-x   4 1001  1001   128B  4 21  2020 html
drwxr-xr-x   3 1001  1001    96B  4 21  2020 man
drwxr-xr-x   9 1001  1001   288B  4 21  2020 src
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

在目录中直接运行,如果先在一台机器上安装多个nginx,这时就需要修改configure文件。

case ".$NGX_PREFIX" in
    .)
        NGX_PREFIX=${NGX_PREFIX:-/usr/local/nginx1.21.6}
        have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
    ;;

    .!)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
sudo ./configure
checking for OS
 + Darwin 20.6.0 x86_64
checking for C compiler ... found
 + using Clang C compiler
 + clang version: 13.0.0 (clang-1300.0.29.30)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

看生成的的后续打印情况,里面有没有提示缺少依赖

./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.
  • 1
  • 2
  • 3
  • 4

提示缺少依赖,先根据提示情况进行安装

$ brew install pcre
==> Downloading https://ghcr.io/v2/homebrew/core/pcre/manifests/8.45
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pcre/blobs/sha256:fb2fefbe12327
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Pouring pcre--8.45.big_sur.bottle.tar.gz
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/264475
推荐阅读
相关标签