Moving a WordPress website from a localhost

Step 1
Step01

Export the Local WordPress Database

Moving a WordPress website from a localhost environment to an online server involves several steps. Here’s a detailed guide on how to do it:

  1. Access phpMyAdmin: Open phpMyAdmin from your localhost environment (usually via http://localhost/phpmyadmin).
  2. Select Your Database: In phpMyAdmin, select the database you used for your local WordPress site.
  3. Export the Database:

Click on the “Export” tab.

Choose the “Quick” method and ensure the format is set to “SQL”.

Click “Go” to download the .sql file.

Step02

Upload WordPress Files to the Online Server

  • Access Your Hosting Server via FTP: Use an FTP client (like FileZilla) to connect to your online hosting server.
    • Use the credentials provided by your web host (FTP username, password, host, port).
  • Upload Your WordPress Files:
    • Navigate to your local WordPress directory (htdocs/your-site on MAMP/XAMPP).
    • Select all the files and folders (including wp-content, wp-admin, and wp-includes), and upload them to your hosting server’s root directory (usually /public_html or /www).
Step03

Create a New Database on the Hosting Server

  • Log into your Hosting Control Panel: (e.g., cPanel or Plesk).
  • Create a New Database:
    • Go to the “MySQL Databases” section and create a new database.
    • Create a new MySQL user and assign it to the database with full permissions.
  • Import the Local Database:
    • Open phpMyAdmin on your hosting server.
    • Select the new database you just created.
    • Go to the “Import” tab, click “Choose File,” and upload the .sql file you exported earlier.
    • Click “Go” to import the database.
Step04

Update the wp-config.php File

  • Edit wp-config.php: In your FTP client, locate the wp-config.php file you uploaded.
  • Update Database Credentials:
    • Change the database name, username, and password to match the new details from the online server.
Define
Step05

Update Site URL in the Database

  • Access phpMyAdmin on your hosting server.
  • Navigate to the wp_options table in your new database.
    • Look for the siteurl and home rows.
    • Update both URLs to your live website’s domain (e.g., https://www.yoursite.com)
Step06

Update Permalinks and Fix Broken Links

  • Log in to Your WordPress Dashboard on the live site (it will be the same admin details from the localhost site).
  • Go to Settings → Permalinks:
    • Re-save the permalinks to ensure they are correctly set up on the live server.
  • Check for Broken Links: Ensure all internal links and media (images, etc.) are working correctly. Use a plugin like “Better Search Replace” to fix any broken links that still point to the localhost URLs.
Step07

Test Your Website

  • Open your site in a browser and test all functionality, including forms, media, and plugins.
  • Ensure the website is working as expected.
Tips

Optional: Set Up a Redirect (if necessary)

  • If you had an existing site or different domain name, set up 301 redirects to ensure your old URLs redirect to the new ones.
  • This process should successfully move your WordPress website from localhost to a live server.

No comment

Leave a Reply

Your email address will not be published. Required fields are marked *