zoukankan      html  css  js  c++  java
  • 在 MAC 下配置 Nginx

    1. 更新Homebrew

    # mac使用brew update无反应,更新慢解决办法
    # 替换brew.git
    cd "$(brew --repo)"
    git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
    
    # 替换homebrew-core.git
    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
    
    # update
    brew update
    

    2. 安装 nginx

    $ brew install nginx

    ==> Installing dependencies for nginx: openssl@1.1 and pcre

    ==> Installing nginx dependency: openssl@1.1

    ==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openssl@1.1

    blablablabla....

    Docroot is: /usr/local/var/www

    The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that

    nginx can run without sudo. 

    nginx will load all files in /usr/local/etc/nginx/servers/.

    To have launchd start nginx now and restart at login:

      brew services start nginx

    Or, if you don't want/need a background service you can just run:

      nginx

    3. 启动Nginx

    登录时作为服务启动: brew services start nginx
    直接启动: nginx
    默认地址:http://localhost:8080
    

    4. 部署新网站

    修改文件 /usr/local/etc/nginx/nginx.conf,可用 sudo pico /usr/local/etc/nginx/nginx.conf,或者直接用记事本编辑。

        # 配置网站
        server {
            listen 8081;
            server_name   localhost;
            location / {
                root     /XXX/DemoSite;
                index    index.html;
            }
        }
    

    重新启动nginx

    sudo nginx -s reload
    

     打开浏览器查看:

    http://localhost:8081/
    
  • 相关阅读:
    Autoit 使用
    小狼毫安装五笔输入法
    MIT 6.824 MapReduce
    基于JDBC封装数据库基本CURD操作
    利用反射特性完成对象的拷贝
    基于HTTP协议和HttpURLConnection完成网上资源的爬取
    应用多线程解决文件拷贝加进度条项目
    java动态代理详解
    [转]String、StringBuffer与StringBuilder之间区别
    “内聚性”和“耦合性”
  • 原文地址:https://www.cnblogs.com/surfsky/p/12705386.html
Copyright © 2011-2022 走看看