当前位置:首页 > 有云笔记 > PROJECT1 > 正文内容

部署Git版本控制系统 、 优化Web服务器

小白2年前 (2022-02-21)PROJECT1132910

自定义错误页面

# 存放一张名为err.png的图片到/usr/local/nginx/html/wp-content
# 创建404.html
[root@web1 html]# vim /usr/local/nginx/html/404.html 
<img src="wp-content/err.png">
# 修改配置文件
[root@web1 html]# vim /usr/local/nginx/conf/nginx.conf
        error_page  404              /404.html;
[root@web2 html]# vim /usr/local/nginx/conf/nginx.conf
        error_page  404              /404.html;
[root@web2 html]# vim /usr/local/nginx/conf/nginx.conf
        error_page  404              /404.html;
[root@web1 html]# systemctl restart nginx.service 
[root@web2 html]# systemctl restart nginx.service 
[root@web3 html]# systemctl restart nginx.service
  • 访问不存在的路径,将会出现自定义错误页面

升级nginx

升级流程

  1. 在haproxy中注释web1的地址

  2. 升级web1

  3. 测试web1

  4. 在haproxy中添加web1的地址,注释掉web2和web3

  5. 升级web2和web3并测试

  6. web2和web3测试成功后,在haproxy中添加web2和web3

实施

# 在haproxy中注释web1的地址
[root@proxy ~]# vim /etc/haproxy/haproxy.cfg 
... ...
listen wordpress *:80
    balance roundrobin
    # server web1 192.168.2.11:80 check inter 2000 rise 2 fall 3
    server web2 192.168.2.12:80 check inter 2000 rise 2 fall 3
    server web3 192.168.2.13:80 check inter 2000 rise 2 fall 3
... ...
[root@proxy ~]# systemctl restart haproxy
# 升级web1
[root@web1 ~]# cd lnmp_soft/
[root@web1 lnmp_soft]# tar xf nginx-1.15.8.tar.gz 
[root@web1 lnmp_soft]# cd nginx-1.15.8/
[root@web1 nginx-1.15.8]# ./configure --with-http_ssl_module --with-http_stub_status_module
[root@web1 nginx-1.15.8]# make
[root@web1 nginx-1.15.8]# mv /usr/local/nginx/sbin/nginx ~/nginx.old
[root@web1 nginx-1.15.8]# cp objs/nginx /usr/local/nginx/sbin/
[root@web1 nginx-1.15.8]# make upgrade  # 只是重启了nginx服务而已
[root@web1 nginx-1.15.8]# systemctl restart nginx.service 
[root@web1 nginx-1.15.8]# ss -tlnp | grep :80
LISTEN     0      128          *:80
# 访问:http://192.168.2.11/测试是否正常
# 在haproxy中注释web2和web3,添加web1
[root@proxy ~]# vim /etc/haproxy/haproxy.cfg 
... ...
listen wordpress *:80
    balance roundrobin
    server web1 192.168.2.11:80 check inter 2000 rise 2 fall 3
    # server web2 192.168.2.12:80 check inter 2000 rise 2 fall 3
    # server web3 192.168.2.13:80 check inter 2000 rise 2 fall 3
... ...
[root@proxy ~]# systemctl restart haproxy
# 升级web2和web3
[root@web2 ~]# systemctl stop nginx.service 
[root@web2 ~]# mv /usr/local/nginx/sbin/nginx ~/nginx.old
[root@web3 ~]# systemctl stop nginx.service 
[root@web3 ~]# mv /usr/local/nginx/sbin/nginx ~/nginx.old
[root@web1 ~]# scp /usr/local/nginx/sbin/nginx 192.168.2.12:/usr/local/nginx/sbin/
[root@web1 ~]# ^12^13
[root@web2 ~]# systemctl start nginx.service 
[root@web3 ~]# systemctl start nginx.service 
# 访问:http://192.168.2.12/测试是否正常
# 访问:http://192.168.2.13/测试是否正常
# 在haproxy中,添加web2和web3
[root@proxy ~]# vim /etc/haproxy/haproxy.cfg 
... ...
listen wordpress *:80
    balance roundrobin
    server web1 192.168.2.11:80 check inter 2000 rise 2 fall 3
    server web2 192.168.2.12:80 check inter 2000 rise 2 fall 3
    server web3 192.168.2.13:80 check inter 2000 rise 2 fall 3
... ...
[root@proxy ~]# systemctl restart haproxy


部署Git版本控制系统 、 优化Web服务器  您阅读本篇文章共花了: 

分享到:

    扫描二维码推送至手机访问。

    版权声明:本文由有云转晴发布,如需转载请注明出处。

    本文链接:https://www.yyzq.cf/?id=124

    分享给朋友:
    返回列表

    上一篇:Keepalived高可用 、 部署Ceph分布式存储

    没有最新的文章了...

    发表评论

    访客

    ◎欢迎参与讨论,请在这里发表您的看法和观点。