Tutorials

How to Move WordPress from Localhost (XAMPP / LocalWP) to Live Web Server

How to Move WordPress from Localhost to Live Web Server - CpanelFree Guide
Written by Blog

Quick Answer: To move WordPress from localhost (XAMPP/LocalWP) to a live web server: 1) Export your local database via phpMyAdmin (localhost/phpmyadmin), 2) Compress your local wp-content folder and WordPress core files into a ZIP archive, 3) Upload and extract the ZIP file into your live hosting public_html directory, 4) Create a MySQL database and user in cPanel and import your SQL dump, and 5) Replace all http://localhost/site URLs with your live https://yourdomain.com URL.

Step 1: Export Local Database from XAMPP or LocalWP

Open your local web browser and navigate to http://localhost/phpmyadmin (or click Open phpMyAdmin inside LocalWP):

  1. Select your local WordPress database from the left menu.
  2. Click the Export tab at the top.
  3. Select the Quick export method and click Export to download database.sql.

Step 2: Compress and Upload Local Files to cPanel

Navigate to your local WordPress installation directory (e.g. C:\xampp\htdocs\mysite\):

  1. Select all files and folders, right-click, and select Send to > Compressed (zipped) folder (site_files.zip).
  2. Log in to your CpanelFree dashboard and open File Manager.
  3. Navigate to public_html, click Upload, and upload site_files.zip.
  4. Right-click the uploaded ZIP file in cPanel and click Extract.

Step 3: Create Live MySQL Database and Import SQL Dump

  1. In cPanel, open MySQL Databases and create a new database (e.g. cpanelfree_wpdb) and user with ALL PRIVILEGES.
  2. Open phpMyAdmin in cPanel, select your newly created database, and click Import to upload database.sql.

Step 4: Update wp-config.php on Live Server

Edit wp-config.php in cPanel File Manager and enter your live database credentials:

define( 'DB_NAME', 'username_wpdb' );
define( 'DB_USER', 'username_wpuser' );
define( 'DB_PASSWORD', 'YourLiveStrongPassword123!' );
define( 'DB_HOST', 'localhost' );

Step 5: Updating Localhost URLs to Live Domain Name

WordPress stores URLs as serialized PHP objects. Changing them with raw SQL text replacement will corrupt widgets and theme options. Use the free Better Search Replace plugin or WP-CLI:

wp search-replace 'http://localhost/mysite' 'https://yourdomain.com' --all-tables

Troubleshooting Database Table Prefix and Collation Conflicts

Local development stacks like XAMPP or LocalWP frequently default to the latest MySQL 8.0 utf8mb4_0900_ai_ci collation. If your live web hosting environment runs MariaDB 10.5 or MySQL 5.7, attempting to import your local SQL dump will fail with Unknown collation errors. Fix this before importing using a text editor search-and-replace:

# Replace MySQL 8.0 collations with universal UTF8MB4
sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g' database.sql
sed -i 's/utf8mb4_0900_as_cs/utf8mb4_unicode_ci/g' database.sql

Setting Correct File and Directory Permissions on Live Server

Local Windows environments do not preserve POSIX filesystem permissions. Once extracted on Linux cPanel hosting, ensure standard permissions are applied:

  • Directories: 755 (drwxr-xr-x)
  • Files: 644 (-rw-r–r–)
  • wp-config.php: 600 or 640 for strict credential isolation

Step-by-Step Localhost to cPanel Migration Workflow

Migration Stage Action Required on Localhost Action Required on Live Server
1. Database Export Export SQL dump via phpMyAdmin Import SQL dump into cPanel MySQL
2. File Transfer Zip wp-content & core files Extract archive into public_html
3. Configuration None Update DB_NAME, DB_USER, DB_PASSWORD
4. URL Replacement None Run Better Search Replace or WP-CLI

Regenerating .htaccess Rewrite Rules and Permalinks

After migrating files from localhost, your live site may return 404 Not Found errors when clicking blog posts or internal pages. In your WordPress admin dashboard, navigate to Settings > Permalinks and click Save Changes twice. This forces WordPress to regenerate your Apache .htaccess rewrite directives.

Why does the live site redirect back to localhost after uploading?

The siteurl and home rows in the wp_options table still hold http://localhost/mysite. Edit these two rows in phpMyAdmin to your live domain (https://yourdomain.com) to restore access immediately.

Deploy Your Local Project Live on CpanelFree

Publish your localhost designs to the web with CpanelFree. Get free cPanel hosting, AutoSSL, and SSD storage at $0 forever.

Claim Free Web Hosting

Frequently Asked Questions

Why do images show broken links after moving from localhost?

Image URLs inside post content are hardcoded to http://localhost/... in the database. Running Better Search Replace or WP-CLI search-replace updates all image source paths to your live domain name.

Automating Localhost to Live Deployment via Git & CI/CD

Modern WordPress developers frequently automate deployments from local environments to production servers using Git version control and GitHub Actions. By pushing code to a GitHub repository, an automated webhook triggers a deployment runner on your live cPanel server, pulling updated themes and plugins without manual FTP uploads.

Do I need to export all tables from localhost phpMyAdmin?

Yes. Exporting the entire database schema ensures all posts, pages, custom post types, plugin settings, and user accounts are migrated to your live web hosting environment without missing configurations.

Pro Sysadmin Tip: Disabling Debug Mode in Production

In local development, WP_DEBUG is often set to true. On live hosting, ensure define('WP_DEBUG', false); is declared in wp-config.php to avoid leaking database paths and PHP warning notices to public visitors.

By following these structured export, upload, and URL replacement steps, you guarantee that your local WordPress projects transition to live cPanel hosting cleanly without broken layouts or lost media links.

About the author

Blog

DevOps architect and Linux sysadmin specializing in server hardening, OpenLiteSpeed performance optimization, and free cloud hosting infrastructure.

Leave a Comment