一、设置ll
vim ~/.bashrc
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
if [ -f "$HOME/.cargo/env" ]; then
. "$HOME/.cargo/env"
fi
source ~/.bashrc
二、更改端口
1. 编辑配置
vim /etc/ssh/sshd_config
2. 设置参数
Port 8022
PermitRootLogin yes
3. 重启服务
systemctl restart ssh
4. 设置root密码
passwd root
passwd123
三、修改数据源(清华大学)
cp /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
apt-get update && apt-get upgrade -y
四、配置固定IP
nmcli -p connection show
nmcli con mod "Wired connection 1" ipv4.addresses 192.168.1.100/24 ipv4.method manual
nmcli con mod "Wired connection 1" ipv4.gateway 192.168.1.1
nmcli con mod "Wired connection 1" ipv4.dns "223.5.5.5,114.114.114.114,8.8.8.8"
nmcli con up "Wired connection 1"
hostname -I
五、自动更新外网ip
安装软件
apt-get install python3-pip python3-venv
1、阿里云
cd /usr/local/
mkdir aliyun_update_dns
cd aliyun_update_dns/
python3 -m venv aliyun
source aliyun/bin/activate
pip install aliyun-python-sdk-core
pip install aliyun-python-sdk-alidns
pip install requests
python -c "import requests; print(requests.__version__)"
vim update_dns.py
python update_dns.py
2、cloudflare
cd /usr/local/
mkdir cloudflare_update_dns
cd cloudflare_update_dns/
python3 -m venv cloudflare
source cloudflare/bin/activate
pip install requests cloudflare
python cloudflare-ddns.py
定时器
crontab -e
# */5 * * * * /usr/local/aliyun_update_dns/myenv/bin/python /usr/local/aliyun_update_dns/update_dns.py >> /usr/local/aliyun_update_dns/update_dns.log 2>&1
*/5 * * * * /usr/local/cloudflare_update_dns/cloudflare/bin/python /usr/local/cloudflare_update_dns/cloudflare-ddns.py
六、挂在硬盘
1. 临时挂载
apt install ntfs-3g samba samba-common-bin
mkdir /mnt/ntfs
mount -t ntfs-3g /dev/sda1 /mnt/ntfs
2. 获取磁盘信息
blkid
vim /etc/fstab
UUID=50CE4302CE42E038 /mnt/ntfs ntfs-3g defaults,nofail 0 0
3. 设置权限,重启服务
chmod -R 777 /mnt
systemctl restart samba
七、安装apparmor
apt install apparmor apparmor-utils
vim /boot/firmware/cmdline.txt
末尾添加
apparmor=1 security=apparmor systemd.unified_cgroup_hierarchy=false
八、安装JAVA
cd /usr/local/
wget https://download.oracle.com/java/17/archive/jdk-17.0.12_linux-aarch64_bin.tar.gz
tar -zxvf jdk-17.0.12_linux-aarch64_bin.tar.gz
vim /etc/profile
export JAVA_HOME=/usr/local/jdk-17.0.12
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
java -version
九、安装ngixn
apt-get install nginx
vim /etc/nginx/nginx.conf
十、安装redis
1. 安装
apt-get install redis-server
2. 修改密码
vim /etc/redis/redis.conf
注释bind 127.0.0.1 -::1
requirepass passwd123
3. 重启服务
systemctl restart redis
systemctl enable redis
十一、安装postgresql
1. 安装
apt install postgresql postgresql-client
2. 修改密码
sudo -u postgres psql
ALTER USER postgres PASSWORD 'passwd123';
\q
3. 更改postgresql.conf权限
vim /etc/postgresql/15/main/postgresql.conf
listen_addresses = '*'
4. 更改pg_hba.conf权限
vim /etc/postgresql/15/main/pg_hba.conf
host all all 0.0.0.0/0 md5
5. 重启服务
systemctl restart postgresql
apt-get remove --purge postgresql-15
apt-get autoremove
apt-get update
apt-get install postgresql-15
十二、安装home-assistant
1. 停用ModemManager
systemctl stop ModemManager
systemctl disable ModemManager
2. 安装依赖
apt install apparmor bluez cifs-utils curl dbus jq libglib2.0-bin lsb-release network-manager nfs-common systemd-journal-remote systemd-resolved udisks2 wget -y
3. 安装docker
curl -fsSL https://get.docker.com | sh
4. 修改docker源
vim /etc/docker/daemon.json
{
"log-driver": "journald",
"storage-driver": "overlay2",
"ip6tables": true,
"experimental": true,
"log-opts": {
"tag": "{{.Name}}"
},
"registry-mirrors": [
"https://docker.1panel.live",
"https://hub.rat.dev/",
"https://docker.chenby.cn",
"https://docker.m.daocloud.io"
]
}
5. 安装代理(必须重启)
wget https://github.com/home-assistant/os-agent/releases/download/1.6.0/os-agent_1.6.0_linux_aarch64.deb
dpkg -i os-agent_1.6.0_linux_aarch64.deb
6. 安装homeassistant-supervised
wget -O homeassistant-supervised.deb https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
apt install ./homeassistant-supervised.deb
7. 安装HACS
wget -O - https://hacs.vip/get | bash -
8. home assistant 网关配置
nmcli -p connection show
nmcli con mod "Supervisor eth0" ipv4.addresses 192.168.1.100/24 ipv4.method manual
nmcli con mod "Supervisor eth0" ipv4.gateway 192.168.1.1
nmcli con mod "Supervisor eth0" ipv4.dns "223.5.5.5,114.114.114.114,8.8.8.8"
nmcli con up "Supervisor eth0"
十三、安装immich
1. 安装postgresql插件
pgvecto.rs插件,用于向量搜索,支持 AI 驱动的照片搜索功能
2. 安装依赖
apt-get install libjemalloc-dev
3. 修改配置
vim /boot/firmware/config.txt
kernel=kernel8.img
4. 下载依赖
wget https://github.com/tensorchord/pgvecto.rs/releases/download/v0.3.0/vectors-pg15_aarch64-unknown-linux-gnu_0.3.0.zip
5. 解压安装
unzip vectors-pg15_aarch64-unknown-linux-gnu_0.3.0.zip -d vectors
cp vectors/vectors.so $(pg_config --pkglibdir)/
cp vectors/vectors--* $(pg_config --sharedir)/extension/
cp vectors/vectors.control $(pg_config --sharedir)/extension/
6. 编辑配置文件
vim /etc/postgresql/15/main/postgresql.conf
shared_preload_libraries = 'vectors.so'
search_path = '"$user", public, vectors'
7. 重启服务
systemctl restart postgresql
8. 验证
DROP EXTENSION IF EXISTS vectors;
CREATE EXTENSION vectors;
pg_trgm 插件,用于模糊文本搜索
apt install postgresql-contrib
9. 验证,进入immich
库
CREATE EXTENSION IF NOT EXISTS vectors;
CREATE EXTENSION IF NOT EXISTS pg_trgm;
2、安装immich
cd /usr/local
mkdir immich-app
cd immich-app
1. 获取 docker-compose.yml 文件
wget -O docker-compose.yml https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
2. 获取 .env 文件
wget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env
3. (可选)获取 hwaccel.transcoding.yml 文件
wget -O hwaccel.transcoding.yml https://github.com/immich-app/immich/releases/latest/download/hwaccel.transcoding.yml
4. (可选)获取 hwaccel.ml.yml 文件
wget -O hwaccel.ml.yml https://github.com/immich-app/immich/releases/latest/download/hwaccel.ml.yml
5. 启动
docker compose up -d
6. 更新
docker compose pull && docker compose up -d
十四、安装dify
cd /usr/local/
git clone https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env
启动
docker compose up -d
十五、安装npm
# 下载并安装nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash
# 代替重新启动外壳
\. "$HOME/.nvm/nvm.sh"
# 下载并安装Node.js
nvm install 22
# 对Node.js版本进行验证
node -v # 应该打印 "v22.14.0".
nvm current # 应该打印 "v22.14.0".
# 验证npm版本
npm -v # 应该打印 "10.9.2".