Mac 环境快速安装 Homebrew & Nginx 教程

Homebrew 是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。

Nginx 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。它由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点开发,第一个公开版本0.1.0发布于2004年10月4日。Nginx将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。

安装 Homebrew

如果之前尝试过其他脚本安装,请移除Homebrew后再安装,具体请参考 FAQ 。

/bin/bash -c $(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)

在安装中如果出现下面的错误提示则说明需要使用代理软件(FanQiang)。

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

以 ClashX客户端(详情:https://sockboom.love/auth/register?affid=824500)为例,可以复制其终端代理命令在终端执行即可,示例:

export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890

然后继续执行最前面的安装命令。如果安装过程还遇到其它问题可以查看:https://brew.idayer.com/guide/start/

安装 Nginx

Homebrew安装好以后就可以安装 Nginx 了,在终端输入下面命令:

brew install nginx

这个安装过程会有点长,需要耐心等待,显示下面内容表明安装成功:

Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that

nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To start nginx now and restart at login:

  brew services start nginx

Or, if you don’t want/need a background service you can just run:

  /usr/local/opt/nginx/bin/nginx -g daemon\ off\;

然后再执行下面命令启动 Nginx。

brew services start nginx

这个时候在浏览器访问 http://localhost:8080/ ,看到一个 Nginx 的欢迎页面就大功告成了!

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

赞 (3) 打赏

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏