美文网首页程序员
Mac 下 brew 安装 nginx 所遇到的坑

Mac 下 brew 安装 nginx 所遇到的坑

作者: 苏_小糖_ | 来源:发表于2019-04-06 10:45 被阅读0次

    Mac 下 brew 安装 nginx 所遇到的坑

    简单介绍一下 brew
      // 更新 brew
      brew update
    
      // 查找某个软件的信息,这里查看 nginx
      brew info nginx
    
      // 安装某个软件
      1. brew search nginx  // php 的话可以查看版本 建议先执行这个命令
      2. brew install nginx
      3. brew services start[stop/restart] nginx // 后台挂起 nginx 或者不需要后台服务 nginx 即可
    
      // 当启动 nginx 发生 [emerg] 9734#0: open() "/usr/local/Cellar/nginx/1.15.3/logs/error.log" failed (2: No such file or directory)
      这个只是 brew install nginx 它的日志文件应该是放在其他地方,
      我的是/usr/local/var/log/nginx/。
      
      // 查看 nginx 的所有文件安装位置 可以使用 nginx -V[可以查看 nginx 版本和配置]、 nginx -v[只查看版本] 
      // 主要关键文件罗列, brew 安装默认地址
      1.  --prefix=/usr/local/Cellar/nginx/1.15.10  // nginx 安装目录, 注意对应版本号
      2. --sbin-path=/usr/local/Cellar/nginx/1.15.10/bin/nginx // nginx 启动程序
      3. --conf-path=/usr/local/etc/nginx/nginx.conf // nginx 配置文件
      4. --pid-path=/usr/local/var/run/nginx.pid // nginx 进程文件,用来指定进程id的存储文件位置
      5. --http-log-path=/usr/local/var/log/nginx/access.log 
         --error-log-path=/usr/local/var/log/nginx/error.log // nginx 日志位置
    
      // 解决方案
      vi /usr/local/etc/nginx/nginx.conf 
      修改 error_log  logs/error.log 
      为 /usr/local/var/log/nginx/error.log  notice // ···等等你需要参数的对应位置
      
      // 重启 nginx 成功, 成功访问
    

    参考资料

    相关文章

      网友评论

        本文标题:Mac 下 brew 安装 nginx 所遇到的坑

        本文链接:https://www.haomeiwen.com/subject/astriqtx.html