Mac 本地搭建nginx

适用于小白!!

安装:brew install nginx

查看是否安装成功:brew info nginx

 

启动:sudo nginx

暂停:sudo nginx -s stop

重新启动:sudo nginx -s reload

启动之后浏览器输入:localhost:8080能看到下面画面即可。

nginx配置文件:/usr/local/etc/nginx/nginx.conf

 例如:

  server {
        listen       8080;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }
 error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }


    }
 server {
        listen       9000;
        server_name  www.other.com;

        location / {
 proxy_pass http://127.0.0.1:8080;
            root   /usr/local/var/www/;
            index  index.html index.htm;
        }

    }

 


版权声明:本文为impossible1994727原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。