1、nginx下载官方连接
http://nginx.org/en/download.html
wget http://nginx.org/download/nginx-1.20.2.tar.gz
2、安装部署
tar -zvxf nginx-1.20.2.tar.gz
安装依赖
yum -y install openssl openssl-devel
开始安装
./configure
make
make install
查看是否安装成功
whereis nginx
运行nginx命令
./nginx
输入IP即可访问
3、nginx常用命令
进入nginx目录下
cd /usr/local/nginx/sbin/
启动
./nginx
停止
./nginx -s stop
安全退出
./nginx -s quit
重新加载配置文件
./nginx -s reload
查看进程
ps aux|grep nginx
4、配置跳转到百度
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
proxy_pass http://www.baidu.com;
}
}
}
6、配置负载均衡
events {
worker_connections 1024;
}
http {
upstream zhangtest{
server 127.0.0.1:81 weight=1;
server 127.0.0.1:82 weight=1;
}
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
proxy_pass http://zhangtest;
}
}
}