Objective
This guide explains how to back up and update the CyberPanel vHosts configuration using a script, replace the old configuration, and restart the necessary services to apply the changes.
Step-by-Step Instructions
1. Back Up the Existing vHosts folder
cp -prf /usr/local/lsws/conf/vhosts /usr/local/lsws/conf/vhosts_bk
Moves the entire `vhosts` directory to `vhosts_bk`.
This ensures that the original virtual host configurations are saved in case a rollback is needed.
2. Download and Execute the vHosts Update Script
wget -qO- https://panelwebhosting.org/script/cyberpanel/cp-vhost.sh | bash
Fetches the script from the specified URL and executes it directly using `bash`.
The script likely generates or updates the vHosts configurations for all domains on the server.
3. Restart the Web Server
systemctl restart lshttpd.service || systemctl restart lsws
Attempts to restart `lshttpd.service` first.
If that fails, it falls back to restarting `lsws`.
Restarting the web server applies the new vHosts configurations.
Verification
Check if the website is loading properly.
If there are issues, restore the original vHosts directory:
mv /usr/local/lsws/conf/vhosts_bk /usr/local/lsws/conf/vhosts systemctl restart lshttpd.service || systemctl restart lsws
Conclusion
This process ensures that your CyberPanel vHosts configuration is updated safely while keeping a backup for recovery if needed.