MAC下安装nginx

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

安装完毕后打开命令行

步骤一:先更新homebrew

brew update

如果上面操作长时间没任何动静,请更换镜像,参考清华的镜像 https://mirrors.tuna.tsinghua…

步骤二: 查看nginx信息

brew search nginx

《MAC下安装nginx》

步骤三:安装nginx

brew install nginx

《MAC下安装nginx》

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

《MAC下安装nginx》

步骤四:运行nginx

nginx

nginx默认使用8080端口 如果发现端口被占用了,可以杀掉使用使用改端口的进程,也可以修改/usr/local/etc/nginx/nginx.conf 下的

http {
    server {
        listen       8181;
        server_name  localhost;  

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

重新启动nginx

nginx -s reload

成功看到欢迎页面~!(对应的html是/usr/local/var/www/index.html)
《MAC下安装nginx》

    原文作者:桃子_Lisa
    原文地址: https://segmentfault.com/a/1190000016020328
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞