{"id":1667,"date":"2026-09-03T17:20:28","date_gmt":"2026-09-03T11:50:28","guid":{"rendered":"https:\/\/cpanelfree.com\/blog\/how-to-move-wordpress-from-localhost-to-live-server\/"},"modified":"2026-09-03T17:23:56","modified_gmt":"2026-09-03T11:53:56","slug":"how-to-move-wordpress-from-localhost-to-live-server","status":"publish","type":"post","link":"https:\/\/cpanelfree.com\/blog\/how-to-move-wordpress-from-localhost-to-live-server\/","title":{"rendered":"How to Move WordPress from Localhost (XAMPP \/ LocalWP) to Live Web Server"},"content":{"rendered":"<div style=\"background-color: #f8fafc;border-left: 4px solid #10b981;padding: 20px;border-radius: 6px;margin-bottom: 25px\">\n<p style=\"margin: 0;font-size: 16px;color: #1e293b\">\n        <strong>Quick Answer:<\/strong> To move WordPress from localhost (XAMPP\/LocalWP) to a live web server: <strong>1)<\/strong> Export your local database via phpMyAdmin (<code>localhost\/phpmyadmin<\/code>), <strong>2)<\/strong> Compress your local <code>wp-content<\/code> folder and WordPress core files into a ZIP archive, <strong>3)<\/strong> Upload and extract the ZIP file into your live hosting <code>public_html<\/code> directory, <strong>4)<\/strong> Create a MySQL database and user in cPanel and import your SQL dump, and <strong>5)<\/strong> Replace all <code>http:\/\/localhost\/site<\/code> URLs with your live <code>https:\/\/yourdomain.com<\/code> URL.\n    <\/p>\n<\/div>\n<h2>Step 1: Export Local Database from XAMPP or LocalWP<\/h2>\n<p>Open your local web browser and navigate to <code>http:\/\/localhost\/phpmyadmin<\/code> (or click <em>Open phpMyAdmin<\/em> inside LocalWP):<\/p>\n<ol style=\"padding-left: 20px;line-height: 1.8\">\n<li>Select your local WordPress database from the left menu.<\/li>\n<li>Click the <strong>Export<\/strong> tab at the top.<\/li>\n<li>Select the <strong>Quick<\/strong> export method and click <strong>Export<\/strong> to download <code>database.sql<\/code>.<\/li>\n<\/ol>\n<h2>Step 2: Compress and Upload Local Files to cPanel<\/h2>\n<p>Navigate to your local WordPress installation directory (e.g. <code>C:\\xampp\\htdocs\\mysite\\<\/code>):<\/p>\n<ol style=\"padding-left: 20px;line-height: 1.8\">\n<li>Select all files and folders, right-click, and select <strong>Send to &gt; Compressed (zipped) folder<\/strong> (<code>site_files.zip<\/code>).<\/li>\n<li>Log in to your <a href=\"https:\/\/cpanelfree.com\/\">CpanelFree<\/a> dashboard and open <strong>File Manager<\/strong>.<\/li>\n<li>Navigate to <code>public_html<\/code>, click <strong>Upload<\/strong>, and upload <code>site_files.zip<\/code>.<\/li>\n<li>Right-click the uploaded ZIP file in cPanel and click <strong>Extract<\/strong>.<\/li>\n<\/ol>\n<h2>Step 3: Create Live MySQL Database and Import SQL Dump<\/h2>\n<ol style=\"padding-left: 20px;line-height: 1.8\">\n<li>In cPanel, open <strong>MySQL Databases<\/strong> and create a new database (e.g. <code>cpanelfree_wpdb<\/code>) and user with <strong>ALL PRIVILEGES<\/strong>.<\/li>\n<li>Open <strong>phpMyAdmin<\/strong> in cPanel, select your newly created database, and click <strong>Import<\/strong> to upload <code>database.sql<\/code>.<\/li>\n<\/ol>\n<h2>Step 4: Update wp-config.php on Live Server<\/h2>\n<p>Edit <code>wp-config.php<\/code> in cPanel File Manager and enter your live database credentials:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\">define( 'DB_NAME', 'username_wpdb' );\ndefine( 'DB_USER', 'username_wpuser' );\ndefine( 'DB_PASSWORD', 'YourLiveStrongPassword123!' );\ndefine( 'DB_HOST', 'localhost' );<\/pre>\n<h2>Step 5: Updating Localhost URLs to Live Domain Name<\/h2>\n<p>WordPress stores URLs as serialized PHP objects. Changing them with raw SQL text replacement will corrupt widgets and theme options. Use the free <strong>Better Search Replace<\/strong> plugin or <strong>WP-CLI<\/strong>:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\">wp search-replace 'http:\/\/localhost\/mysite' 'https:\/\/yourdomain.com' --all-tables<\/pre>\n<div style=\"background-color: #f8fafc;border: 1px solid #e2e8f0;border-left: 4px solid #0ea5e9;padding: 20px;border-radius: 8px;margin: 30px 0\">\n<h3 style=\"margin-top: 0;color: #0f172a;font-size: 18px;display: flex;align-items: center\">\n        <span style=\"margin-right: 8px\">\ud83d\udd17<\/span> Recommended Related Technical Guides:<br \/>\n    <\/h3>\n<ul style=\"margin: 10px 0 0 0;padding-left: 20px;line-height: 1.8\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/best-free-wordpress-migration-plugins-2026\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">Top 5 Free WordPress Migration Plugins<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-migrate-wordpress-to-new-host-manually\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">How to Migrate WordPress Manually (Zero Plugins)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-create-mysql-database-user-cpanel\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">How to Create MySQL Database &amp; User with Full Privileges<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">Explore $0 Free cPanel Web Hosting Plans<\/a><\/li>\n<\/ul>\n<\/div>\n<h2>Troubleshooting Database Table Prefix and Collation Conflicts<\/h2>\n<p>Local development stacks like XAMPP or LocalWP frequently default to the latest MySQL 8.0 <code>utf8mb4_0900_ai_ci<\/code> 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 <code>Unknown collation<\/code> errors. Fix this before importing using a text editor search-and-replace:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\"># Replace MySQL 8.0 collations with universal UTF8MB4\nsed -i 's\/utf8mb4_0900_ai_ci\/utf8mb4_unicode_ci\/g' database.sql\nsed -i 's\/utf8mb4_0900_as_cs\/utf8mb4_unicode_ci\/g' database.sql<\/pre>\n<h2>Setting Correct File and Directory Permissions on Live Server<\/h2>\n<p>Local Windows environments do not preserve POSIX filesystem permissions. Once extracted on Linux cPanel hosting, ensure standard permissions are applied:<\/p>\n<ul style=\"padding-left: 20px;line-height: 1.8\">\n<li>Directories: <code>755<\/code> (drwxr-xr-x)<\/li>\n<li>Files: <code>644<\/code> (-rw-r&#8211;r&#8211;)<\/li>\n<li><code>wp-config.php<\/code>: <code>600<\/code> or <code>640<\/code> for strict credential isolation<\/li>\n<\/ul>\n<h2>Step-by-Step Localhost to cPanel Migration Workflow<\/h2>\n<table style=\"width: 100%;border-collapse: collapse;margin: 20px 0;font-size: 14px\">\n<thead>\n<tr style=\"background-color: #0f172a;color: #ffffff\">\n<th style=\"padding: 10px;border: 1px solid #334155\">Migration Stage<\/th>\n<th style=\"padding: 10px;border: 1px solid #334155\">Action Required on Localhost<\/th>\n<th style=\"padding: 10px;border: 1px solid #334155\">Action Required on Live Server<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background-color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #cbd5e1;font-weight: bold\">1. Database Export<\/td>\n<td style=\"padding: 10px;border: 1px solid #cbd5e1\">Export SQL dump via phpMyAdmin<\/td>\n<td style=\"padding: 10px;border: 1px solid #cbd5e1\">Import SQL dump into cPanel MySQL<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px;border: 1px solid #cbd5e1;font-weight: bold\">2. File Transfer<\/td>\n<td style=\"padding: 10px;border: 1px solid #cbd5e1\">Zip <code>wp-content<\/code> &amp; core files<\/td>\n<td style=\"padding: 10px;border: 1px solid #cbd5e1\">Extract archive into <code>public_html<\/code><\/td>\n<\/tr>\n<tr style=\"background-color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #cbd5e1;font-weight: bold\">3. Configuration<\/td>\n<td style=\"padding: 10px;border: 1px solid #cbd5e1\">None<\/td>\n<td style=\"padding: 10px;border: 1px solid #cbd5e1\">Update DB_NAME, DB_USER, DB_PASSWORD<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px;border: 1px solid #cbd5e1;font-weight: bold\">4. URL Replacement<\/td>\n<td style=\"padding: 10px;border: 1px solid #cbd5e1\">None<\/td>\n<td style=\"padding: 10px;border: 1px solid #cbd5e1\">Run Better Search Replace or WP-CLI<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Regenerating .htaccess Rewrite Rules and Permalinks<\/h2>\n<p>After migrating files from localhost, your live site may return <code>404 Not Found<\/code> errors when clicking blog posts or internal pages. In your WordPress admin dashboard, navigate to <strong>Settings &gt; Permalinks<\/strong> and click <strong>Save Changes<\/strong> twice. This forces WordPress to regenerate your Apache <code>.htaccess<\/code> rewrite directives.<\/p>\n<div style=\"border-bottom: 1px solid #e2e8f0;padding: 12px 0\">\n<h4 style=\"margin: 0 0 8px 0;color: #1e293b\">Why does the live site redirect back to localhost after uploading?<\/h4>\n<p style=\"margin: 0;color: #475569;font-size: 14px\">The <code>siteurl<\/code> and <code>home<\/code> rows in the <code>wp_options<\/code> table still hold <code>http:\/\/localhost\/mysite<\/code>. Edit these two rows in phpMyAdmin to your live domain (<code>https:\/\/yourdomain.com<\/code>) to restore access immediately.<\/p>\n<\/div>\n<div style=\"background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);border: 1px solid #334155;border-radius: 12px;padding: 25px;margin: 30px 0;text-align: center\">\n<h3 style=\"color: #38bdf8;margin-top: 0;font-size: 20px\">Deploy Your Local Project Live on CpanelFree<\/h3>\n<p style=\"color: #94a3b8;font-size: 14px;line-height: 1.6;max-width: 600px;margin: 0 auto 15px\">\n        Publish your localhost designs to the web with <strong>CpanelFree<\/strong>. Get free cPanel hosting, AutoSSL, and SSD storage at $0 forever.\n    <\/p>\n<p>    <a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"display: inline-block;background-color: #10b981;color: #ffffff;padding: 10px 22px;border-radius: 6px;text-decoration: none;font-weight: bold;font-size: 14px\">Claim Free Web Hosting<\/a>\n<\/div>\n<h2>Frequently Asked Questions<\/h2>\n<div style=\"border-bottom: 1px solid #e2e8f0;padding: 12px 0\">\n<h4 style=\"margin: 0 0 8px 0;color: #1e293b\">Why do images show broken links after moving from localhost?<\/h4>\n<p style=\"margin: 0;color: #475569;font-size: 14px\">Image URLs inside post content are hardcoded to <code>http:\/\/localhost\/...<\/code> in the database. Running Better Search Replace or WP-CLI search-replace updates all image source paths to your live domain name.<\/p>\n<\/div>\n<h2>Automating Localhost to Live Deployment via Git &amp; CI\/CD<\/h2>\n<p>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.<\/p>\n<div style=\"border-bottom: 1px solid #e2e8f0;padding: 12px 0\">\n<h4 style=\"margin: 0 0 8px 0;color: #1e293b\">Do I need to export all tables from localhost phpMyAdmin?<\/h4>\n<p style=\"margin: 0;color: #475569;font-size: 14px\">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.<\/p>\n<\/div>\n<div style=\"background-color: #f1f5f9;padding: 15px;border-radius: 8px;margin: 20px 0\">\n<h4 style=\"margin-top: 0;color: #1e293b\">Pro Sysadmin Tip: Disabling Debug Mode in Production<\/h4>\n<p style=\"margin: 0;color: #475569;font-size: 14px\">In local development, <code>WP_DEBUG<\/code> is often set to true. On live hosting, ensure <code>define('WP_DEBUG', false);<\/code> is declared in <code>wp-config.php<\/code> to avoid leaking database paths and PHP warning notices to public visitors.<\/p>\n<\/div>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1666,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[],"class_list":["post-1667","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1667","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/comments?post=1667"}],"version-history":[{"count":4,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1667\/revisions"}],"predecessor-version":[{"id":1714,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1667\/revisions\/1714"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media\/1666"}],"wp:attachment":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media?parent=1667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/categories?post=1667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/tags?post=1667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}