部署Git版本控制系统 、 优化Web服务器
自定义错误页面
Bash
# 存放一张名为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
升级流程
在haproxy中注释web1的地址
升级web1
测试web1
在haproxy中添加web1的地址,注释掉web2和web3
升级web2和web3并测试
web2和web3测试成功后,在haproxy中添加web2和web3
实施
Bash
# 在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