Below are the recommended best practices for migrating a PHP site (e.g., www.domain.com) to CloudPanel smoothly and safely: Step 1: Create a PHP Site on CloudPanel
Use your live domain (e.g., www.domain.com) when creating your PHP site. This ensures correct Nginx redirection from non-www to www, or vice versa.
CloudPanel automatically adds a subdomain (www1.domain.com) as a pre-live domain for testing.
Step 2: Configure DNS for Testing
Create an A record for your testing subdomain:
Enable Basic Authentication in CloudPanel to prevent search engines from indexing your test site.
Step 3: Migrate Your Website Content
Files: Copy your website files from the old server to your CloudPanel site directory via FTP or SFTP.
Database: On the old server, export your database using:
Upload dump.sql to CloudPanel and import it:
Update your site's configuration files to reflect the new database credentials and set the base URL to your test subdomain:
Step 4: Testing Your Migrated Site
Thoroughly test your site at:
Verify functionality, performance, and database integrity.
Step 5: Live Switch with Minimal Downtime
On your old server, display a maintenance page to prevent visitor access during migration.
Re-export any updated content (e.g., media files) and database from your old server:
Import this fresh database dump into CloudPanel again:
Step 6: Final Testing Using Host File
Before changing your DNS publicly, test the migrated site locally by modifying your hosts file:
Windows:
Open text editor as Administrator.
Edit file:
Add entry:
Save and test your site in a browser at:
Linux/Mac:
Edit hosts file:
Add entry:
Save changes and test your website at:
Step 7: Update DNS Records (Go Live)
Change your DNS A records for domain.com and www.domain.com to point to your CloudPanel server IP.
Disable Basic Authentication to allow public access.
Remove the temporary hosts file entry created earlier.
This structured approach ensures a seamless, safe, and minimal-downtime migration to CloudPanel.