前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >宝塔面板安装使用常见问题收集

宝塔面板安装使用常见问题收集

作者头像
用户7146828
发布2021-08-09 15:00:52
2.4K0
发布2021-08-09 15:00:52
举报
文章被收录于专栏:旧云博客

使用 SSH 连接工具,如 堡塔SSH终端连接到您的 Linux 服务器后, 挂载磁盘,根据系统执行相应命令开始安装(大约2分钟完成面板安装):

Centos安装脚本

代码语言:javascript
复制
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

Ubuntu/Deepin安装脚本

代码语言:javascript
复制
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh

Debian安装脚本

代码语言:javascript
复制
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh

Fedora安装脚本

代码语言:javascript
复制
wget -O install.sh http://download.bt.cn/install/install_6.0.sh && bash install.sh

注意:必须为没装过其它环境如Apache/Nginx/php/MySQL的新系统,推荐使用centos 8.X的系统安装宝塔面板

安装要求:

  • 内存:512M以上,推荐768M以上(纯面板约占系统60M内存)
  • 硬盘:300M以上可用硬盘空间(纯面板约占20M磁盘空间)
  • 系统:CentOS 7.1+ (Ubuntu16.04+.、Debian9.0+),确保是干净的操作系统,没有安装过其它环境带的Apache/Nginx/php/MySQL/pgsql/gitlab/java(已有环境不可安装)
  • 架构:x86_64(主流服务器均是此架构),ARM不完整兼容(面板环境安装慢,部分软件可能安装不上)

宝塔Linux面板7.4.7版本是基于Centos开发的,为了最好的兼容性,请优先考虑使用Centos8.x系统

系统兼容性顺序:

Centos8.x > Centos7.x > Ubuntu18.04 > Debian10 > Ubuntu 20.04 > 其它系统

提示:Centos官方已宣布在2020年停止对Centos6的维护更新,各大软件开发商也逐渐停止对Centos6的兼容,新服务器不建议使用Centos6

以下主机商必看(开端口教程,不开不能用):

腾讯云:https://www.bt.cn/bbs/thread-1229-1-1.html

阿里云:https://www.bt.cn/bbs/thread-2897-1-1.html

华为云:https://www.bt.cn/bbs/thread-3923-1-1.html

推荐先安装 堡塔SSH客户端 (免费/简单/中文/多屏)

Linux面板7.4.7安装命令:

使用SSH 连接工具(查看使用方法),挂载磁盘后(查看),根据系统执行框内命令开始安装(大约2分钟完成面板安装)

Centos安装命令:

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

试验性Centos/Ubuntu/Debian安装命令 独立运行环境(py3.7) 可能存在少量兼容性问题 不断优化中

curl -sSO http://download.bt.cn/install/install_panel.sh && bash install_panel.sh

Ubuntu/Deepin安装命令:

wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh

Debian安装命令:

wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh

Fedora安装命令:

wget -O install.sh http://download.bt.cn/install/install_6.0.sh && bash install.sh

Linux面板7.4.7升级命令:

curl http://download.bt.cn/install/update6.sh|bash

以上节点无法使用的情况下,请使用下面的备用节点:

备用节点【江苏】:

yum install -y wget && wget -O install.sh http://180.101.160.68:5880/install/install_6.0.sh && sh install.sh

备用节点【香港】:

yum install -y wget && wget -O install.sh http://103.224.251.67:5880/install/install_6.0.sh && sh install.sh

备用节点【美国】:

yum install -y wget && wget -O install.sh http://128.1.164.196:5880/install/install_6.0.sh && sh install.sh

若点击更新后没生效,请尝试重启面板服务:

bt restart

面板特色功能:

  • 一键配置服务器环境(LAMP/LNMP)
  • 一键安全重启
  • 一键创建管理网站、ftp、数据库
  • 一键部署SSL证书
  • 一键部署源码(discuz、wordpress、dedecms、z-blog、微擎等等)
  • 一键配置(定期备份、数据导入、伪静态、301、SSL、子目录、反向代理、切换PHP版本)
  • 一键安装常用PHP扩展(fileinfo、intl、opcache、imap、memcache、apc、redis、ioncube、imagick)
  • 数据库一键导入导出
  • 系统监控(CPU、内存、磁盘IO、网络IO)
  • 防火墙端口放行
  • SSH开启与关闭及SSH端口更改
  • 禁PING开启或关闭
  • 方便高效的文件管理器(上传、下载、压缩、解压、查看、编辑等等)
  • 计划任务(定期备份、日志切割、shell脚本)
  • 软件管理(一键安装、卸载、版本切换)

卸载宝塔面板

注:卸载环境可能会影响服务器数据 请谨慎操作!

1.进入ssh 输入以下命令下载脚本

wget http://download.bt.cn/install/bt-uninstall.sh

2.执行脚本 (若是ubutnu用户请在前面加sudo 例子sudo sh bt-uninstall.sh)

sh bt-uninstall.sh

3.根据提示输入1或2后按回车清理面板或环境 (若输入其他值或不输入直接回车则只卸载面板)

安装宝塔linux面板时出现错误的解决方法

1、如果安装时出现以下截图中的错误

一般都是yum源有问题,进入ssh 输入解决

yum clean all

如果还是不行 请更换yum源

2、安装后错误/usr/bin/bt: line 129: syntax error: unexpected end of file 解决办法

1.网络波动导致无法将宝塔文件写入到/etc/init.d/bt 这个系统文件 2.源文件缺失 下面是解决办法:

代码语言:javascript
复制
mv /etc/init.d/bt   /tmp/bt_back
cp /www/server/panel/init.sh  /etc/init.d/bt && chmod +x  /etc/init.d/bt
/etc/init.d/bt  restart

或者复制下面的代码后使用命令 vim /etc/init.d/bt 粘贴下面代码:

代码语言:javascript
复制
#!/bin/bash
# chkconfig: 2345 55 25
# description: bt Cloud Service

### BEGIN INIT INFO
# Provides:          bt
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts bt
# Description:       starts the bt
### END INIT INFO
panel_init(){
        panel_path=/www/server/panel
        pidfile=$panel_path/logs/panel.pid
        cd $panel_path
        env_path=$panel_path/pyenv/bin/activate
        if [ -f $env_path ];then
                source $env_path
                pythonV=$panel_path/pyenv/bin/python
                chmod -R 700 $panel_path/pyenv/bin
        else
                pythonV=/usr/bin/python
        fi
        reg="^#\!$pythonV\$"
        is_sed=$(cat $panel_path/BT-Panel|head -n 1|grep -E $reg)
        if [ "${is_sed}" = "" ];then
                sed -i "s@^#!.*@#!$pythonV@" $panel_path/BT-Panel
        fi
        is_sed=$(cat $panel_path/BT-Task|head -n 1|grep -E $reg)
        if [ "${is_sed}" = "" ];then
                sed -i "s@^#!.*@#!$pythonV@" $panel_path/BT-Task
        fi
        chmod 700 $panel_path/BT-Panel
        chmod 700 $panel_path/BT-Task
        log_file=$panel_path/logs/error.log
        task_log_file=$panel_path/logs/task.log
        if [ -f $panel_path/data/ssl.pl ];then
                log_file=/dev/null
        fi

        port=$(cat $panel_path/data/port.pl)
}
panel_init

get_panel_pids(){
        isStart=$(ps aux|grep -E '(runserver|BT-Panel)'|grep -v grep|awk '{print $2}'|xargs)
        pids=$isStart
        arr=$isStart
}

get_task_pids(){
        isStart=$(ps aux|grep -E '(task.py|BT-Task)'|grep -v grep|awk '{print $2}'|xargs)
        pids=$isStart
        arr=$isStart    
}

panel_start()
{
        isStart=`ps aux|grep 'runserver:app'|grep -v grep|awk '{print $2}'`
        if [ "$isStart" != '' ];then
                kill -9 $isStart
        fi
        get_panel_pids
        if [ "$isStart" == '' ];then
                rm -f $pidfile
                panel_port_check
                echo -e "Starting Bt-Panel...\c"
                nohup $panel_path/BT-Panel >> $log_file 2>&1 &
                isStart=""
                n=0
                while [[ "$isStart" == "" ]];
                do
                        echo -e ".\c"
                        sleep 0.5
                        get_panel_pids
                        let n+=1
                        if [ $n -gt 8 ];then
                                break;
                        fi
                done
                if [ "$isStart" == '' ];then
                        echo -e "\033[31mfailed\033[0m"
                        echo '------------------------------------------------------'
                        tail -n 20 $log_file
                        echo '------------------------------------------------------'
                        echo -e "\033[31mError: BT-Panel service startup failed.\033[0m"
                fi
                echo -e "    \033[32mdone\033[0m"
        else
                echo "Starting Bt-Panel... Bt-Panel (pid $(echo $isStart)) already running"
        fi
        
        get_task_pids
        if [ "$isStart" == '' ];then
                echo -e "Starting Bt-Tasks... \c"
                nohup $panel_path/BT-Task >> $task_log_file 2>&1 &
                sleep 0.2
                get_task_pids
                if [ "$isStart" == '' ];then
                        echo -e "\033[31mfailed\033[0m"
                        echo '------------------------------------------------------'
                        tail -n 20 $task_log_file
                        echo '------------------------------------------------------'
                        echo -e "\033[31mError: BT-Task service startup failed.\033[0m"
                        return;
                fi
                echo -e "    \033[32mdone\033[0m"
        else
                echo "Starting Bt-Tasks... Bt-Tasks (pid $isStart) already running"
        fi
}

panel_port_check()
{
    is_process=$(lsof -n -P -i:$port|grep LISTEN|grep -v grep|awk '{print $1}'|sort|uniq|xargs)
    for pn in ${is_process[@]}
        do
          if [ "$pn" = "nginx" ];then
                /etc/init.d/nginx restart
          fi

          if [ "$pn" = "httpd" ];then
                /etc/init.d/httpd restart
          fi

          if [ "$pn" = "mysqld" ];then
                /etc/init.d/mysqld restart
          fi

          if [ "$pn" = "superviso" ];then
                pkill -9 superviso
                sleep 0.2
                supervisord -c /etc/supervisor/supervisord.conf
          fi

          if [ "$pn" = "pure-ftpd" ];then
                /etc/init.d/pure-ftpd restart
          fi

          if [ "$pn" = "memcached" ];then
                /etc/init.d/memcached restart
          fi

          if [ "$pn" = "sudo" ];then
                if [ -f /etc/init.d/redis ];then
                    /etc/init.d/redis restart
                fi
          fi

          if [ "$pn" = "php-fpm" ];then
                php_v=(52 53 54 55 56 70 71 72 73 74);
                for pv in ${php_v[@]};
                do
                    if [ -f /etc/init.d/php-fpm-${pv} ];then
                        if [ -f /www/server/php/%{pv}/sbin/php-fpm ];then
                            if [ -f /tmp/php-cgi-${pv}.sock ];then
                                /etc/init.d/php-fpm-${pv} start
                            fi
                            /etc/init.d/php-fpm-${pv} restart
                        fi
                    fi
                done
          fi
        done
    
    is_ports=$(lsof -n -P -i:$port|grep LISTEN|grep -v grep|awk '{print $2}'|xargs)
    if [ "$is_ports" != '' ];then
        kill -9 $is_ports
        sleep 1
    fi
}

panel_stop()
{
        echo -e "Stopping Bt-Tasks...\c";
        get_task_pids
        arr=($pids)
        for p in ${arr[@]}
        do
                kill -9 $p
        done
        echo -e "    \033[32mdone\033[0m"

        echo -e "Stopping Bt-Panel...\c";

        get_panel_pids
        for p in ${arr[@]}
        do
                kill -9 $p &>/dev/null
        done
        
        if [ -f $pidfile ];then
                rm -f $pidfile
        fi
        echo -e "    \033[32mdone\033[0m"
}

panel_status()
{
        port=$(cat $panel_path/data/port.pl)
        get_panel_pids
        if [ "$isStart" != '' ];then
                echo -e "\033[32mBt-Panel (pid $(echo $isStart)) already running\033[0m"
        else
                echo -e "\033[31mBt-Panel not running\033[0m"
        fi
        
        get_task_pids
        if [ "$isStart" != '' ];then
                echo -e "\033[32mBt-Task (pid $isStart) already running\033[0m"
        else
                echo -e "\033[31mBt-Task not running\033[0m"
        fi
}

panel_reload()
{
    isStart=$(ps aux|grep 'runserver:app'|grep -v grep|awk '{print $2}')
        if [ "$isStart" != '' ];then
        kill -9 $isStart
        sleep 0.5
    fi
    get_panel_pids
        if [ "$isStart" != '' ];then
        
        get_panel_pids
    for p in ${arr[@]}
        do
                kill -9 $p
        done
        rm -f $pidfile
        panel_port_check
        echo -e "Reload Bt-Panel.\c";
                nohup $panel_path/BT-Panel >> $log_file 2>&1 &
        isStart=""
        n=0
        while [[ "$isStart" == "" ]];
        do
            echo -e ".\c"
            sleep 0.5
            get_panel_pids
            let n+=1
            if [ $n -gt 8 ];then
                break;
            fi
        done
        if [ "$isStart" == '' ];then
                echo -e "\033[31mfailed\033[0m"
                echo '------------------------------------------------------'
                tail -n 20 $log_file
                echo '------------------------------------------------------'
                echo -e "\033[31mError: BT-Panel service startup failed.\033[0m"
                return;
        fi
        echo -e "    \033[32mdone\033[0m"
    else
        echo -e "\033[31mBt-Panel not running\033[0m"
        panel_start
    fi
}

install_used()
{
        if [ ! -f $panel_path/aliyun.pl ];then
                return;
        fi
        password=$(cat /dev/urandom | head -n 16 | md5sum | head -c 12)
        username=$($pythonV $panel_path/tools.py panel $password)
        echo "$password" > $panel_path/default.pl
        rm -f $panel_path/aliyun.pl
}

error_logs()
{
    tail -n 100 $log_file
}


case "$1" in
        'start')
                install_used
                panel_start
                ;;
        'stop')
                panel_stop
                ;;
        'restart')
                panel_stop
                sleep 1
                panel_start
                ;;
        'reload')
                panel_reload
                ;;
        'status')
                panel_status
                ;;
        'logs')
                error_logs
                ;;
        'panel')
                $pythonV $panel_path/tools.py cli $2
                ;;
        'default')
                port=$(cat $panel_path/data/port.pl)
                password=$(cat $panel_path/default.pl)
                if [ -f $panel_path/data/domain.conf ];then
                    address=$(cat $panel_path/data/domain.conf)
                fi
                if [ -f $panel_path/data/admin_path.pl ];then
                    auth_path=$(cat $panel_path/data/admin_path.pl)
                fi
                if [ "$address" = "" ];then
                    address=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
                fi
                pool=http
                if [ -f $panel_path/data/ssl.pl ];then
                    pool=https
                fi
                echo -e "=================================================================="
                echo -e "\033[32mBT-Panel default info!\033[0m"
                echo -e "=================================================================="
                echo  "Bt-Panel-URL: $pool://$address:$port$auth_path"
                echo -e `$pythonV $panel_path/tools.py username`
                echo -e "password: $password"
                echo -e "\033[33mWarning:\033[0m"
                echo -e "\033[33mIf you cannot access the panel, \033[0m"
                echo -e "\033[33mrelease the following port (8888|888|80|443|20|21) in the security group\033[0m"
                echo -e "=================================================================="
                ;;
        *)
                $pythonV $panel_path/tools.py cli $1
        ;;
esac

然后按ESC输入:wq

宝塔一键迁移API版本 3.0版本教程

https://www.bt.cn/bbs/thread-42566-1-1.html

.shang_content { width:80%; margin:40px auto 10px auto; text-align:center; text-indent: 0; } } .hide_box { z-index:999; filter:alpha(opacity=50); background:#666; opacity:0.5; -moz-opacity:0.5; left:0; top:0; height:99%; width:100%; position:fixed; display:none; } .shang_box { color:#fff; width:800px; height:550px; padding:10px; background-color:#d8d7d7; border-radius:10px; position:fixed; z-index:1000; left:40%; top:45%; margin-left:-280px; margin-top:-280px; border: 2px solid #dc5f06; display:none; } .shang_box img { border:none; border-width:0; display: initial;} .dashang { display:block; width:100px; margin:10px auto; height:auto; padding:10px 18px; text-align:center; text-decoration:none; font-size:16px; transition:all 0.3s; font-weight:400; outline:0!important; color:#fff!important; background-color:#f05050; border-color:#f05050; border-radius:30px; margin-bottom:20px; text-indent: 0; } .shang_close { float:right; display:inline-block; } .shang_logo { display:block; text-align:center; margin:20px auto; } .shang_tit { width:100%; color:#000000; margin:10px auto 30px auto; } .shang_tit p { color:#000; text-align:center; font-size:18px; font-weight:900; text-indent: 0; } .shang_payimg { width:640px; text-align:center; margin:10px auto; border-radius:3px; height:365px; } .pay_explain { text-align:center; margin:10px auto 25px auto; font-size:14px; color:#333; } .radiobox { width:16px; height:16px; background:url('https://love2wind.cn/usr/themes/spzac/img/shang/radio2.jpg'); display:block; float:left; margin-top:5px; margin-right:14px; } .checked .radiobox { background:url('https://love2wind.cn/usr/themes/spzac/img/shang/radio1.jpg'); } .shang_payselect { text-align:center; margin:0 auto; margin-top:40px; cursor:pointer; height:60px; width:320px; } .shang_payselect .pay_item { display:inline-block; margin-right:10px; float:left; } .shang_info { clear:both; text-indent: 0; } .shang_info p,.shang_info a { color:#ff0000; text-align:center; font-size:16px; text-decoration:none; line-height:0em; text-indent: 0; }

赞 赏

如果觉得我的文章对你有用,请随意赞赏

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021年05月18日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Centos安装脚本
  • Ubuntu/Deepin安装脚本
  • Debian安装脚本
  • Fedora安装脚本
  • 安装要求:
  • Linux面板7.4.7安装命令:
    • Centos安装命令:
      • 试验性Centos/Ubuntu/Debian安装命令 独立运行环境(py3.7) 可能存在少量兼容性问题 不断优化中
        • Ubuntu/Deepin安装命令:
          • Debian安装命令:
            • Fedora安装命令:
            • Linux面板7.4.7升级命令:
              • 备用节点【江苏】:
                • 备用节点【香港】:
                  • 备用节点【美国】:
                  • 面板特色功能:
                  • 卸载宝塔面板
                  • 安装宝塔linux面板时出现错误的解决方法
                  • 宝塔一键迁移API版本 3.0版本教程
                  相关产品与服务
                  云数据库 MySQL
                  腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
                  领券
                  问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档