当前位置: 首页 > news >正文

MAC 安装nginx

使用Homebrew方式进行安装

步骤:

1、更新 Homebrew

brew update

2、下载并安装 Nginx

brew install nginx

3、查看 nginx 配置信息

brew info nginx
zhanghua@Breeze ~ % brew info nginx
// 版本信息
==> nginx: stable 1.25.1 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server// Nginx安装目录
https://nginx.org/
/usr/local/Cellar/nginx/1.25.1_1 (26 files, 2.4MB) *Poured from bottle using the formulae.brew.sh API on 2023-08-10 at 10:48:47// 安装来源
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb
License: BSD-2-Clause
==> Dependencies
Required: openssl@3 ✔, pcre2 ✔
==> Options
--HEADInstall HEAD version// 根目录
==> Caveats
Docroot is: /usr/local/var/www// 重点!!!nginx 的配置文件及默认启动端口 8080
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.// Nginx将在 Server 目录下加载所有文件,在这个
nginx will load all files in /usr/local/etc/nginx/servers/.To 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:/usr/local/opt/nginx/bin/nginx -g daemon off;
==> Analytics
install: 11,885 (30 days), 57,023 (90 days), 84,746 (365 days)
install-on-request: 11,855 (30 days), 56,930 (90 days), 84,620 (365 days)
build-error: 3 (30 days)

4、nginx常用命令

启动
brew services start nginx停止
brew services stop nginx终端进入nginx 目录
cd /opt/homebrew/etc/nginx编辑 nginx.conf 配置文件
vim nginx.conf 编辑完成后:wq保存退出重新加载配置文件
nginx -s reload

5、nginx配置文件 nginx.conf

#user  nobody;
worker_processes  1;#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {#http 配置include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;upstream xx{// 负载均衡配置server 127.0.0.1:8080 weight =1;server 127.0.0.1:8081 weight =1;}// nginx 端口 ,只要访问8080端口 就会被nginx 监听 ,如果电脑端口有冲突 可以更换端口号server {listen       8080;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   html;index  index.html index.htm;// 反向代理proxy_pass http://域名}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#证书 cert.pen和 cert.key换成证书的目录#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}include servers/*;
}
http://www.lryc.cn/news/265330.html

相关文章:

  • 开源 AI 新秀崛起:Bittensor 更像是真正的“OpenAI”
  • 设计模式:循序渐进走入工厂模式
  • 如何将图片(matlab、python)无损放入word论文
  • 在Next.js和React中搭建Cesium项目
  • docker学习(十、搭建redis集群,三主三从)
  • ES排错命令
  • 爬虫实战案例 -- 爬取豆瓣读书网页内容
  • 某电子文档安全管理系统 SQL注入漏洞复现
  • ant-design-vue Message 用法以及内容为 html片段情况
  • 2024 Move 开发者大会火热报名中!1 月 13 至 14 日上海见
  • hbase用shell命令新建表报错ERROR: KeeperErrorCode = NoNode for /hbase/master
  • PyQt中的冒号(:)
  • yolo-nas无人机高空红外热数据小目标检测(教程+代码)
  • Ubuntu22.04安装python2
  • 【Amazon 实验①】Amazon WAF功能增强之实验环境准备
  • Qt不能在线程函数操作UI
  • web网页端使用webSocket实现语音通话功能(SpringBoot+VUE)
  • 读取spring boot项目resource目录下的文件
  • R语言生物群落(生态)数据统计分析与绘图实践技术
  • c# OpenCV 检测(斑点检测、边缘检测、轮廓检测)(五)
  • PHP下载安装以及基本配置
  • 黑苹果安装经验总结2023-12
  • 基于深度学习的森林火焰烟雾检测系统(含UI界面,yolov8、Python代码,数据集)
  • 测试开发体系介绍——测试体系介绍-L1
  • Linux中的链接运算符详解 - 提高编程效率与性能
  • JS模块化规范之ES6及UMD
  • XM平台官网开户注册流程图解
  • 【Linux进阶之路】线程
  • 个性化TikTok外贸工具定制!突破营销新境界!
  • 设计模式-门面模式