搭建Nginx
ubuntu:18.04环境
安装nginx:
apt-get install nginx
配置监听【/etc/nginx/nginx.conf】:
以下内容写在http{}中
upstream myweb { server 127.0.0.1:30009; server 127.0.0.1:30009 backup; #热备 } server { listen 80; server_name 127.0.0.1; location / { proxy_pass http://myweb; } } server{ listen 81; server_name 127.0.0.1; location /{ proxy_pass http://myweb; } }
nginx操作命令:
开启/关闭
systemctl start/stop nginx
重新加载配置
systemctl reload nginx
Centos7安装nginx:
添加nginx到yum源:
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装nginx
yum install -y nginx
启动nginx
systemctl start nginx
可修改配置文件:/etc/nginx/conf.d文件夹下