macos系统安装nginx

MacOS系统安装软件:


macos系统下没有yum和apt-get命令,要安装软件需要使用homebrew。

1、安装homebrew:

安装:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
卸载:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

PS:如果出现ping github.com超时的情况,查找第三方ip,如192.30.253.112 github.com添加到/etc/hosts最后一行。

2、利用homebrew安装、卸载软件包:

$ brew install pcre bzip2 openssl
$ brew uninstall python
$ brew search <packageName>
$ brew list 查看已安装
$ brew info <packageName> 查看包信息
$ brew -v
$ brew -h
$ brew install nginx 安装过程会自己安装依赖关系
$ brew services start nginx 启动nginx
$ brew services stop nginx 关闭nginx
$ brew services reload nginx 重启nginx
$ brew uninstall nginx 卸载nginx

3、nginx文件目录结构:

nginx安装文件目录
(...网站路径)
/usr/local/Cellar/nginx


nginx配置文件路径
/usr/local/etc/nginx/nginx.conf


nginx日志文件路径
/usr/local/var/log/

nginx运行pid文件路径
/usr/local/var/run/

系统hosts文件位置

/private/etc/hosts

4、其他

注意事项:
macos x系统对权限的约束非常严格,不能用root执行脚本;
nginx.conf中user不能配置成root或macos,配置完会报错;
运行时,目录属主:属组,属主需要改成conf中user的用户,默认nobody,属组改不了,默认staff(包含所有用户的组),
但是即使如此,如果不配置属主,nginx并不生效,也就是说这个组没个卵用,目录配成777也没用。

猜你喜欢

转载自www.cnblogs.com/immense/p/11397555.html