linux一些基础命令

pkill -9 nginx    强行杀死
ps -ef | grep nginx  查看进程

kill -QUIT 36398 杀死进程

nginx -s reload  重启nginx

cp -r   aa bb       复制文件夹

rm -rf  aa            快速删除

mv  aa.txt bb.txt      移动文件或改名字

ifconfig               查看ip地址

 

1.反向代理配置文件nginx.conf,注意有时tomcat_server不支持下划线,有时需要去掉,tomcat版本的问题

upstream tomcat_server{
server 192.168.1.66:8080;
}
server {
listen 80;
server_name www.tomcat.com;
location / {
proxy_pass http://tomcat_server; #指定代理的后台服务器
}
}

一定要记得在windows端更改这个配置文件:

nginx学习总结:

linux的ip地址和代理网址,浏览器就用:www.taobao.com 登录就行了 

nginx学习总结:

nginx学习总结:

2.负载均衡:开启两个tomcat,再配置权重

#后台服务器列表
upstream taobao_server{
server 192.168.1.66:8081 weight=3; #weight表示权重,权重越高被分配到的几率越大
server 192.168.1.66:8082 weight=7;
}
server {
listen 80;
server_name www.taobao.com;
location / {
proxy_pass http://taobao_server; #指定代理的后台服务器
}
}

两个tomcat轮番上阵,达到负载均衡的目的:

nginx学习总结:

那个红箭头指向更改了一部分内容,改的这个文件,区别两个tomcat:

nginx学习总结:

nginx学习总结:

3.动静分离:

location ~ .*\.(js|css|ico|png|jpg|eot|svg|ttf|woff) {
root /home/www/static;
}

cp tomcat.css tomcat.png /home/www/static

cd static

chmod 777 * #扩大权限

 

相关文章:

  • 2022-01-04
  • 2021-12-02
  • 2022-12-23
  • 2021-04-02
  • 2022-12-23
  • 2022-02-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-29
  • 2021-08-26
  • 2021-06-17
  • 2021-11-19
相关资源
相似解决方案