安装宝塔
# 安装宝塔
由于运行的是Raspbian系统,所以使用官网提供的Ubuntu/Deepin一键安装脚本。
切换到root账户:
> 在某些情况下,非root安装可能会报“Make python env fielded”等权限错误。
使用root账户安装比较稳妥。
```
sudo -i
```
## 安装宝塔面板64位Debian系统
系统:2020-05-27-raspios-buster-arm64.img
[官方-宝塔Linux面板安装教程](https://www.bt.cn/bbs/thread-19376-1-1.html)
[纯小白入坑树莓派(四)安装宝塔面板](http://sianx.com/posts/8bb66036/)
Ubuntu/Deepin安装命令:
```js
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh
```
>w 注意:不要输入脚本安装命令最后那串字符
- **先用上述命令安装**。如果失败了,再去官方查安装命令!
- 该命令可以直接从官网下载相应安装文件,并执行脚本自动进行安装。
- 一定要在root环境下安装,**宝塔官网提供的命令是没有加sudo的,可能会导致安装失败**。
- 安装时间大概是几分钟,这个取决与当前网络环境,和需要更新的软件包数量。
安装结果:
```js
Congratulations! Installed successfully!
==================================================================
外网面板地址: http://123.14.71.3:8888/1b942b14
内网面板地址: http://192.168.1.180:8888/1b942b14
*以下仅为初始默认账户密码,若无法登录请执行bt命令重置账户/密码登录
username: aq7zby3g
password: 7072b486
If you cannot access the panel,
release the following panel port [8888] in the security group
若无法访问面板,请检查防火墙/安全组是否有放行面板[8888]端口
==================================================================
Time consumed: 27 Minute!
```
### 错误处理
安装的过程中可能报如下错误:
```js
install.sh: line 1: syntax error near unexpected token `<'
install.sh: line 1: `<html><body><br><br><br><script></script><script>window.location="/?adfwkey=nvt04";</script><br><br><br><center><h3><a href="/?adfwkey=nvt04"><p>çû¹ÄúĵÒҳæÃûÐ×ÔԶ¯ø×ת£¬ëãµ÷»ÕâÀï</p></a></h3></center></body></html>'
```
这是因为下载节点有问题导致文件无法下载。需要切换一个备用节点。
宝塔官方提供了香港、江苏、美国等节点。
将上述安装命令中的节点地址替换成江苏节点:
```
wget -O install.sh http://180.101.160.68:5880/install/install_6.0.sh && sudo bash install.sh
```
[树莓派4B(Debian10 arm64)安装宝塔面板填坑记录](https://www.vvso.cn/xlbk/16177.html)
## 4B+64位系统宝塔跑分

## 安装宝塔面板32位Debian系统
系统:2020-12-02-raspios-buster-armhf.img
>w 宝塔6.0以上版本,只支持64位系统。
32位树莓派系统,只能安装5.9版本的宝塔
Linux面板5.9(稳定版)Ubuntu/Deepin安装命令:
```js
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash install.sh
```
参考教程:[树莓派上安装宝塔面板,搭建网站管理系统](https://www.lxx1.com/3424)
安装结果:
```js
==================================================================
Congratulations! Install succeeded!
==================================================================
外网面板地址: http://115.46.77.74:8888/0514d610
内网面板地址: http://192.168.1.4:8888/0514d610
username: ojgeinzj
password: 5393b587
If you cannot access the panel,
release the following panel port [8888] in the security group
若无法访问面板,请检查防火墙/安全组是否有放行面板[8888]端口
==================================================================
Time consumed: 18 Minute!
```
这个地址是公网地址,树莓派在局域网,换成树莓派的局域网IP后才可以访问。
## 相关命令
[宝塔命令大全](https://www.bt.cn/btcode.html)
查看面板入口:
```language
sudo /etc/init.d/bt default
```
关闭安全入口:rm -f
```language
/www/server/panel/data/admin_path.pl
```
修改面板密码,如要改成123456
```language
cd /www/server/panel && python tools.py panel 123456
```
下载卸载脚本:
```language
wget http://download.bt.cn/install/bt-uninstall.sh
```
卸载宝塔面板:
```language
sh bt-uninstall.sh
```
## 更改apt软件源和raspberrypi软件源为中科大源
>w 在安装宝塔面板之前不要更换树莓派的软件源,不然安装过程有可能会出现各种报错
### 更改apt软件源
```language
sudo sed -i 's|raspbian.raspberrypi.org|mirrors.ustc.edu.cn/raspbian|g' /etc/apt/sources.list
```
### 更改raspberrypi软件源
```language
sudo sed -i 's|//archive.raspberrypi.org|//mirrors.ustc.edu.cn/archive.raspberrypi.org|g' /etc/apt/sources.list.d/raspi.list
```
### 更新源
```language
sudo apt-get update
```
### 更新固件
> 据说可以显著降低发热:
```language
sudo apt-get full-upgrade
```
更新的过程中,需要确认是否继续