在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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在macOS安装nginx,你可以按照以下步骤进行操作: 1. 首先,请确保已经安装了Homebrew。如果没有安装,请参考常见问题部分的指南来安装Homebrew。 2. 使用以下命令安装nginx:brew install nginx。这将会下载并安装nginx。 3. 安装完成后,可以使用nginx -v命令来查看已安装nginx版本。 4. 要启动nginx,可以使用命令nginx。 5. 如果想要关闭nginx,可以使用命令nginx -s stop。 6. 如果需要重新加载nginx配置文件,可以使用命令nginx -s reload。 7. 在安装过程中,可能会遇到端口被占用的问题。如果出现类似于"bind() to 0.0.0.0:80 failed (48: Address already in use)"的错误提示,这意味着端口80已经被其他进程占用了。 #### 引用[.reference_title] - *1* *2* [关于MacOSNginx安装及配置](https://blog.csdn.net/BSSMWYT/article/details/122767822)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [Mac 安装 Nginx](https://blog.csdn.net/speedwalkman/article/details/130723412)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值