升级与降级
升级前请务必备份配置文件。
# 创建带时间戳的备份tar czf /root/ols-backup-$(date +%Y%m%d).tar.gz /usr/local/lsws/conf/这将保存 httpd_config.conf、所有虚拟主机配置、SSL 设置和模块配置。
检查当前版本
Section titled “检查当前版本”/usr/local/lsws/bin/lshttpd -v通过仓库升级
Section titled “通过仓库升级”AlmaLinux / Rocky Linux 9
Section titled “AlmaLinux / Rocky Linux 9”dnf update openlitespeedsystemctl restart lswsUbuntu / Debian
Section titled “Ubuntu / Debian”apt updateapt upgrade openlitespeedsystemctl restart lsws包管理器会保留您现有的配置文件。如果配置文件在本地已被修改,系统可能会提示您选择保留当前版本还是安装包维护者的版本。除非您确定需要新的默认配置,否则请保留当前版本。
通过源码升级
Section titled “通过源码升级”如果您是从源码编译安装的:
cd openlitespeedgit pullbash build.shcd distbash install.sh/usr/local/lsws/bin/lswsctrl restart安装脚本会检测到现有安装并保留配置文件。
在 RPM 系系统上,使用 dnf downgrade:
# 列出可用版本dnf --showduplicates list openlitespeed
# 降级到指定版本dnf downgrade openlitespeed-1.7.19systemctl restart lsws在 Debian 系系统上:
# 列出可用版本apt-cache showpkg openlitespeed
# 安装指定版本apt install openlitespeed=1.7.19-1systemctl restart lsws切换到目标标签并重新编译:
cd openlitespeedgit checkout v1.7.19bash build.shcd distbash install.sh/usr/local/lsws/bin/lswsctrl restart如果升级导致问题,恢复配置备份:
# 停止服务器systemctl stop lsws
# 恢复配置tar xzf /root/ols-backup-YYYYMMDD.tar.gz -C /
# 重新启动systemctl start lsws# 检查版本/usr/local/lsws/bin/lshttpd -v
# 检查服务器状态/usr/local/lsws/bin/lswsctrl status
# 查看错误日志中的启动问题tail -50 /usr/local/lsws/logs/error.log