换源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo nano /etc/apt/sources.list

注:在nano中,用ctrl+k批量删除,ctrl+o保存,ctrl+x退出

Ubuntu 18.04 ARM64 可用的国内源(太垃圾了,建议换20.04)
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security multiverse

Ubuntu 20.04 ARM64 可用的国内源
deb https://mirror.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb https://mirror.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb https://mirror.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb https://mirror.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
deb https://mirror.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse

更新源

sudo apt-get update
sudo apt-get upgrade

创建文件夹

mkdir repository
mkdir store

开机启动

sudo nano /etc/systemd/system/rc-local.service

写入以下文段

(默认添加Unit和Service:

[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

[Install]
WantedBy=multi-user.target
Alias=rc-local.service

执行创建
sudo nano /etc/rc.local

写入(开机自动挂载硬盘,创建screen并注入服务等)
#!/bin/bash -e
sudo mount /dev/sda1 /home/ubuntu/repository
sudo mount /dev/sdb1 /home/ubuntu/store
sudo systemctl start nginx
sudo systemctl start mysql
sudo systemctl start redis-server
sudo systemctl start docker
sudo docker container start hch_rabbitmq
sudo sleep 10
screen_name="frp"
sudo screen -dmS $screen_name
sudo screen -x -S $screen_name -p 0 -X stuff $'cd /home/ubuntu/frp\n./frpc -c frpc.ini\n'
screen_name="invoice_python"
sudo screen -dmS $screen_name
sudo screen -x -S $screen_name -p 0 -X stuff $'sudo sleep 60\ncd /home/ubuntu/ruoyi/invoice_python\nsudo python3 write_invoice.py\n'
screen_name="ruoyi"
sudo screen -dmS $screen_name
sudo screen -x -S $screen_name -p 0 -X stuff $'cd /home/ubuntu/ruoyi\nsudo java -jar ruoyi-admin.jar\n'
exit 0

(总之一个原则,前置服务没起起来就让后置任务可劲儿等,sleep走起)

sudo chmod +x /etc/rc.local
sudo systemctl enable rc-local
sudo systemctl start rc-local.service
reboot
sudo systemctl status rc-local.service

安装python之安装pip3

sudo apt install python3-pip

安装java8

sudo apt-get install openjdk-8-jdk

安装Nginx

sudo apt install nginx

sudo systemctl status nginx

修改配置文件

sudo nano /etc/nginx/nginx.conf

如有需要可以重启

sudo systemctl restart nginx

安装mysql

sudo apt-get install mysql-server

sudo systemctl restart mysql

修改配置以方便远程管理

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

将bind-address = 127.0.0.1改为bind-address = 0.0.0.0

mysql -uroot -p

输入登陆密码
use mysql;
update user set host='%' where user ='root';
grant all privileges on *.* to 'root'@'%';
FLUSH PRIVILEGES;

修改密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;

安装docker

sudo curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

安装消息队列(下文中的*请自行去「https://cr.console.aliyun.com/」申请)
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://*.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

sudo docker pull rabbitmq:management

镜像列表

sudo docker image ls

删除镜像
sudo docker rmi 镜像名称

容器列表
sudo docker ps

停止容器
sudo docker stop 容器名称
sudo docker kill 容器名称

删除容器

sudo docker rm

启用消息队列
sudo docker run -d -p 5672:5672 -p 15672:15672 --name hch_rabbitmq rabbitmq:management

安装redis

sudo apt install redis-server

sudo systemctl status redis-server

如有需要可以重启

sudo systemctl restart redis-server

安装mangoDB

sudo screen -S mongodb

开启服务

cd /home/ubuntu/mongodb/bin

./mongod --bind_ip=0.0.0.0 --auth --port=27017

linux管理

sudo ./mongo

鉴权

db.auth('账号','密码')

show users

use admin

安装字体

sudo apt-get -y install fontconfig xfonts-utils

sudo cp /home/ubuntu/repository/font/* /usr/share/fonts/

cat /etc/issue

fc-list

cd /usr/share/fonts/

sudo mkfontscale

sudo mkfontdir

fc-cache

连接wifi(20.04以上版本)

sudo apt update

sudo apt install net-tools

sudo ifconfig wlan0 up

sudo apt install wireless-tools

sudo apt install iw

sudo apt-get install wpasupplicant

sudo apt-get install network-manager

cd /etc/netplan/

ls

sudo nano 你的文件名

输入

network:
ethernets:
eth0:
dhcp4: true
optional: true
version: 2
wifis:
wlan0:
dhcp4: true
access-points:
"你的wifi的ssid":
password: "你的密码"

保存

sudo netplan generate

sudo netplan apply

拔掉网线后重启

接着等待足够长的时间后

用wifi连ssh重启即可

查看网络配置

ifconfig -a

设置ffmpeg全局变量

sudo chmod -R 777 /home/ubuntu/ffmpeg

sudo ln -s /home/ubuntu/ffmpeg/ffmpeg /usr/bin/ffmpeg

sudo ln -s /home/ubuntu/ffmpeg/ffprobe /usr/bin/ffprobe

ffmpeg

ffprobe

运行SpringBoot后端

sudo java -jar ruoyi-admin.jar

frp相关

客户端

sudo chmod -R 777 frp文件夹

cd frp文件夹

sudo nano frpc.ini

# 这个别改

[common]

server_addr = 你的ip
server_port = 7000
token = 你的鉴权秘钥

# 随便写一个名字

[article]
type = tcp
local_ip = 127.0.0.1
local_port = 本地端口
remote_port = 服务端转发的端口

# 相当于你访问服务端的remote_port就能访问到客户端的local_port

./frpc -c frpc.ini

服务端

cd frp文件夹

sudo nano frps.ini

[common]
server_addr = 0.0.0.0
# frp 服务所使用的端口(TCP)
bind_port = 7000

# frp看板端口
dashboard_port = 6443

# 无连接延迟时间
authentication_timeout = 9000
dashboard_user = 看板用户名
dashboard_pwd = 看板密码
token = 你的鉴权秘钥(和客户端一致)

重启相关

断电重启之前需要执行的操作

进入每个screen停止服务

sudo shutdown -h now

断电重启之后需要执行的操作

(统统写道开机自启里了,不需要执行任何操作)

#!/bin/bash -e
screen_name="mongo"
sudo screen -dmS $screen_name
sudo screen -x -S $screen_name -p 0 -X stuff $'cd /home/ubuntu/mongodb/bin\n./mongod --bind_ip=0.0.0.0 --auth --port=27017\n'
exit 0


人生有無數種可能,人生有無限的精彩,人生沒有盡頭。一個人只要足夠的愛自己,尊重自己內心的聲音,就算是真正的活著。