1 ,nginx 是什么 :
- web 服务器
- 分享代理服务器
2 ,具体作用 :
- 直接支持 : rails ,php
- 反向代理 : http
- 负载均衡
- 右键代理服务器
- 前段动静分离
3 ,nginx 优点 :
- 稳定
- 性能高
- 资源占用少
- 功能丰富
- 模块化
- 热部署
4 ,nginx 安装 : linux
- 安装依赖 :
yum install gcc -y
yum install pcre-devel -y
yum install zlib -y
yum install zlib-devel -y
yum install openssl -y
yum install openssl-devel -y - 下载 nginx :
wget http://nginx.org/download/nginx-1.10.2.tar.gz
5 ,解压 :
tar -xzvf nginx-1.10.2.tar.gz -C …/software/
6 ,安装 :
- cd /app/software/nginx-1.10.2
- ./configure
- make
- make install
7 ,成功的标志 :
- cd /usr/local/
- ls
- 看到 nginx ,证明安装成功
8 ,启动 nginx :
- cd /usr/local/nginx/sbin
- ./nginx
9 ,检测进程 :
ps -aux | grep nginx
10 ,成功的标志 :
看到 nginx 的进程
11 ,访问 :
http://161.189.10.185/
12 ,关闭 nginx :
pkill -9 nginx
13 ,编辑主配置文件 : 引入分配置文件
- 目的 : 方便维护,每个域名对应一个 conf 文件
- 编辑 :
cd /usr/local/nginx/conf/
mkdir vhost
vim nginx.conf - 加入这一句 :
include vhost/*.conf; - 位置 :
14 ,重启 nginx :
cd /usr/local/nginx/sbin/
./nginx -s reload