This is an advanced plugin for the Hestia Control Panel that adds a powerful "one-click" site staging capability. It is built upon the hestiacp-pluginable framework.
This tool allows users to create a complete, independent copy of a live website—including all files and a full database clone—on a new subdomain. Its key feature is the ability to automatically update the configuration file (wp-config.php or .env) of the new staging site with the correct staging database credentials, making the cloned site work out-of-the-box.
Warning
This plugin performs major, automated operations on your server, including creating subdomains, copying large amounts of files, and manipulating databases. It is NOT recommended for beginners and should be tested on a non-production server first.
Always ensure you have recent, working backups before using this tool. You assume all risk for its use.
- One-Click Staging: Adds a "Create Staging" button directly to the actions menu for each web domain.
- Automatic Configuration Updates: Intelligently updates database credentials in the staging site's configuration file for:
- WordPress (
wp-config.php) - .env-based applications (Laravel, etc.)
- WordPress (
- Complete File Cloning: Uses
rsyncto efficiently create an exact copy of the entirepublic_htmldirectory. - Full Database Duplication: Dumps the selected source database, creates a new database with a unique user/password, and imports the data.
- Automatic URL Replacement: Performs a search-and-replace on the SQL dump to automatically update the site URL from the production domain to the new staging domain.
- Background Processing: The entire staging process runs as a background task to prevent web server timeouts on large sites.
- UI Notifications: The user receives a notification in the Hestia panel when the staging process starts and when it completes successfully.
The staging process is fully automated by a backend script:
- The user clicks the "Create Staging" button for a domain and is taken to a configuration page.
- They choose a prefix for the staging subdomain, select the database to clone, and select their Application Type (e.g., WordPress, .env, or Manual).
- Upon submission, a background shell script is launched with
rootprivileges. This script performs the following steps: a. Creates the new staging web domain (e.g.,staging.example.com). b. Creates a new, empty database with a secure, randomly generated password. c. Copies all files from the source to the staging directory. d. Dumps the source database and replaces all instances of the production domain with the new staging domain. e. Imports the modified database into the new staging database. f. Updates Configuration: Based on the user's selection, it modifies thewp-config.phpor.envfile in the staging directory, replacing the production database credentials with the new staging ones. g. Sends a final success notification to the user in the Hestia UI.
- Hestia Control Panel v1.9.X or greater.
- hestiacp-pluginable must be installed first.
- Ubuntu or Debian Linux OS.
- The
rsyncutility (the installer will attempt to add this). rootorsudoaccess to the server.
Please back up your server before proceeding!
- SSH into your HestiaCP server.
- Navigate to the Hestia plugins directory:
cd /usr/local/hestia/plugins - Clone this repository:
sudo git clone https://github.com/iniznet/hcpp-sitestager.git sitestager
- Set Permissions: This is a critical step. Ensure all scripts are executable.
sudo chmod +x sitestager/install sitestager/uninstall sitestager/pages/staging_script.sh
- Run the Installer: This will ensure the
rsyncdependency is met.sudo /usr/local/hestia/plugins/sitestager/install
- Log in to HestiaCP. The new "Create Staging" option will be available in the Web tab.
- WordPress & Serialized Data: The current database search-and-replace method using
sedis effective for simple sites but may break WordPress sites or other applications that store URLs in serialized PHP arrays. For 100% reliable WordPress staging, a tool likewp-cli search-replaceis recommended. - Configuration File Parsing: The automatic configuration update relies on
sedand common patterns (e.g.,define('DB_NAME', ...);orDB_DATABASE=...). If your configuration file is formatted in a non-standard way, the update might fail. In this case, you would need to update the credentials manually. - One-Way Staging: This plugin only handles creating a staging site from production. It does not have a "push to live" feature to move changes from staging back to production.
- Run the uninstallation script:
sudo /usr/local/hestia/plugins/sitestager/uninstall
- Remove the plugin directory:
sudo rm -rf /usr/local/hestia/plugins/sitestager