ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

树莓派全面配置

2021-05-17 22:02:12  阅读:262  来源: 互联网

标签:树莓 sudo get 配置 apt pip install 全面 config


树莓派操作

默认的用户名: pi,默认的密码是: raspberry

默认的用户名: root,密码: raspberry

在内存卡boot盘中新建一个ssh的空文件,为了打开ssh功能。

在内存卡boot盘中新建一个wpa_supplicant.conf文本文件,写入wifi配置:

country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
	ssid="你的无线网名称"
	psk="你的无线网密码"
	key_mgmt=WPA-PSK
	priority=1
}

在树莓派系统内文件位于/etc/wpa_supplicant/wpa_supplicant.conf

初始设置

换清华源、安装基础命令

# 编辑 `/etc/apt/sources.list` 文件,删除原文件所有内容,用以下内容取代:
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi

# 编辑 `/etc/apt/sources.list.d/raspi.list` 文件,删除原文件所有内容,用以下内容取代:
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install vim
sudo apt-get install screen

给pip3换成阿里源(自己测试感觉是阿里的源比较全和稳)

# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
# pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/sipmle
# pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn
# 上面的不要看

# 这个命令是本机pip安装时查找的源的位置
pip config list -v 
# 打开pip.conf文件,没有就创建目录和文件
~/.pip/pip.conf
# 添加以下内容
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com


python -m pip install --upgrade pip

查看

uname -a
cat /etc/os-release

注意

GPU内存不能拉到812M以上,否则会进不了系统。如果进不去了可以通过SD卡插USB修改config文件。

wiringPi

系统自带的一般是2.5.0版本,需要更新到2.5.2版本才能使用gpio readall命令

# 如果没有自带wiringpi
sudo apt-get install wiringpi

# 更新wiringPi
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb

安装node.js并换源

参考网址:https://github.com/nodesource/distributions/blob/master/README.md

# 先删除自带的低版本nodejs
sudo apt-get remove nodejs

sudo passwd root
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs
npm config set registry https://registry.npm.taobao.org

安装防火墙

# 安装
sudo apt- get install ufw

# 启动
sudo ufw enable

# 查看状态
sudo ufw status

# 开启
sudo ufw allow 22

配置静态IP地址

sudo vim /etc/dhcpcd.conf

# 最后添加以下内容,按照自己的路由器配置来
interface wlan0

static ip_address=192.168.1.2/24
static routers=192.168.1.1
static domain_name_servers=114.114.114.114

树莓派系统设置

sudo raspi-config

# 树莓派配置文件 config.txt 官方说明文档:https://www.raspberrypi.org/documentation/configuration/config-txt.md

# VNC开启
第五行

调整CPU频率

Raspberry Pi OS
sudo nano /boot/config.txt

Ubuntu OS
sudo nano /boot/firmware/config.txt

超頻
over_voltage=6
arm_freq=2000
gpu_freq=700

超頻MAX
over_voltage=6
arm_freq=2147
gpu_freq=750

CPU最高頻率
sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq

CPU最低頻率
sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq

CPU目前頻率
sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

查看温度

# 查看温度一次
vcgencmd measure_temp

# 每2秒刷新温度
watch -n2 vcgencmd measure_temp

搭建文件服务器

sudo apt-get install samba

sudo vim /etc/samba/smb.conf
# 末尾添加
[sun]
comment = sun Storage
path = /home/pi/sun
read only = no
create mask = 0777
directory mask = 0777
guest ok = yes
browseable = yes
# 重启
sudo samba restart

# 开机自启动
sudo update-rc.d samba defaults

安装docker

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun

# 将当前用户加入docker组:
sudo usermod -aG docker $USER

安装Nginx

# 安装nginx依赖包
sudo apt-get install gcc

# 安装PCRE库
sudo apt-get install libpcre3 libpcre3-dev

# 安装zlib库
sudo apt-get install zlib1g zlib1g-dev

# 安装OpenSSL库
sudo apt-get install libssl-dev

tar -zxvf nginx-1.18.0.tar.gz
./configure --prefix=/usr/local/nginx
make
make install
# 项目路径 /usr/local/nginx

标签:树莓,sudo,get,配置,apt,pip,install,全面,config
来源: https://www.cnblogs.com/sunshen/p/14778734.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有