mac上nginx常用命令总结、配置

1、安装nginx

brew install nginx

mac版本老旧,安装nginx失败,可以参考我的这篇博客,文章后半部分关于nginx安装失败,也许可以帮到您(解决xcode-select --install不能下载该软件

 

2、常用命令// 查看帮助nginx -h

// 查看版本
nginx -v

// 查看详细信息,包括文件位置,配置位置(nginx.conf)等
nginx -V

// 编辑nginx.conf文件,:wq进行保存
vim xxx/nginx.conf

// 检查配置文件是否正确
nginx -t

// 关闭所有的nginx
nginx -s stop

// 退出nginx
nginx -s quit

// 重新加载配置文件
nginx -s reload

// 重启
nginx 

//存在多个配置文件 (nginx: [error] invalid PID number "" in "/usr/local/var/run/nginx.pid")
sudo nginx -c /usr/local/etc/nginx/nginx.conf

  

浏览器打开:http://localhost/ 查看效果

 

3、nginx.conf配置

 

4、ngix配置不生效

看看nginx.conf是否有以下的内容,是默认内容,用#号注释掉

参考文章:

https://blog.csdn.net/qq_53810245/article/details/128001608

 

5、nginx失败:500 internal server error

  -- 先检查磁盘空间,如果满了,清理磁盘再试试重启:

df -lh

  

-- 查看错误日志

/var/log/nginx/error.log

  

我遇到的问题通过日志看出来了,failed (13: Permission denied)

-- 查看启动用户和使用用户是否一致

ps aux | grep nginx

  

-- nginx.conf文件修改用户,重启nginx

参考文章

1、https://blog.csdn.net/qq_53810245/article/details/128001608

2、https://blog.csdn.net/qq_52855464/article/details/126639005

 

 

有问题欢迎交流! 

 

posted @ 2024-01-08 16:02  猕猴桃姑娘  阅读(660)  评论(0)    收藏  举报