- 环境配置
- boot设置
- 开启HDMI
- 1.确定屏幕分辨率
- 2.在内存卡boot中修改config.txt文件,增加如下内容
max_usb_current=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_drive=1
hdmi_cvt 1024 600 60 6 0 0 0
display_rotate=2 #屏幕旋转180°
- 启动串口
- .在内存卡boot中修改config.txt文件,增加如下内容
enable_uart=1 - 在putty软件中设置串口号,波特率(115200)
- user:pi passwd:raspberry
- .在内存卡boot中修改config.txt文件,增加如下内容
- 开启HDMI
- 设置wifi
- 方法一(开机后)
- 进入sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
- 增加如下参数
#WPA/WPA2加密:
network={
ssid="红米手机"
key_mgmt=WPA-PSk
psk="12345678"
}
WEP加密:
network={
ssid="无线网密码"
key_mgmt=NONE
wep_Key0="无线网密码"
}
- 方法二(开机前)
- 在sd卡boot分区新建wpa_supplicant.conf文件(注意:此文件在树莓派启动后,会从boot分区消失)
- 文件里面填写如下内容
country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="红米手机"
key_mgmt=WPA-PSK
psk="12345678"
} #WPA/WPA2加密
- 方法一(开机后)
- 开启ssh和远程桌面
- 方法一(sudo raspi-config)
- 打开 sudo raspi-config
- 第五项设置interfacing options
- 打开2ssh和3vnc(注:ssh开启后可以使用winscp服务)
- 方法二(boot)
- 在boot文件里面新建一个ssh文件,里面什么内容都不要
- 方法三
- 首选项
- 树莓派配置
- interfaces选项找到ssh选择enable
- 方法一(sudo raspi-config)
- 开机自启vnc配置(https://www.cnblogs.com/crosys/p/6220471.html)
- 1.编辑配置文档
- sudo nano /etc/init.d/vncserver
添加如下内容
#!/bin/sh
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop vncserver
### END INIT INFO
# More details see:
# http://www.penguintutor.com/linux/vnc
### Customize this entry
# Set the USER variable to the name of the user to start vncserver under
export USER='pi'
### End customization required
eval cd ~$USER
case "$1" in
start)
# 启动命令行。此处自定义分辨率、控制台号码或其它参数。
su $USER -c '/usr/bin/vncserver -depth 16 -geometry 1024x768 :1'
echo "Starting VNC server for $USER "
;;
stop)
# 终止命令行。此处控制台号码与启动一致。
su $USER -c '/usr/bin/vncserver -kill :1'
echo "vncserver stopped"
;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
;;
esac
exit 0
- sudo nano /etc/init.d/vncserver
- 2.修改权限
- sudo chmod 755 /etc/init.d/vncserver
- 3.添加开机启动项
- sudo update-rc.d vncserver defaults
- 1.编辑配置文档
- 配置看门狗(https://blog.csdn.net/a51509/article/details/80303162)
- 1.安装watchdog
- sudo apt install watchdog
- 2.编辑/etc/modules
- 1.sudo nano /etc/modules
- 2.添加bcm2708_wdog
- 3.编辑/etc/watchdog.conf
- 1.sudo nano /etc/watchdog.conf
- 2.添加如下内容
watchdog-device = /dev/watchdog
# 最大进程数
max-load-1 = 24
# 高温复位(80度)
temperature-device = /sys/class/thermal/thermal_zone0/temp
max-temperature = 80000
- 4.设置开机自启
- sudo chkconfig watchdog on
- 5.手动启动看门狗
- sudo service watchdog start
- 6.测试forkbomb
- : () { : | : & } ; :
- 1.安装watchdog
- 配置国内源
- sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份
- sudo nano /etc/apt/sources.list #编辑sources.list 文件,这个是修改软件源
- 国内源(注释掉原来的/删除) nano: ctrl+o后回车保存文件,ctrl+x退出
#清华 Debian9(stretch) (参考网址https://mirror.tuna.tsinghua.edu.cn/help/raspbian/)
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main non-free contrib
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main non-free contrib
- 更新源列表索引
sudo apt-get update
sudo apt-get upgrade
- 安装VIM及实现vi编辑器行号
- 安装vim命令
sudo apt-get install vim - 设置行号
sudo vim /etc/vim/vimrc
set number - 当安装vim报如下错误解决方案(vim : 依赖: vim-common (= 2:7.3.429-2ubuntu2) 但是 2:7.3.429-2ubuntu2.1 正要被安装)
sudo apt-get purge vim-common
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install vim
- 安装vim命令
- 基于Fcitx输入法框架中文输入法
- 安装Fcitx(谷歌拼音、搜狗拼音)
sudo apt-get install fcitx fcitx-googlepinyin fcitx-module-cloudpinyin fcitx-sunpinyin
- 安装Fcitx(谷歌拼音、搜狗拼音)
- c编译器安装
- 输入 git clone git://git.drogon.net/wiringPi
- 输入cd wiringPi
- 输入git pull origin
- 输入./build
- 配置samba(和ubuntu基本一样除了重启samba服务命令有差异)
- 安装samba服务
sudo apt-get update
sudo apt-get install samba samba-common - 修改配置文件smb.conf(下面#注释的需要删除否则会报错)
sudo vi /etc/samba/smb.conf
最后一行增加如下内容
[share] #共享文件的名称, 将在网络上以此名称显示
path = /home/share #共享文件的路径
available = yes
browseable = yes
public = yes #不需要密码,的时候删去注释符号
writable = yes - 重启samba服务
sudo service smbd restart - 报错
Job for smbd.service failed because the control process exited with error code.
See "systemctl status smbd.service" and "journalctl -xe" for details.
原因是配置文件有问题,#号后面的注释需要另起一行
- 安装samba服务
- ddns(多级路由跨局域网,内网穿透解决方法)
- 说明
- 1.树莓派ip:192.168.0.107
- 2.tp路由ip:192.168.1.3,树莓派挂在tp上
- 3.天翼路由网关
- 4.http://tool.chinaz.com/port/ 端口开放查询网址
- 过程
- 1.tp开启ddns功能得到一个网址
- 2.tp开启虚拟服务器把树莓派22端口映射
- 3.天翼网关映射tp路由的22端口
- 4.把购买的域名解析到ddns分配的域名上去
- 说明
- boot设置
Raspberry Pi环境配置
于 2022-04-07 13:35:37 首次发布