mac环境brew安装nginx

简介: mac环境brew安装nginx

安装:

brew install nginx

以下是安装完成之后打印出来的提示信息


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

按照提示启动


brew services start nginx

查看状态:

nginx -t

如果报错


nginx: [emerg] open() "/usr/local/var/run/nginx.pid" failed (13: Permission denied)

权限问题

sudo chown -R $(whoami)  /usr/local/var/run  # 具体路径参考报错提示中的路径

重启nginx服务器


brew services stop nginx   # 停止
brew services start nginx   # 启动

提示中默认显示8080端口

http://127.0.0.1:8080/


网页中出现下面的文字,就启动成功了

Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.

静态服务器

在路径/usr/local/var/www下放入文件mytest.html内容如下:


<h1>hello nginx! 2018-07-10</h1>

通过链接访问测试: http://127.0.0.1:8080/mytest.html


通用配置


user  nobody;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    client_max_body_size 20M;
    include conf.d/*.conf;
}

注意到include conf.d/*.conf; 这样就可以将conf.d这个文件夹中的所有配置文件加载进来,实现单独配置,互不影响。

相关文章
|
5月前
|
前端开发 安全 测试技术
Postman Mac 版安装终极指南:从下载到流畅运行,一步到位
Postman 是 API 开发与测试的高效工具,支持各类 HTTP 请求调试与团队协作。本文详解 Mac 版下载、安装步骤,助你快速上手。同时推荐一体化 API 协作平台 Apifox,集文档、调试、测试于一体,提升开发效率与团队协同能力。
|
4月前
|
应用服务中间件 Linux nginx
在虚拟机Docker环境下部署Nginx的步骤。
以上就是在Docker环境下部署Nginx的步骤。需要注意,Docker和Nginix都有很多高级用法和细节需要掌握,以上只是一个基础入门级别的教程。如果你想要更深入地学习和使用它们,请参考官方文档或者其他专业书籍。
211 5
|
5月前
|
Kubernetes 应用服务中间件 Nacos
Kubernetes环境下Nginx代理Nacos服务请求故障诊断
以上方法不仅适用于排除特定环境下出现故障情况,也适合作为一般性指南帮助运维人员快速准确地找出并解决问题。实际操作中还需根据现场实际情况灵活运用这些技巧,并结合自身经验进行判断和处理。
168 12
|
8月前
|
iOS开发 MacOS 索引
在不受支持的 Mac 上安装 macOS Tahoe 26
在不受支持的 Mac 上安装 macOS Tahoe 26
522 0
在不受支持的 Mac 上安装 macOS Tahoe 26
|
11月前
|
Ubuntu Linux Shell
Ubuntu gnome WhiteSur-gtk-theme类mac主题正确安装和卸载方式
通过这个过程,用户不仅可以定制自己的桌面外观,还可以学习到更多关于 Linux 系统管理的知识,从而更好地掌握系统配置和主题管理的技巧。
1686 12
|
11月前
|
监控 Shell Linux
Android调试终极指南:ADB安装+多设备连接+ANR日志抓取全流程解析,覆盖环境变量配置/多设备调试/ANR日志分析全流程,附Win/Mac/Linux三平台解决方案
ADB(Android Debug Bridge)是安卓开发中的重要工具,用于连接电脑与安卓设备,实现文件传输、应用管理、日志抓取等功能。本文介绍了 ADB 的基本概念、安装配置及常用命令。包括:1) 基本命令如 `adb version` 和 `adb devices`;2) 权限操作如 `adb root` 和 `adb shell`;3) APK 操作如安装、卸载应用;4) 文件传输如 `adb push` 和 `adb pull`;5) 日志记录如 `adb logcat`;6) 系统信息获取如屏幕截图和录屏。通过这些功能,用户可高效调试和管理安卓设备。
|
开发工具 git 开发者
「Mac畅玩鸿蒙与硬件3」鸿蒙开发环境配置篇3 - DevEco Studio插件安装与配置
本篇将专注于如何在 DevEco Studio 中安装和配置必要的插件,以增强开发功能和提升效率。通过正确配置插件,开发流程能够得到简化,开发体验也会更加顺畅。
559 1
「Mac畅玩鸿蒙与硬件3」鸿蒙开发环境配置篇3 - DevEco Studio插件安装与配置
|
开发工具 iOS开发 开发者
「Mac畅玩鸿蒙与硬件2」鸿蒙开发环境配置篇2 - 在Mac上安装DevEco Studio
本篇将专注于如何在 Mac 上安装鸿蒙开发工具 DevEco Studio,确保开发环境能够顺利搭建。完成安装后,可以正式开始鸿蒙应用的开发工作。
1092 1
「Mac畅玩鸿蒙与硬件2」鸿蒙开发环境配置篇2 - 在Mac上安装DevEco Studio
|
Web App开发 关系型数据库 应用服务中间件