使用 brew search nginx
命令,搜索nginx
使用 brew install nginx
命令,安装nginx
使用 nginx -v
查看ngxin版本:
nginx version: nginx/1.15.11
使用 brew info nginx
查看nginx的详细信息(我们需要知道配置文件的路径)
nginx: stable 1.15.11 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/usr/local/Cellar/nginx/1.15.11 (25 files, 2MB) *
Poured from bottle on 2019-04-14 at 19:41:21
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/nginx.rb
==> Dependencies
Required: openssl ✔, 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: 39,863 (30 days), 101,681 (90 days), 432,120 (365 days)
install_on_request: 37,388 (30 days), 95,854 (90 days), 395,442 (365 days)
build_error: 0 (30 days)
由以上信息我们知道nginx的配置文件的路径在/usr/local/etc/nginx/nginx.conf
,默认端口为8080
因为Tomcat默认端口也为8080,同时也避免被骇客攻击,修改端口也是很有必要的。
我们使用vim编辑器来修改默认端口,终端输入 vim /usr/local/etc/nginx/nginx.conf
编辑默认端口。
server {
36 listen 8087;
37 server_name localhost;
38 charset utf-8;
39 #charset koi8-r;
使用 brew services start nginx
命令启动nginx
==> Successfully started `nginx` (label: homebrew.mxcl.nginx)
网友评论