更改 apt

# 将 Unbuntu 系统中 /etc/apt/sources.list 的内容替换为下面的内容(记得备份)

deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

更新 apt

# 更新 apt 源包
apt-get update
# 将所有 源包 中的软件升级
apt-get upgrade

nodejsnpm 更新到 20.X 版本

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -\nsudo apt-get install -y nodejs

# 确认版本
node -v
npm -v

更换 npm

# 设置为阿里云的镜像
npm config set registry https://registry.npmmirror.com
# 查看npm镜像地址
npm config get registry

npm install

自启动

创建 hexo-cl.service 服务

vim /etc/systemd/system/hexo-cl.service

hexo-cl.service 文件内容

[Unit]
Description=hexo clean
After=network.target

[Service]
ExecStart=/zimu-hexo/hexo/tmpHexo/hexo cl
User=root
WorkingDirectory=/zimu-hexo/hexo/zimu

[Install]
WantedBy=multi-user.target

创建 hexo-g.service 服务

vim /etc/systemd/system/hexo-g.service

hexo-g.service 文件内容

[Unit]
Description=hexo generate
After=network.target hexo-cl.service

[Service]
ExecStart=/zimu-hexo/hexo/tmpHexo/hexo g
User=root
WorkingDirectory=/zimu-hexo/hexo/zimu

[Install]
WantedBy=multi-user.target

创建 hexo-a.service 服务

vim /etc/systemd/system/hexo-a.service

hexo-a.service 文件内容

[Unit]
Description=hexo algolia
After=network.target hexo-g.service

[Service]
ExecStart=/zimu-hexo/hexo/tmpHexo/hexo a
Restart=always
User=root
WorkingDirectory=/zimu-hexo/hexo/zimu

[Install]
WantedBy=multi-user.target

创建 hexo.service 服务

vim /etc/systemd/system/hexo.service

hexo-a.service 文件内容

[Unit]
Description=hexo server
After=network.target hexo-a.service

[Service]
ExecStart=/zimu-hexo/hexo/tmpHexo/hexo s
Restart=always
User=root
WorkingDirectory=/zimu-hexo/hexo/zimu

[Install]
WantedBy=multi-user.target

重新加载所有服务,并确认服务成功启动

# 重新加载所有服务的配置文件
systemctl daemon-reload

# 确认服务
# 启动服务
systemctl start hexo
# 查看服务状态
systemctl status hexo

阿里云效在流水线中添加主机组