Web Design & Development

Locally Host a WordPress Site | XAMPP & Plugin Method



Intro

With XAMPP and the All-in-One WP Migration plugin, you can easily restore a full backup of your WordPress site, allowing you to run a private local copy for testing, development, or data recovery. I recently did this as a way to grab some information from some old posts I permanently deleted but still existed in previous backups I had archived. I found this to be the easiest and fastest method for getting a local copy of my site up and running. This is not a guide for hosting a private copy and it being public facing for users, this is just for testing and data recovery purposes, private use only.

Information Gathering

While you may not need to do any of this section when using XAMPP and the plugin All-in-One WP Migration it would be a good idea to gather it just in-case you do run into some compatibility issues, things that might not be running as expected like on the live site.

Before setting up XAMPP for local WordPress development, it’s essential to gather key information from your live WordPress site. This ensures that your local setup matches your live environment, making the migration and restoration process smoother. Here’s what you need to collect before you begin:

1. Live Database Information

To ensure that your local WordPress site connects to the database correctly, gather the following database-related details:

  • Database Name:
    • Go to your live WordPress site’s hosting control panel (e.g., cPanel, Plesk) and access phpMyAdmin.
    • In phpMyAdmin, find the database used by your WordPress site (usually listed on the left-hand panel).
    • Take note of the Database Name (e.g., wp_live_database).
  • Database Prefix:
    • In your WordPress wp-config.php file (located in the root of your site), find the following line: $table_prefix = 'wp_';
    • The prefix is usually wp_, but it could be something else if customized. This prefix is used for your WordPress tables, such as wp_posts, wp_users, etc.

2. PHP Version

Ensure your local XAMPP environment runs the same PHP version as your live site to avoid compatibility issues.

  • Check PHP Version on Live Site:
    • You can check your PHP version from within the WordPress Dashboard by going to Tools > Site Health.
    • Alternatively, you can create a simple PHP file called phpinfo.php and place it in your live site’s root directory with the following code: <?php phpinfo(); ?>
    • Access the file through a browser (http://yourdomain.com/phpinfo.php) to view detailed PHP information, including the version.
  • Check PHP Version in phpMyAdmin:
    • In phpMyAdmin, you can also see the PHP version displayed in the top-right corner of the page.

3. MySQL Version

It’s also important to know the MySQL version used by your live site, as certain versions may have different behaviors or require compatibility adjustments.

  • Check MySQL Version on Live Site:
    • In phpMyAdmin, click on the Server Information link at the top of the page.
    • The MySQL version will be displayed in the list of server information, typically next to the PHP version.

4. WordPress Version

Ensure that your local WordPress installation matches the version of your live site.

  • Check WordPress Version on Live Site:
    • In the WordPress Dashboard, go to Updates (located under Dashboard in the left sidebar).
    • The version number will be listed on this page, or you can check the footer of your WordPress dashboard, where the version number is often displayed.

5. Additional Configuration Information

For a smoother setup, gather these additional details:

  • Permalinks Structure:
    • Go to Settings > Permalinks in your live WordPress site.
    • Note the permalink structure you are using (e.g., Post Name, Day and Name, etc.).
  • Active Themes and Plugins:
    • Make a list of your active themes and plugins. These can be installed and configured similarly on your local site to ensure consistency.

6. Server-Specific Configuration (Optional)

If your live site is hosted with custom server configurations (e.g., NGINX, custom caching, or security settings), consider documenting these so you can mirror them locally if needed. For a typical WordPress site, however, this may not be necessary.

7. Other Information

  • WordPress Security Keys:
    • The security keys in your wp-config.php file provide encryption for passwords and other sensitive data.
    • Ensure that you copy these values from your live wp-config.php to the local one if you plan to migrate or clone the site.

Summary Checklist

Before you install XAMPP, gather these details from your live WordPress site:

  • Database Name
  • Database Prefix
  • PHP Version
  • MySQL Version
  • WordPress Version
  • Permalink Structure
  • Active Themes and Plugins
  • Security Keys (from wp-config.php)

With this information in hand, you can move on to setting up XAMPP, installing WordPress, and ensuring your local environment mirrors your live site for an efficient migration or testing process.

Prerequisites | Backups

Manual Backup of Your Site with the Plugin All-in-One WP Migration

The All-in-One WP Migration plugin allows you to create a complete backup of your WordPress site, including files and the database, in just a few steps. Follow this guide to manually back up your site.

Install and Activate the Plugin

  • Log into your WordPress dashboard.
  • Go to Plugins > Add New.
  • Search for All-in-One WP Migration.
  • Click Install Now, then Activate the plugin.

Open the Export Tool

  • In the WordPress dashboard, navigate to All-in-One WP Migration > Export.
  • Click Export To, then select File.

Generate and Download the Backup File

  • The plugin will process your site’s data into a single backup file.
  • Once complete, click the Download button to save the backup to your computer.

Store the Backup Securely

  • Keep the backup file in a secure location, such as cloud storage or an external hard drive.
  • Ensure it is accessible for future restoration if needed.

By following these steps, you will have a complete backup of your WordPress site, making it easy to restore or migrate when necessary.

Installation of XAMPP

Recommend Using a Virtual Machine

For this part I used Hyper-V and installed a Windows virtual machine using an evaluation copy of the Windows 11 Enterprise Evaluation version which typically offers a 90-day trial period. This means from the date of installation, the system will function fully for 90 days before requiring activation or conversion to a full version. The evaluation period can be extended by using the rearm command, which resets the activation clock. However, this can only be done three times, providing a total of 360 days of evaluation time. After this period, the system will enter a reduced functionality mode, limiting access to certain features.

To extend the evaluation period, open an elevated Command Prompt (run as administrator) and execute:

BAT (Batchfile)
slmgr.vbs -rearm

Note: If you gathered the information in the steps above in the beginning it would be best duplicate those names and structure in the following steps below for best compatibility.

XAMPP is a free and open-source software that provides a local server environment for WordPress development. For better security and system stability, it is recommended to install XAMPP on a Virtual Machine (VM) instead of directly on your main OS. You can use Oracle VM VirtualBox, VMware Workstation Player, or Microsoft Hyper-V for this setup.

Here’s how to install XAMPP, configure a local WordPress website, and run it from your Virtual Machine.

Install a Virtual Machine (VM)

You have three options for setting up a VM:

  • Hyper-V (Windows)
  • Oracle VM VirtualBox
  • VMware Workstation Player
Enable Hyper-V (Windows)
  1. Open Control Panel > Programs > Turn Windows features on or off.
  2. Check Hyper-V and click OK.
  3. Restart your computer when prompted.
  4. Open Hyper-V Manager from the Start menu and create a new Virtual Machine.
Install a VM Operating System
  • Create and install a compatible Windows or Linux OS inside your chosen VM software.

Download and Install XAMPP

  1. Go to the Apache Friends website.
  2. Download the latest version of XAMPP for your OS.
  3. Run the installer in the Virtual Machine, and follow the steps in the wizard to install Apache, MySQL, PHP, and phpMyAdmin.

Set Up WordPress

  1. Download WordPress
  2. Extract WordPress to the htdocs Folder
    • Open the XAMPP installation folder (default is C:\xampp\ for Windows).
    • Inside the XAMPP folder, find the htdocs directory.
    • Extract the downloaded WordPress ZIP file to the htdocs folder.
    • Rename the extracted folder to your preferred site name (e.g., localwordpress).

Create a Database for Your Local WordPress Site

  1. Access phpMyAdmin
    • Open XAMPP Control Panel, and click Start next to Apache and MySQL to start the servers.
    • In your browser, go to http://localhost/phpmyadmin/ to open phpMyAdmin.
  2. Create the Database
    • In phpMyAdmin, click on Databases at the top.
    • Enter a database name (e.g., localwordpress_db).
    • Select Collation as utf8_general_ci, then click Create.

Install WordPress

  1. Run the WordPress Installation Script
    • In your browser, go to http://localhost/localwordpress (replace localwordpress with the folder name you created).
    • WordPress will prompt you to select a language; choose your preferred language and click Continue.
  2. Connect WordPress to the Database
    • WordPress will ask for your database information:
      • Database Name: Enter the name you created earlier (e.g., localwordpress_db).
      • Username: Enter root.
      • Password: Leave this field empty (default password for local XAMPP installations).
      • Database Host: Enter localhost.
      • Table Prefix: Leave as wp_ or change if needed.
    • Click Submit, and WordPress will check the connection.
  3. Complete the WordPress Setup
    • On the next screen, click Run the Installation.
    • Fill in the following fields:
      • Site Title: Choose a name for your local site.
      • Username: Enter admin or another name for your WordPress admin.
      • Password: Choose a strong password.
      • Your Email: Enter any valid email address.
    • Click Install WordPress to complete the process.
  4. Log Into Your New Local WordPress Site
    • After installation, you’ll be directed to the WordPress login page.
    • Log in using the admin username and the password you just created.

Test and Access Your Local WordPress Site

  • In the browser, go to http://localhost/localwordpress/ (or the folder name you used) to view your new WordPress site.
  • You can now develop your site locally before moving it to a live server.

By using XAMPP and a Virtual Machine, you create a safe, isolated environment to build and test your WordPress site locally, without affecting your main operating system in an isolated development environment, protecting your main OS from conflicts and security risks.

Restoring Your Backups

Importing a Backup from All-in-One WP Migration

Now that you’ve set up your local WordPress site using XAMPP, you can restore your site from a backup created using the All-in-One WP Migration plugin. This process will guide you through installing the plugin, importing the backup, and getting your site back online on your local server.

Install the All-in-One WP Migration Plugin

  1. Log into Your Local WordPress Site
    • Open a browser and navigate to http://localhost/your-site-folder (replace your-site-folder with the name you used for your WordPress site).
    • Log in to your WordPress dashboard using the admin username and password you created during installation.
  2. Install the All-in-One WP Migration Plugin
    • In the WordPress dashboard, go to Plugins > Add New.
    • Search for All-in-One WP Migration.
    • Click Install Now next to the plugin, then click Activate once the installation is complete.

Import the Backup File

  1. Access the All-in-One WP Migration Plugin
    • In the WordPress dashboard, go to All-in-One WP Migration > Import.
  2. Upload the Backup File
    • Click the Import From button and select File from the options.
    • Browse and select the .wpress backup file you previously downloaded from your live site.
    • Wait for the plugin to upload and process the backup file. This may take a few minutes depending on the size of the backup.
    • If you get an error about upload limit, refer to instructions below to resolve.
  3. Complete the Import Process
    • Once the backup is successfully imported, a message will appear informing you that the import was completed successfully.
    • You’ll be prompted to Save Permalinks Structure. Click the Finish button to complete the process.

Check Your Site

  1. Log into Your Site Again
    • After the import, you may need to log back into your WordPress dashboard with your previous credentials.
    • Go to http://localhost/your-site-folder/wp-login.php, and log in with your admin username and password.
  2. Test Your Local WordPress Site
    • Visit http://localhost/your-site-folder/ in the browser to view your local site.
    • Check that everything looks correct and that all content, themes, plugins, and settings have been restored properly.

Final Considerations

  • Database and File Structure: All-in-One WP Migration imports both the database and file structure, meaning your posts, pages, media, and plugins should all be restored as they were on your live site.
  • Testing: Since this is a local setup, you can now freely test, modify, or develop your site without affecting the live version.

By following these steps, you’ve successfully restored your WordPress site using All-in-One WP Migration on your local XAMPP setup.

Troubleshooting

Resolving Upload Limit

When trying to import your backup you may get an error about an upload limit, use the methods below to change it. You may need to try more than one just like I did.

Method 1: Increase Upload Limit Using .htaccess File

The .htaccess file is used to configure server settings in Apache-based servers. If you’re using an Apache server, you can adjust the upload limits by editing the .htaccess file.

Steps to Increase Upload Limit in .htaccess:

  1. Access Your WordPress Site Files:
    • Use an FTP client (like FileZilla) or your hosting file manager (via cPanel or similar) to navigate to the root directory of your WordPress site.
    • Look for the .htaccess file. If it’s not visible, make sure your FTP client or file manager is set to show hidden files.
  2. Edit the .htaccess File:
    • Right-click on the .htaccess file and select Edit.
    • Add the following lines of code to the top of the file (before any existing code):

# Increase upload size limit

php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300

  1. Save the File:
    • Save the changes to the .htaccess file.
  2. Test the Upload Limit:
    • Try uploading a larger file through the All-in-One WP Migration plugin. You should now be able to upload files up to 128MB (or your chosen size).

Method 2: Increase Upload Limit Using php.ini File

The php.ini file is the configuration file for PHP, and you can use it to adjust the settings related to file uploads. This method may work if your server allows you to edit the php.ini file, which is common in shared hosting or VPS environments.

Steps to Increase Upload Limit in php.ini:

  1. Locate the php.ini File:
    • Access your website’s root directory (the same as where wp-config.php is located).
    • If you can’t find a php.ini file, create one yourself in the root folder or wp-admin folder.
  2. Edit the php.ini File:
    • Open the php.ini file in a text editor.
    • Add or modify the following lines (or adjust their values if they already exist):

upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 256M
max_execution_time = 300
max_input_time = 300

  1. Save the Changes:
    • Save the file and close the editor.
  2. Restart Your Server (If Needed):
    • Some hosting environments require you to restart the PHP service for changes to take effect. If you don’t have access to restart PHP, contact your hosting provider to confirm that the changes have been applied.
  3. Test the Upload Limit:
    • Go to your All-in-One WP Migration plugin and try uploading a file again to see if the limit has increased.

Method 3: Increase Upload Limit Using WordPress Dashboard (If .htaccess or php.ini is not possible)

If you don’t have access to the .htaccess or php.ini files, some hosting environments allow you to change the upload limit directly from the WordPress dashboard by using a plugin like WP Maximum Upload File Size.

Steps:

  1. Install the WP Maximum Upload File Size plugin from the WordPress plugin repository.
  2. After activation, go to Settings > Media.
  3. Increase the Maximum Upload File Size setting as needed.

Common Settings to Modify:

  • upload_max_filesize: Maximum size of a file that can be uploaded.
  • post_max_size: Maximum size of the entire POST request (including file upload).
  • memory_limit: Maximum amount of memory PHP scripts can use.
  • max_execution_time: Maximum time a script is allowed to run before it is terminated (in seconds).
  • max_input_time: Maximum time for PHP to parse input data.

Important Notes:

  • If you are using a shared hosting environment, your host may limit the values you can set. In that case, you may need to contact your hosting provider for assistance.
  • If you can’t access either .htaccess or php.ini, contact your hosting provider and ask them to increase the upload limit for you.

Conclusion

While that was quite a lot if you need to have it done it can be a life saver! Let me know in the comments if this helped you out.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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