云服务器免费试用

干净的一键卸载宝塔面板WEB运行环境的方法(卸载宝塔面板命令)

服务器知识 0 902

现在国内用户使用宝塔面板用来建站的朋友非常多,如果你的VPS不想做网站了,需要卸载宝塔,一般的VPS商家都可以到后面直接重新安装新的系统,不过有一些商家的VPS是不支持重装系统的,像KT就需要发工单重新安装系统,那么有什么办法可以把宝塔全面卸载呢?今天就给大家分享一个脚本,到VPS里直接执行一下就可以把宝塔面板卸载掉。
脚本如下:
保存成sh文件后,直接执行就可以,sh 文件名.sh

#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH Remove_Bt(){ if [ ! -f "/etc/init.d/bt" ] || [ ! -d "/www/server/panel" ]; then echo -e "此服务器没有安装宝塔!" echo -e "This server does not install bt-panel" exit; fi /etc/init.d/bt stop if [ -f "/usr/sbin/chkconfig" ];then chkconfig --del bt elif [ -f "/usr/sbin/update-rc.d" ];then /usr/sbin/update-rc.d fi rm -rf /www/server/panel rm -f /etc/init.d/bt echo -e "宝塔面板已卸载成功" echo -e "bt-panel uninstall success" } Remove_Service(){ servicePath="/www/server" for service in nginx httpd mysqld pure-ftpd tomcat redis memcached php-fpm-52 php-fpm-53 php-fpm-54 php-fpm-55 php-fpm-56 php-fpm-70 php-fpm-71 do if [ -f "/etc/init.d/${service}" ]; then /etc/init.d/${service} stop if [ -f "/usr/sbin/chkconfig" ];then chkconfig --del ${service} elif [ -f "/usr/sbin/update-rc.d" ];then update-rc.d -f ${service} remove fi if [ "${service}" = "mysqld" ]; then rm -rf ${servicePath}/mysql rm -f /etc/my.cnf elif [ "${service}" = "httpd" ]; then rm -rf ${servicePath}/apache elif [ "${service}" = "memcached" ]; then rm -rf /usr/local/memcached elif [ "${service}" = "nginx" ] || [ "${service}" = "redis" ] || [ "${service}" = "tomcat" ] || [ "${service}" = "pure-ftpd" ] ; then rm -rf ${servicePath}/${service} fi rm -f /etc/init.d/${service} echo -e ${service} "\033[32mclean\033[0m" fi done if [ -d "${servicePath}/php" ]; then rm -rf ${servicePath}/php fi if [ -d "${servicePath}/nvm" ]; then rm -rf ${servicePath}/nvm fi if [ -d "${servicePath}/phpmyadmin" ]; then rm -rf ${servicePath}/phpmyadmin fi if [ -f /opt/gitlab/embedded/service/gitlab-rails/Gemfile ];then gitlab-ctl stop yum remove gitlab-ce -y rm -rf /opt/gitlab rm -rf /var/opt/gitlab rm -rf /etc/gitlab rm -rf /www/server/panel/plugin/gitlab fi } Remove_Rpm(){ echo -e "查询已安装rpm包.." echo -e "Find installed packages" for lib in libiconv-1.14 libmcrypt-2.5.8 mcrypt-2.6.8 mhash-0.9.9.9 bt-mysql bt-httpd bt-mariadb bt-php-5.2 bt-php-5.3 bt-php-5.4 bt-php-5.5 bt-php-5.6 bt-php-7.0 bt-php-7.1 do rpm -qa |grep ${lib} > ${lib}.pl libRpm=`cat ${lib}.pl` if [ "${libRpm}" != "" ]; then rpm -e ${libRpm} --nodeps > /dev/null 2>&1 echo -e ${lib} "\033[32mclean\033[0m" fi rm -f ${lib}.pl done echo -e "清理完毕" echo -e "Clean over" } Remove_Data(){ rm -rf /www/server/data rm -rf /www/wwwlogs rm -rf /www/wwwroot } echo "=================================================" #echo -e "What you want to do ?(Default:1)" echo "1) 卸载宝塔" echo "2) 卸载宝塔及运行环境" #echo "3) 卸载宝塔及运行环境并清除所有站点相关数据" read -p "请选择你要进行的操作(1-2 默认:1): " action; echo "=================================================" case $action in '1') Remove_Bt ;; '2') Remove_Service if [ -f "/usr/bin/yum" ] & [ -f "/usr/bin/rpm" ]; then Remove_Rpm fi Remove_Bt ;; *) Remove_Bt ;; esac rm -f bt-uninstall.sh
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 #!/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATH Remove_Bt(){ if [ ! -f "/etc/init.d/bt" ] || [ ! -d "/www/server/panel" ]; then echo -e "此服务器没有安装宝塔!" echo -e "This server does not install bt-panel" exit; fi /etc/init.d/bt stop if [ -f "/usr/sbin/chkconfig" ];then chkconfig --del bt elif [ -f "/usr/sbin/update-rc.d" ];then /usr/sbin/update-rc.d fi rm -rf /www/server/panel rm -f /etc/init.d/bt echo -e "宝塔面板已卸载成功" echo -e "bt-panel uninstall success"}Remove_Service(){ servicePath="/www/server" for service in nginx httpd mysqld pure-ftpd tomcat redis memcached php-fpm-52 php-fpm-53 php-fpm-54 php-fpm-55 php-fpm-56 php-fpm-70 php-fpm-71 do if [ -f "/etc/init.d/${service}" ]; then /etc/init.d/${service} stop if [ -f "/usr/sbin/chkconfig" ];then chkconfig  --del ${service} elif [ -f "/usr/sbin/update-rc.d" ];then update-rc.d -f ${service} remove fi if [ "${service}" = "mysqld" ]; then rm -rf ${servicePath}/mysql rm -f /etc/my.cnf elif [ "${service}" = "httpd" ]; then rm -rf ${servicePath}/apache elif [ "${service}" = "memcached" ]; then rm -rf /usr/local/memcached elif [ "${service}" = "nginx" ] || [ "${service}" = "redis" ] || [ "${service}" = "tomcat" ] || [ "${service}" = "pure-ftpd" ] ; then rm -rf ${servicePath}/${service} fi rm -f /etc/init.d/${service} echo -e ${service} "\033[32mclean\033[0m" fi done if [ -d "${servicePath}/php" ]; then rm -rf ${servicePath}/php fi if [ -d "${servicePath}/nvm" ]; then rm -rf ${servicePath}/nvm fi if [ -d "${servicePath}/phpmyadmin" ]; then rm -rf ${servicePath}/phpmyadmin fi if [ -f /opt/gitlab/embedded/service/gitlab-rails/Gemfile ];then gitlab-ctl stop yum remove gitlab-ce -y rm -rf /opt/gitlab rm -rf /var/opt/gitlab rm -rf /etc/gitlab rm -rf /www/server/panel/plugin/gitlab fi}Remove_Rpm(){ echo -e "查询已安装rpm包.." echo -e "Find installed packages" for lib in libiconv-1.14 libmcrypt-2.5.8 mcrypt-2.6.8 mhash-0.9.9.9 bt-mysql bt-httpd bt-mariadb bt-php-5.2 bt-php-5.3 bt-php-5.4 bt-php-5.5 bt-php-5.6 bt-php-7.0 bt-php-7.1 do rpm -qa |grep ${lib} > ${lib}.pl libRpm=`cat ${lib}.pl` if [ "${libRpm}" != "" ]; then rpm -e ${libRpm} --nodeps > /dev/null 2>&1 echo -e ${lib} "\033[32mclean\033[0m" fi rm -f ${lib}.pl done echo -e "清理完毕" echo -e "Clean over"} Remove_Data(){ rm -rf /www/server/data rm -rf /www/wwwlogs rm -rf /www/wwwroot} echo "================================================="  #echo -e "What you want to do ?(Default:1)"echo "1) 卸载宝塔"  echo "2) 卸载宝塔及运行环境"#echo "3) 卸载宝塔及运行环境并清除所有站点相关数据"read -p "请选择你要进行的操作(1-2 默认:1): " action;echo "================================================="   case $action in '1') Remove_Bt ;; '2') Remove_Service if [ -f "/usr/bin/yum" ] & [ -f "/usr/bin/rpm" ]; then Remove_Rpm fi Remove_Bt ;; *) Remove_Bt ;;esac rm -f bt-uninstall.sh

效果如下:

好了,这样就把宝塔面板卸载了,不过最好的方法还是重装安装系统,才是最干净的。

干净的一键卸载宝塔面板WEB运行环境的方法(卸载宝塔面板命令)

原文:https://www.laozuo.org/13544.html

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942@qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: 干净的一键卸载宝塔面板WEB运行环境的方法(卸载宝塔面板命令)
本文地址: https://solustack.com/200.html

相关推荐:

网友留言:

我要评论:

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