nginx学习

现象:
nginx学习

方法:
一:下载
1:下载nginx:http://nginx.org/en/download.html
2:下载进行解压
3:进入window的cmd窗口,进入到nginx目录,使用“start nginx.exe ”进行安装
在这里插入图片描述

安装成功后,在“任务管理器”中会看到“nginx.exe”进程,
在这里插入图片描述
如果发现进程中并没有,那么说明你安装失败,你可以到你的D:\nginx-1.8.1目录下的logs文件夹下的error下查看,分析原因
二:设置
在浏览器地址栏输入:127.0.0.1,会进入到nginx的欢迎页面

start nginx.exe //开始

nginx.exe -s stop //停止nginx

nginx.exe -s reload //重新加载nginx 的配置文件

nginx.exe -s quit //退出nginx

三:配置文件
1:nginx的配置文件为解压目录下的conf
在这里插入图片描述

2:配置默认端口 为8088 listen标识监听占用8088端口

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8088;
server_name localhost;
}
}

3:配置一个虚拟主机 访问localhost:8001 将会跳转https://www.baidu.com
server {
listen 8001; #监听端口
server_name localhost; #域名可以有多个,用空格隔开
location / {
root html;
index index.html index.htm;
proxy_pass https://www.baidu.com;
}
}

4:配置多个
server {
listen 8001;
server_name localhost;
#localhost:8001 将转跳到这里
location / {
root html;
index index.html index.htm;
proxy_pass https://www.baidu.com;
}
#localhost:8001/worker 将转跳到这里
location /worker {
proxy_pass https://www.sougou.com/;
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值