所需硬件
开发板+sd卡+sd卡读卡器+电源线+网线+亚克力外壳
刷系统
用balenaEtcher软件给sd卡刷img镜像。我下载的是有带桌面环境的。
Raspberry Pi OS with desktop
刷好后电脑上重新拔插读卡器,读到一个名为boot的驱动设备,进根目录添加一个名为ssh的文件(无后缀)。
配置系统
sd卡插上树莓派,网线插上,上电,等待开机初始化几分钟。
由于我是路由器引的网线,因此进入路由器后台,找到名为raspberrypi的主机,记住ip。
使用xshell软件通过ssh连接树莓派。ip为记住的ip,用户为pi,密码为raspberry。
由于我没有用HDMI接外显示器。因此用的VNC Viewer连接,默认是关闭的。以下为开启VNC方法。
进去后执行以下命令:
sudo raspi-config方向键选择Interfacing Options,里面的VNC,为yes,返回按esc。
继续方向键选择Advanced Options,里面的Resolution,选择合适的分辨率,我的1280x720。
然后就可以去下载win客户端的VNC® Viewer。
VNC Server填刚才记住的ip加上::5900,例如我的192.168.1.111::5900。
Name随你便,进去后它要你设置初始化一些信息,还有新的密码。
切换成国内镜像源
sudo nano /etc/apt/sources.list将原始的源注释,添加下面的源:
#aliyun
deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi再输入命令:
sudo nano /etc/apt/sources.list.d/raspi.list将原始的源注释,添加下面的源
#aliyun
deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ buster main更新系统
sudo apt-get update
sudo apt-get upgrade -yssh远程访问
sudo raspi-config选择 5Interfacing Options里面的ssh,把disable改为enable
root访问ssh
sudo nano /etc/ssh/sshd_config#找到 PermitRootLogin 并添加下面一行代码
PermitRootLogin yes打开root用户
# 按提示输入要设置的密码就可以了
sudo passwd root正常识别exfat/NTFS
对exfat格式的支持:
sudo apt-get install exfat-fuse对NTFS格式的支持:
sudo apt-get install ntfs-3gSpeedTest测速
wget https://rawchen.com/speedtest.py
python speedtest.pyI/O测速
sudo apt-get install hdparm# 执行命令
sudo hdparm -t /dev/mmcblk0frp实现内网穿透
这是什么呢?简单说就是你的树莓派没有暴露在公网上。借助这个内网穿透能在外网主机访问到你内网的树莓派。
frp的原理是通过反向代理,也就是中间服务端做转发。因此需要一台云服务器。
服务端配置 - frps
wget https://github.com/fatedier/frp/releases/download/v0.17.0/frp_0.17.0_linux_amd64.tar.gz
tar -zxvf frp_0.17.0_linux_amd64.tar.gz
cd frp_0.17.0_linux_amd64
nano frps.ini配置文件内容如下:
[common]
bind_port = 7000
vhost_http_port = 80
dashboard_port = dashboard_port_number
dashboard_user = dashboard_user_name
dashboard_pwd = dashboard_pwd_value
privilege_token = privilege_token_valuectrl+x退出,提示是否保存,按y,再提示保存在哪,按回车。
参数说明
bind_port:绑定的端口,需要与客户端中 server_port 参数保持一致
vhost_http_port:虚拟主机运行在本机的端口,如果 vps 有服务占用了端口,应当更换
dashboard_port:frp 后台服务页面的端口,如果设置 8000,便可通过 http://yourip:8000 来访问 frps 的后台页面
dashboard_user:frp 后台服务页面的管理员用户名
dashboard_pwd:frp 后台服务页面的管理员密码
privilege_token:自定义值,必须与客户端中的 privilege_token 保持一致配置完成之后,便可以通过如下命令启动 frps:
./frps -c ./frps.ini为了让服务器一直运行 frp 服务,这里还可以将它添加到开机自启脚本中,命令行如下:
sudo nano /etc/rc.local在 exit 0 前一行,写上命令,其中 <your_frp_path> 为你 frp 存放的目录位置,即:
<your_frp_path>/frps -c <your_frp_path>/frps.inictrl+x退出,提示是否保存,按y,再提示保存在哪,按回车。
客户端配置 - frpc
wget https://github.com/fatedier/frp/releases/download/v0.17.0/frp_0.17.0_linux_arm.tar.gz
tar -zxvf frp_0.17.0_linux_arm.tar.gz
cd frp_0.17.0_linux_arm
nano frpc.ini配置文件内容如下:
[common]
server_addr = your_server_ip
server_port = 7000
privilege_token = privilege_token_value
login_fail_exit = false
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = remote_port_numberctrl+x退出,提示是否保存,按y,再提示保存在哪,按回车。
参数说明
server_addr:服务器端的 ip
server_port:服务器端的端口,即 bind_port
privilege_token:同服务器端的 privilege_token 保持一致
login_fail_exit:失败时自动重连
remote_port:远程端口,即 ssh 连接树莓派时的端口配置完成之后,便可以通过如下命令启动 frps:
./frpc -c ./frpc.ini为了让树莓派一直运行 frp 服务,这里还可以将它添加到开机自启脚本中,命令行如下:
sudo nano /etc/rc.local在 exit 0 前一行,写上命令,其中 <your_frp_path> 为你 frp 存放的目录位置,即:
<your_frp_path>/frpc -c <your_frp_path>/frpc.inictrl+x退出,提示是否保存,按y,再提示保存在哪,按回车。
以上配置完成之后,就可以远程 ssh 连接到树莓派了。命令行如下:
ssh -oPort=<remote_port_number> pi@<your_server_ip>其中,<remote_port_number> 为树莓派配置中的 remote_port 参数值,<your_server_ip> 为服务器 ip。
安装jdk1.8
下载:jdk-8u241-linux-arm32-vfp-hflt.tar.gz
我是通过u盘拷贝,因此为/media/pi/DATE/,这个目录是要改的。
sudo tar zxf /media/pi/DATE/jdk-8u241-linux-arm32-vfp-hflt.tar.gz -C /usr/local
sudo nano /etc/profile添加:
export JAVA_HOME=/usr/local/jdk1.8.0_241
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:JAVA_HOME/lib/dt.jar:JAVA_HOME/lib/tools.jar输入命令使其生效
source /etc/profile
用U盘作系统盘
测过速度,sd卡读取20m/s,2.0金士顿优盘读取30m/s,所以树莓派可以用优盘当系统盘。
需要使用Raspbian / Raspbian Lite或更高版本的2017-04-10版本,官方的可以。
- 看到这应该是sd卡已经有装好系统了吧,进系统执行命令:
echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt
sudo reboot- 验证
vcgencmd otp_dump | grep 17:若输出17:3020000a 则成功。若不是,那么OPT位没有被编程。
- 关机,拔出SD卡,插上你刷好Raspbian系统的U盘吧!此时不要插入多个优盘。
搭建宝塔动态网页LNMP
前提要更新下系统哈,前面有。
然后切换到root超级权限操作。
sudo su
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && bash install.sh没记住初始密码:
cat /www/server/panel/default.pl折腾完想卸载:
rm -f /etc/init.d/bt && rm -rf /www/server/panel

You really make it seem so easy with your presentation but I find this matter to be really something that I think I would never understand.
It seems too complex and extremely broad for me. I'm looking forward for your
next post, I'll try to get the hang of it!
Hmm is anyone else encountering problems with the pictures on this blog loading?
I'm trying to find out if its a problem on my end or if it's the blog.
Any suggestions would be greatly appreciated.
Ahaa, its good discussion regarding this piece of writing at this
place at this webpage, I have read all that, so
now me also commenting here.
Very quickly this web site will be famous amid all blogging visitors, due to it's fastidious articles or reviews
Hurrah, that's what I was searching for, what a data!
present here at this blog, thanks admin of this web site.