mac安装nginx

安装步骤:

1、打开终端,习惯性命令,更新brew:

brew update    

2、查询软件是否已经安装,执行命令:

brew search nginx  

3、查询需要安装nginx需要的信息

brew info nginx

4、正式开始安装:

brew install nginx

先安装其依赖内容,比如先安装pcre2包,再安装nginx

5、查看安装的nginx信息,brew info nginx

显示已经安装路径

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/.(所有配置文件从这里加载,比如修改nginx.conf)

To restart nginx after an upgrade:

  brew services restart nginx (修改配置文件后重启nginx)

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

  /usr/local/opt/nginx/bin/nginx -g daemon off; (启动文件在/usr/local/opt/nginx/bin)

6、 查看nginx版本、启动的环境配置变量、配置文件

命令:nginx -V (命令nginx -v  小写v只返回版本信息)

7、仅查看启动时候配置文件

命令:nginx -t

8、修改配置文件重启

nginx -t       检查配置文件是否有语法错误

nginx -s reload      reload 命令会重新加载配置文件,而nginx服务不会中断,服务启动,文件即加载成功。

启动:/home/appops/openresty/nginx/sbin/nginx

测试:/home/appops/openresty/nginx/sbin/nginx -t

重启:/home/appops/openresty/nginx/sbin/nginx -s reload

停止:/home/appops/openresty/nginx/sbin/nginx -s stop

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容