FetchLinux配置步骤(Linux环境)
在配置FetchLinux前,需确保系统已更新并安装依赖工具。根据Linux发行版选择对应命令:
sudo apt update && sudo apt install -y git wget curl openssh-serversudo yum update && sudo yum install -y git wget curl openssh-server从GitHub官方仓库获取FetchLinux源码,建议安装到/opt目录(系统级软件常规路径):
git clone https://github.com/fetchlinux/fetchlinux.git /opt/fetchlinux
执行后,/opt/fetchlinux目录将包含FetchLinux的所有源码和配置模板。
进入FetchLinux目录,复制默认配置模板(fetchlinux.conf.example)为自定义配置文件(fetchlinux.conf):
cd /opt/fetchlinux && sudo cp fetchlinux.conf.example fetchlinux.conf
模板文件包含默认参数,需根据实际需求修改。
使用文本编辑器(如nano或vi)打开fetchlinux.conf,调整以下关键参数:
# 仓库URL(用于同步镜像的源地址,需替换为实际镜像站点)
REPOSITORY_URL="http://your-mirror-url/fetchlinux"
# 镜像名称(标识当前配置的镜像,如"Ubuntu-Mirror")
MIRROR_NAME="YourMirrorName"
# 更新频率(可选:daily/weekly/monthly,根据需求选择)
UPDATE_FREQUENCY="daily"
# 镜像存储路径(可选,默认存储到仓库目录下的镜像子目录)
MIRROR_PATH="/var/www/html/fetchlinux"
修改完成后保存并退出编辑器(nano中按Ctrl+O保存、Ctrl+X退出)。
为保障系统安全,FetchLinux需以专用用户身份运行,避免使用root权限:
sudo groupadd fetchlinuxsudo useradd -r -g fetchlinux fetchlinux(-r表示系统用户,-g指定所属组)sudo chown -R fetchlinux:fetchlinux /opt/fetchlinux通过systemd管理服务,设置FetchLinux开机自动启动:
sudo systemctl enable fetchlinux
执行以下命令启动FetchLinux服务:
sudo systemctl start fetchlinux
检查服务是否运行正常(显示active (running)即为成功):
sudo systemctl status fetchlinux
若需停止服务,可使用sudo systemctl stop fetchlinux;重启服务则用sudo systemctl restart fetchlinux。
若需定期自动更新镜像,确保FetchLinux服务已设置为开机自启(步骤5.1)。如需手动触发更新,可执行:
sudo fetchlinux --update
此命令将强制FetchLinux立即同步镜像,无需等待定时任务。
REPOSITORY_URL需替换为有效的镜像源地址,否则无法同步镜像;/etc/systemd/system/fetchlinux.service文件(部分系统可能位于/lib/systemd/system/);journalctl -u fetchlinux -f)以排查问题,日志路径可通过systemctl status fetchlinux查看。