mac安装nginx教程
生活随笔
收集整理的這篇文章主要介紹了
mac安装nginx教程
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題記:對接項目用到了nginx才發現買了mac從沒摸過nginx,記錄一下在mac上安裝nginx的經歷!
一、使用brew安裝nginx
1,安裝:
brew install nginx
2,查看安裝信息(經常用到, 比如查看安裝目錄等)
brew info nginx
說明:安裝后,主要看brew把nginx安裝到哪里去了,默認是安裝到/usr/local/etc/nginx/nginx.conf
Action:~ wangjun$ brew info nginx nginx: stable 1.17.9 (bottled), HEAD HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server https://nginx.org/ /usr/local/Cellar/nginx/1.17.9 (25 files, 2.1MB) *Poured from bottle on 2020-07-13 at 08:58:04 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/nginx.rb ==> Dependencies Required: openssl@1.1 ?, pcre ? ==> Options --HEADInstall HEAD version ==> Caveats Docroot is: /usr/local/var/wwwThe 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: 31,080 (30 days), 104,700 (90 days), 408,180 (365 days) install-on-request: 30,338 (30 days), 101,623 (90 days), 393,792 (365 days) build-error: 0 (30 days) Action:~ wangjun$這就安裝成功了!
二、常用命令
1,查看nginx版本的命令
Action:~ wangjun$ nginx -v nginx version: nginx/1.17.92,啟動nginx服務
第一種方式:
啟動nginx:sudo nginx
Action:log wangjun$ brew services start nginx ==> Successfully started `nginx` (label: homebrew.mxcl.nginx)3,查看nginx是否啟動成功
Action:~ wangjun$ brew services start nginx Service `nginx` already started, use `brew services restart nginx` to restart. Action:~ wangjun$ ps -ef|grep nginx501 2968 1 0 9:09AM ?? 0:00.01 nginx: master process /usr/local/opt/nginx/bin/nginx -g daemon off;501 2971 2968 0 9:09AM ?? 0:00.03 nginx: worker process501 11022 10470 0 9:17PM ttys002 0:00.00 grep nginx4,日志位置
/usr/local/var/log/nginx/error.log查看日志 tail -f *5,關閉nginx服務
第一種方式:
關閉nginx:sudo nginx -s? stop
第二種方式:
Action:log wangjun$ brew services stop nginx Stopping `nginx`... (might take a while) ==> Successfully stopped `nginx` (label: homebrew.mxcl.nginx)6,重啟nginx服務
第一種方式:
重啟nginx:sudo nginx -s reload
7,判斷配置文件是否正確:
nginx -t -c /usr/local/nginx/conf/nginx.conf
或者
cd /usr/local/nginx/sbin
./nginx -t
8,也可將配置文件分離
在主配置文件中添加:include servers/*;? ? ? 該語句會加載servers文件夾下所有的配置信息。
在/usr/local/etc/nginx文件夾下新增servers文件夾,
總結
以上是生活随笔為你收集整理的mac安装nginx教程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 小巫随笔12(致小巫逝去的童年)
- 下一篇: OpenStack之keystone(身