Best Practices for Migrating a PHP Site to CloudPanel
2025-03-22 15:37:17
#2
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: CODE_BLOCK_0
  • 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:
    CODE_BLOCK_1
  • Upload dump.sql to CloudPanel and import it:
    CODE_BLOCK_2
  • Update your site's configuration files to reflect the new database credentials and set the base URL to your test subdomain:
    CODE_BLOCK_3

🔸 Step 4: Testing Your Migrated Site



  • Thoroughly test your site at: CODE_BLOCK_4
  • 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:
    CODE_BLOCK_5
  • Import this fresh database dump into CloudPanel again:
    CODE_BLOCK_6


🔸 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:CODE_BLOCK_7
  • Add entry:CODE_BLOCK_8
  • Save and test your site in a browser at:CODE_BLOCK_9

Linux/Mac:
  • Edit hosts file:CODE_BLOCK_10
  • Add entry:CODE_BLOCK_11
  • Save changes and test your website at:CODE_BLOCK_12

🔸 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.
Yazdığımız şeyler bizi temsil eder, Efendilik iyidir.
Please Login or Register.
Currently 1 people reading this topic. (1 guest(s))