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这个文件夹中的所有配置文件加载进来,实现单独配置,互不影响。

相关文章
|
2月前
|
应用服务中间件 Linux nginx
在虚拟机Docker环境下部署Nginx的步骤。
以上就是在Docker环境下部署Nginx的步骤。需要注意,Docker和Nginix都有很多高级用法和细节需要掌握,以上只是一个基础入门级别的教程。如果你想要更深入地学习和使用它们,请参考官方文档或者其他专业书籍。
160 5
|
3月前
|
Kubernetes 应用服务中间件 Nacos
Kubernetes环境下Nginx代理Nacos服务请求故障诊断
以上方法不仅适用于排除特定环境下出现故障情况,也适合作为一般性指南帮助运维人员快速准确地找出并解决问题。实际操作中还需根据现场实际情况灵活运用这些技巧,并结合自身经验进行判断和处理。
119 12
|
应用服务中间件 Linux nginx
Jetson 环境安装(四):jetson nano配置ffmpeg和nginx(亲测)之编译错误汇总
这篇文章是关于在Jetson Nano上配置FFmpeg和Nginx时遇到的编译错误及其解决方案的汇总。
488 4
|
编解码 Ubuntu 应用服务中间件
Jetson 环境安装(三):jetson nano配置ffmpeg和nginx(亲测)
本文介绍了在NVIDIA Jetson Nano上配置FFmpeg和Nginx的步骤,包括安装、配置和自启动设置。
727 1
Jetson 环境安装(三):jetson nano配置ffmpeg和nginx(亲测)
|
Ubuntu 应用服务中间件 Linux
Linux下搭建Nginx环境的搭建
Linux下搭建Nginx环境的搭建
242 6
|
应用服务中间件 Shell PHP
windows系统配置nginx环境运行pbootcms访问首页直接404的问题
windows系统配置nginx环境运行pbootcms访问首页直接404的问题
|
应用服务中间件 Linux nginx
Mac os 安装 nginx 教程(success)
这篇文章是关于如何在Mac OS系统上使用Homebrew安装nginx及其依赖,并解决安装过程中可能出现的权限问题。
1811 0
Mac os 安装 nginx 教程(success)
|
应用服务中间件 程序员 开发工具
mac下安装nginx
mac下安装nginx
|
JavaScript Linux Android开发
mac环境下搭建frida环境并连接网易mumu模拟器
这篇文章介绍了如何在mac环境下搭建Frida环境,并详细说明了如何连接网易MuMu模拟器进行动态分析。
1019 1
|
PyTorch TensorFlow 算法框架/工具
手把手教你-MAC笔记本安装Pytorch环境
手把手教你-MAC笔记本安装Pytorch环境