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/
    
  • 相关阅读:
    Hibernate实体类注解
    Struts2注解详解
    Spring注解大全
    Maven依赖机制
    Maven启动代理服务器
    SSH整合
    二进制求和 —— 从复杂方法到简单方法
    最大子序和 —— 动态规划解法
    括号匹配问题 —— Deque双端队列解法
    常见面试题 —— 两数之和(拒绝暴利法)
  • 原文地址:https://www.cnblogs.com/surfsky/p/12705386.html
Copyright © 2011-2022 走看看