Mac Nginx 安装(最新系统版本安装,包含M1) |
您所在的位置:网站首页 › mac系统最新 › Mac Nginx 安装(最新系统版本安装,包含M1) |
安装 Nginx 可以通过 HomeBrew 进行安装,也可以通过 Nginx Download 下载安装包进行安装,这里我们就选择 HomeBrew 的方式进行安装了。 搜索 Nginx 包,查询要安装的软件是否存在 $ brew search nginx(可选使用) 查看 Nginx 包、安装、启动、存放、等信息 $ brew info nginx dengzemiaodeMacBook-Pro:~ dengzemiao$ brew info nginx nginx: stable 1.17.3 (bottled), HEAD HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server https://nginx.org/ Not installed From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/nginx.rb ==> Dependencies Required: [email protected] ✘, pcre ✘ ==> Options --HEAD Install HEAD version ==> Caveats 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 have launchd 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: nginx ==> Analytics install: 33,474 (30 days), 102,528 (90 days), 411,252 (365 days) install_on_request: 32,832 (30 days), 100,590 (90 days), 399,424 (365 days) build_error: 0 (30 days)通过这些信息可以看出: 1、nginx 在本地还未安装(Not installed) 2、nginx 的来源(From) 3、Docroot 也就是文件根目录,代码存放的文件夹,默认为 /usr/local/var/www 4、在 /usr/local/etc/nginx/nginx.conf 配置文件中默认端口被配置为 8080 从而使 nginx 运行时不需要加 sudo 5、nginx 将在 /usr/local/etc/nginx/servers/ 目录中加载所有文件 6、我们可以通过命令 '$ nginx' 来启动 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 have launchd 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: nginx 安装成功之后,nginx 的本地路径为: /usr/local/var/homebrew/linked/nginx nginx 本地配置文件路径: /usr/local/etc/nginx/nginx.conf # M1 系统路径 /opt/homebrew/etc/nginx/nginx.conf nginx 文件存放路径为,在 Mac 上其实这个存放路径是软链出来的: /usr/local/var/www # M1 系统路径 /opt/homebrew/var/www这个 /usr/local/var/www 指向的是 /usr/local/Cellar/nginx 里面的 html 文件夹, 项目的代码或文件可以放置这个文件夹中就能被访问到,如果路径不满意也可以 Nginx 配置文件 中去调整。 启动 Nginx,启动之后打开 http://localhost:8080/ 链接,就会出现 Welcome to nginx!。 $ nginxNginx 常用命令 到这里安装 Nginx 也就完成了!! |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |