Mac安装 nginx (极简)
Mac安装 nginx
本篇采用homebrew安装方式
1.更新brew
brew update
2.查询要安装的软件是否存在
brew search nginx
3.查询本机nginx情况
brew info nginx
Not installed — nginx在本地还未安装
From — nginx的下载地址
/usr/local/var/www — Docroot默认路径
8080 — 为 /usr/local/etc/nginx/nginx.conf 配置文件中被配置的默认端口,nginx运行时不需要加sudo
nginx将在/usr/local/etc/nginx/servers/目录中加载所有文件
可以通过最简单的命令 ‘nginx’ 来启动nginx。
4.安装nginx
brew install nginx
5.查看nginx安装目录
open /usr/local/etc/nginx/
nginx安装位置:
open /usr/local/Cellar/nginx //其实这个是nginx被安装到的目录
可以看到里面有个html文件夹,它指向的就是/usr/local/var/www目录,这个在上面我们查看的info信息中有提到(Dcroot)
6.启动nginx
nginx
7.打开浏览器访问:localhost:8080
出现上述页面则显示启动成功,如果你展示的是403或者其他未访问成功,可以先看下 /usr/local/var/www 目录下是否有一个欢迎页面文件(index.html)
8.了解一下nginx的配置文件(nginx.conf)
cat /usr/local/etc/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 {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;server {listen 8080; #监听8080端口server_name localhost; #定义使用localhost访问#charset koi8-r;#access_log logs/host.access.log main;location / {root html; #定义服务器的默认网站根目录位置index index.html index.htm; #定义首页索引文件的名称}#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;# 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/*;
}
通过配置文件可以看到其默认的网站根目录为:html(即/usr/local/var/www)
而默认的索引文件为index.html 和 index.htm
9.如果你的根目录没有首页索引文件,可以手动创建一个
cd /usr/local/var/www/ //进入到www目录下
touch index.html //创建一个新的index.html文件
vim index.html //编辑该文件 ;
index.html文件写入:
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>title</title>
</head>
<body><div><h1>我的nginx欢迎页面</h1></div>
</body>
</html>
按esc键,输入:wq退出编辑并保存
回到浏览器(localhost:8080)刷新
Mac安装 nginx (极简)相关推荐
- Mac安装MongoDB(极简)
Mac安装MongoDB MongoDB 是一个基于分布式文件存储的数据库,由 C++ 语言编写. MongoDB也是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系 ...
- Nginx 极简入门教程
Nginx 极简入门教程 基本介绍 Nginx 是一个高性能的 HTTP 和反向代理 web 服务器,同时也提供了 IMAP/POP3/SMTP服务. Nginx 是由伊戈尔·赛索耶夫为俄罗斯访问量第 ...
- 极简主义linux桌面,Ubuntu 16.04/17.10/18.04安装Zafiro极简图标主题
zafiro图标是桌面xfce4,gnome或lxde的图标包,具有干净简单的设计线条,灵感来源于平面设计. 它是根据L.I.M.A许可证分发的,优先级是极简主义,不会用任何图标来饱和元素,每个图标都 ...
- 苹果电脑mac安装nginx教程
苹果电脑MAC安装nginx教程 使用homebrew安装,提醒需要翻墙,最后面介绍的源码安装方式不需要翻墙,只需要在墙内搞到源码即可,建议先确认一下自己能否翻墙,如果可以翻墙就用第一种方法,如果不能 ...
- Nginx配置图片服务器(Nginx极简配置说明)
一.概述 同学们大家好,今天给大家带来Nginx的一篇实践配置总结,主要是Nginx做静态图片服务器的详情配置说明,还包括做反向代理.动静分离.负载均衡的极简配置. 二.Nginx安装 Nginx下载 ...
- mac 安装 nginx
我是用root用户装的 1.先安装PCRE库 可以在这里下载最新版,我这里使用的是8.33的版本然后在终端执行下面的命令. cd ~/Download tar xvzf pcre-8.33.tar. ...
- Mac安装nginx配置过程
mac电脑系统重装了,记录一下安装nginx的过程: 1.打开终端 2.安装Command Line tools xcode-select --install 3.安装brew命令 1 ruby -e ...
- mac 安装nginx与switchhosts 并在微信开发者工具调试h5项目
一.nginx 安装参考:(亲测有用) Mac 安装 brew(最新教程,绝对可行,一行代码搞定,不报错) - LeeHua - 博客园 nginx按照
- mac安装nginx教程
题记:对接项目用到了nginx才发现买了mac从没摸过nginx,记录一下在mac上安装nginx的经历! 一.使用brew安装nginx 1,安装: brew install nginx 2,查看安 ...
- Mac 安装Nginx详细教程
目录 一.前言 二.正文 1.安装 Homebrew 2.brew安装nginx 3.启动nginx服务,如下命令: 三.总结nginx常见的配置 1.nginx启动: 2.nginx停止 一.前言 ...
最新文章
- 线程创建后,立刻调用CloseHandle的原因
- Kotlin 中的 run、let、with、apply、also、takeIf、takeUnless 语法糖使用和原理分析
- Java+Selenium Web UI自动化测试的一些总结
- HDU - 6315 Naive Operations(线段树+思维)
- javaweb学习总结——基于Servlet+JSP+JavaBean开发模式的用户登录注册
- 小程序 - 学习笔记
- 8条关于Web前端性能的优化建议
- android 获取sd卡视频文件名,android – 如何获取SD卡上的视频列表
- python做数据分析需要oracle_精通 Oracle+Python,第 1 部分:查询最佳应践
- 《计算机网络》学习笔记 ·005【传输层】
- html实现好看的年会抽奖(附源码)
- android 编辑框失去焦点,关于android:editText并没有失去焦点
- signature=946b61359fb7b919b57e636da83bf538,X-ray tube.
- U盘图标自定义时不能修改图标?
- 【MineCraft】-- 如何开设我的世界服务器
- wps怎么恢复成单页_我告诉你文档两页怎么变成单页
- leetcode 1905. 统计子岛屿(C++、java、python)
- 计算机科学与技术考研双非院校排名,ESI工科小校较好新排名,两所双非院校冲进世界500强!...
- 《聊天机器人观后感》
- 用Python做一款自己的TK创建器