Intermediate
How to setup staging environments on Hostinger
Quick Answer
Create a staging environment on Hostinger by setting up a subdomain through hPanel, installing your website files via File Manager, and configuring a separate database. This allows you to test changes safely before deploying to your live site.
Prerequisites
- Active Hostinger hosting account
- Live website already deployed
- Basic understanding of file management
- Access to your domain's DNS settings
1
Access Hostinger hPanel and navigate to subdomains
Log into your Hostinger hPanel dashboard and select your hosting account. Navigate to Domains section and click on Subdomains. This is where you'll create a separate environment for your staging site.
Tip
Choose a subdomain name like 'staging' or 'dev' to clearly identify it as a test environment.
2
Create a staging subdomain
Click Create Subdomain and enter your desired subdomain name (e.g.,
staging). Select your main domain from the dropdown menu. Set the document root to a new folder like /public_html/staging and click Create.Tip
The subdomain will be accessible at staging.yourdomain.com once DNS propagates (usually within 24 hours).
3
Set up a separate database for staging
Go to Databases in your hPanel and click MySQL Databases. Create a new database with a name like
staging_db. Create a new database user or assign existing user permissions to this database. Note down the database credentials for later configuration.Tip
Keep staging and production databases separate to avoid accidentally affecting live data during testing.
4
Copy your website files to staging directory
Open File Manager from hPanel and navigate to your main website's
/public_html directory. Select all files and folders, then click Copy. Navigate to your staging folder /public_html/staging and paste the files there.Tip
This process may take several minutes depending on your website size. You can also use FTP clients for faster transfers.
5
Update configuration files for staging
In your staging directory, locate and edit configuration files like
wp-config.php (WordPress) or .env files. Update database connection details to point to your staging database. Change any absolute URLs to use your staging subdomain instead of the live domain.Tip
Make sure to update any hardcoded URLs in your configuration to prevent staging from affecting your live site.
6
Import database to staging environment
Go to phpMyAdmin in hPanel and select your staging database. Click Import tab and upload your live site's database backup file. If you don't have a backup, export it first from your live database using the Export tab.
Tip
After importing, update any URLs in the database that still point to your live domain using phpMyAdmin's search and replace feature.
7
Test and configure staging environment
Visit your staging subdomain in a browser to verify everything works correctly. Test key functionality like forms, user registration, and content management. Configure any necessary redirects or security settings specific to your staging environment.
Tip
Consider adding password protection to your staging site to prevent search engines from indexing it.
8
Set up automated backups and sync process
In hPanel, go to Backups and ensure your staging environment is included in regular backups. Consider setting up a process to periodically sync your live database to staging for testing with current data while being careful not to overwrite staging-specific configurations.
Tip
Document your staging setup process and create a checklist for updating staging when making significant changes to your live site.
Troubleshooting
Staging subdomain shows 404 or doesn't load
Check that DNS has fully propagated (can take up to 24 hours). Verify the document root path is correct in Subdomains settings and ensure files exist in the specified directory.
Database connection errors on staging site
Double-check database credentials in your configuration files. Ensure the database user has proper permissions and the database name matches exactly what you created in
MySQL Databases.Images or assets not loading on staging site
Update absolute URLs in your database and configuration files to use the staging subdomain. Use search and replace in phpMyAdmin to change
yourdomain.com to staging.yourdomain.com throughout the database.File permission errors or unable to upload files
Check file permissions in File Manager. Set folders to
755 and files to 644. If using WordPress, ensure the staging directory has write permissions for plugin/theme updates.Ready to get started with Hostinger?
Put this tutorial into practice. Visit Hostinger and follow the steps above.
Visit Hostinger →