Move Live WordPress Site to Local Server Using Local by Flywheel
We were using MAMP for installing WordPress on local server and for copying live WordPress site to desktop for many years. Initially MAMP was only used on MAC but later they also released Windows version making no need of going to WAMP. Recently we came across another option “Local by Flywheel”. As the name indicates this is software released by Flywheel hosting company. Basically this is a marketing piece from them to help their customer to build and publish sites from local to live server.
But the app allows anyone to install WordPress locally within few minutes. Though you need to spend similar effort like MAMP to move your complete live site to Local by Flywheel app.
Move Live WordPress Site to Local Server Using Local by Flywheel
Here are the step by step processes to move your live WordPress site local server using Local by Flywheel app. We have provided the time consuming steps first so that you can carry on to further steps while previous steps are in progress.
- Use FTP to download all your site files
- Download your SQL database dump from phpMyAdmin
- Download Local by Flywheel app
- Install Local by Flywheel app on your computer
- Create a new site
- Setup WordPress
- Check local WordPress site
- Replace the files with your live site files in “Local Sites” folder
- Upload live SQL database using Adminer
- Update local site’s details
- Launch your live site on localhost
Let us discuss each step in detail in the following sections.
1. Download Live Site Files
One of the big differences in Local by Flywheel is that you don’t need to have WordPress installation files. The app by default has the latest WordPress installation package.
Go to your FTP client and connect to your live server. Start downloading all site files to your local PC or Mac. This may take long time depending on the size of your site. If you need, request your hosting company to send you the backup of site files.
2. Download SQL Database Dump
Local by Flywheel has two option to upload database – Adminer and Sequel Pro. We will explain Adminer in this article since it is similar to phpMyAdmin on your hosting account.
Login to your hosting account and navigate to cPanel. Go to the phpMyadmin section and download the live database file to your local computer. Ensure to download the file in GZIP compressed format and the file name should be end with “.sql.gz”.
Now that you have the database and site files, let us move on to the Local by Flywheel app. You can learn more in a separate article about downloading WordPress backup manually.
3. Download Local by Flywheel App
Go to the Flywheel website and click on the download button. This is almost 500MB app hence will take some time to download depending on your Internet speed. Fill out the details, choose Mac or Widows version and download the app.
4. Install Local by Flywheel App
Once downloaded the app, double click on it and follow the instructions to install it on your PC or Mac. The app will try to install three components – virtual box, host machine and local image.
During installation process, we have encounter the security problem on Mac. You should allow the app in “Security & Privacy” settings and proceed with the installation.
5. Create a New Site
Launch the app after successful installation and click on the “+ Create New Site” button.
Enter the site details and click on “Continue”. The app will automatically take the local site domain as “yoursitename.local” and stores all content under “~/Local Sites/yoursitename” folder. At this point, leave the blueprint option as it is. After first site is created, you can use the first site as blueprint to create further sites. So it is not useful during first site creation.
The next step is to choose the environment for WordPress installation. Select the “Preferred” tab and the app will automatically determine the PHP and MySQL version. The web server is generally “nginx + Varnish”.
Preferred options are the recommended environment by the app. Alternatively you can go to the “Custom” tab and choose the PHP, server and MySQL options on your own. This needs additional download of 220MB files and connecting to Flywheel server is not supported with custom options.
So go ahead with preferred options and click “Continue” button.
The last step in creating a new site is to setup WordPress. Fill the form with your WordPress username, password and email id; you can delete the default email id generated by the app. The advanced option allows you to setup WordPress multisite. So, if you need a multisite installation, ensure to select “Yes” for multisite.
On next screen, you can save the admin details entered for this site as default for the app.
6. Check Local WordPress Site
Now you have successfully installed WordPress on your local computer. Ensure the link “Start Site” on top right corner of the app is showing as green, this indicates the site is running. Click on the “View Site” button to view the WordPress site with your local URL like “yoursitename.local”. You can also login to the WordPress admin panel by clicking on the “Admin” button.
There are many options available in the app which you can navigate and learn yourself. For example, click on the “Trusted” button under “SSL” tab to have a HTTPS connection on your local site. Let us focus on our next task that is replacing the default WordPress site’s content with your live content from steps 1 & 2.
Note: We have noticed, the application was still lying under “Downloads” folder on Mac. You may need to move the “Local by Flywheel” app to “Application” folder manually.
7. Replace Files with Your Live Site Files
The Local by Flywheel app stores all site files under “Local Sites” folder. So navigate to “Macintosh HD > Users > Your Mac User Name > Local Sites > Your Site Name > app > public”. You should find the files under similar path in Windows app.
Just delete the entire site files under “public” folder and move your live site’s files downloaded in step 1.
8. Upload Live SQL Database Using Adminer
The Local by Flywheel app allows two options for uploading database – Adminer and Sequel Pro. Ensure your site is running in the app and then click on the “Adminer” option from the app under “Database” tab. This will open the screen on browser similar to phpMyAdmin.
Select all tables from “Local” database and click on “Drop” button to delete them. Now the “Local” database is empty. Click on the “Import” button and upload the live site’s database downloaded from step 2.
Database file upload should work for smaller database files. In our case we get the memory exhausted error due to the large file size. In such case, extract the live site’s gzipped database file to a .sql file and move under “Local Sites > app” folder. Go to the “Local by Flywheel” app and right click on your sitename. Select the option “Open Site SSH”.
This will open the command prompt and enter the following command:
mysql -u root -proot local < /app/databasefile.sql
Ensure to replace “databasefile.sql “ with the name of your database file uploaded under “Local Sites > app” folder. This command will show a warning and may take a while. After that navigate to “Local Sites > app” folder and check there is a new folder named “sql” is created containing all the database tables.
9. Replace Live Site URL with Local URLs
Now that, you have uploaded the live site’s database file successfully to local site. But when you launch the site, it may still show error establishing database connection error or it will connect to your live site. Go to “Adminer” and click on the “SQL command” link. Paste the below query to replace your live site’s URL to local site URL:
UPDATE wp_options SET option_value = replace(option_value, 'https://www.yoursitename.com', 'http://yoursitename.local') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'https://www.yoursitename.com', 'http://yoursitename.local');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'https://www.yoursitename.com','http://yoursitename.local');
Remember to replace “yoursitename” with your site name and use correct table prefix (we have used the default prefix as wp_).
10. Update Local Site’s Details
The last step is to replace the database name in the local site’s “wp-config.php” file. Go to “Local Sites > app > public” folder and open “wp-config.php” file. Change the database name from live site database to local like below with other details for localhost:
11. Launch Live Site on Localhost
Everything is set now!!! Go to the “Local by Flywheel” app and ensure the site is running. Click on the view site button to launch the local copy of your live site with the URL “yoursitename.local”. You can login to admin dashboard and start editing the local site.
Remember, you may need to adjust sidebar and footer settings, as they might not be copied from the live site. Also plugins like Jetpack will ask you to run in safe mode on local site. After finished activities logout from the admin panel, stop the site in Local by Flywheel app and then quit the app.