在MacOS上安装Nginx

【注意】这里介绍的是基于源码下载安装的方式

下载Nginx

下载地址: http://nginx.org/en/download.html (可以下载Mainline版本,或者下载稳定版)

下载完成之后解压:

tar xvzf nginx-1.23.2.tar.gz

file

下载PCRE

如果直接安装Nginx,会报下面的错误,需要下载pcre:

./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.

下载地址: https://sourceforge.net/projects/pcre/files/pcre/

下载完成之后解压:

tar xvzf pcre-8.45.tar.gz

安装Nginx

  • 进入Nginx目录, 然后运行配置

    cd ~/Downloads/nginx-1.23.2
    ./configure --with-pcre=~/Downloads/pcre-8.45
  • 安装

    sudo make install
  • 安装完成,默认安装在目录 /usr/local/nginx

测试运行

  • 进入安装目录,启动Nginx

    cd /usr/local/nginx/sbin
    sudo ./nginx
  • 浏览器访问http://127.0.0.1,出现“Welcome to nginx”则表示成功
    file

发布者:CoolQA,转转请注明出处:https://www.amwalle.com/more/working/20221126-%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85nginx.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
CoolQA的头像CoolQA
上一篇 2022年11月19日 16:09
下一篇 2022年12月16日 10:01

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理