MAC下安装nginx

必备工具
homebrew https://brew.sh/index_zh-cn.html (安装方法自行搜索)html

安装完毕后打开命令行nginx

步骤一:先更新homebrew工具

brew update

若是上面操做长时间没任何动静,请更换镜像,参考清华的镜像 https://mirrors.tuna.tsinghua...spa

步骤二: 查看nginx信息命令行

brew search nginx

clipboard.png

步骤三:安装nginxcode

brew install nginx

clipboard.png

安装完毕
主页的文件在/usr/local/var/www 文件夹下
对应的配置文件地址在/usr/local/etc/nginx/nginx.confserver

clipboard.png

步骤四:运行nginxhtm

nginx

nginx默认使用8080端口 若是发现端口被占用了,能够杀掉使用使用改端口的进程,也能够修改/usr/local/etc/nginx/nginx.conf 下的blog

http {
    server {
        listen       8181;
        server_name  localhost;  

        #charset koi8-r;
        .....
        }
    }

从新启动nginx进程

nginx -s reload

成功看到欢迎页面~!(对应的html是/usr/local/var/www/index.html)
clipboard.png