Clone & Edit WordPress Locally with Bitnami & UpdraftPlus
Perhaps it is because I’m becoming an old timer, but I generally prefer to work locally rather than online, (unless there is a good reason not to). As most of my dev work these days involves WordPress (WP), I will periodically clone our WP site locally to test content, experiment with plugins or generally explore WP until it breaks. In the last year I’ve tried FlyWheel Local, Xamp, ServerPress and Bitnami. Currently, the best method I’ve found is to use the Bitnami WordPress Stack with UpdraftPlus (a WP backup/clone plugin). The Bitnami Stack includes WordPress, Php, MySQL, and Apache Server. Setup is easy and it runs faster than any of the other apps I’ve tested. It launches the server when Windows starts, and includes easy access to phyMyAdmin.
This article provides instructions for setting up Bitnami and cloning a (remote) WordPress site with UpdraftPlus. The Bitnami stack includes the All-In-One plugin for cloning, but I’ve had mixed results with it. With this method, everything is done using WordPress, so if you have a WP cloner you like, it will work fine in this situation. After having some backup/clone plugins fail and finding that UpdraftPlus works great, I purchased a five year license of the “Migrator” version for $99 (disclaimer: no compensation whatsoever for promoting it). The cloning process is simple: backup the live site up to Google Drive, download the zips, and use the UpdraftPlus’ restore function to install the site locally.
Caveats & Cautions
- Inside of the Bitnami Stack, WordPress can be updated the usual way, but the Bitnami Stack is not upgradable, so this may not be the best solution for long-term local WP development. To use the latest Bitnami Stack it must be installed afresh. When updated, any local sites can be backed up and reinstalled. I don’t clone the local site back to the web, so periodically uninstalling/reinstalling Bitnami works fine for my use. Bitnami does not need to upgraded each time they publish a new version.
- When you have both local and a remote site, it is obviously very important to keep track of which one you are working on lest you modify your live site accidently (the voice of experience)! The most sure-fire way to prevent this is not to have them both open at the same time. Other strategies include opening them in separate browser windows and always positioning them the same (for example the live site on the left). Also, change the favicon of the local site.
- Like perhaps all web tools, the tools discussed in this article change frequently. To minimize re-figuring useage, I take copious notes when I use software. As I wrote this article I discovered that some of my notes, less than 6 months old, are obsolete.
- If you are running the Internet Information Server or any other servers, these can effect your Bitnami install — particularly the server port.
Download and install using the Bitnami WordPress Stack Installer
To install multiple WP sites using a single install of the Bitnami Stack, you will need the WP WAMP Module. This is placed into the root of the Bitnami install. More on this later.
If you don’t want to use the default install directory you can choose a different location. Bitnami must be installed into an empty folder, and if the folder is not named Bitnami, the installer will add a Bitnami directory as it’s root.
The admin screen is important!
Despite the WP logo, this is the login/pwd for the Bitnami stack. Bitnami will apply the login/pwd as the default admin login/pwd when you install WP sites. Also, you will need the pwd to login to phpMyAdmin (with username ‘root’). If you’re going to clone over the site, the Blog name doesn’t matter as it will be overwritten. It can also be changed in WP.
The default server port is 80. If Bitnami detects another server running, it will ask which port to use when configuring the Apache Server, else you won’t see that screen during the install. I’d recommend accepting all the server port requests, adding an email account, and disabling the request to launch in the cloud. When the install is complete, Bitnami asks if you want to open the site, which you probably do. You also get the Bitnami Manager window, which can be closed.
The install can take awhile, but when completed, you have WP running locally with a default site.
If Bitnami used the default server port (80), your site will be available at http://127.0.0.1/wordpress/. You can also use the name of your computer, for example http://pixelmuncher/wordpress/
If Bitnami has assigned a port to its server, the URL will included the port number. For example http://127.0.0.1:81/wordpress/
Log into the site by appending wp-login.php to the URL. For example http://pixelmuncher/wordpress/wp-login.php
Backup the Source Site
CAUTION! There are some plugins which will break this process — they should be disabled before backing up your site. For example, our site is hosted at SiteGround. They have a proprietary caching plugin which causes problems during a local install. I disable this plugin before backing up. The proprietary plugins installed by our maintenance vendor also need to be disabled. I’m sure there are other plugins which would cause similar problems. When migration is completed they can be deleted from the cloned site. Don’t forget to re-activate them on the live site after backing up!
I have UpdraftPlus configured to backup to Google Drive. Download the backed up zips to the local computer for cloning.
Clone Backup Locally
After installing and activating UpdraftPlus on the local computer, it will create a directory for storing backups.
In my case the directory is: D:\Projects\Bitnami\apps\wordpress\htdocs\wp-content\updraft.
Copy the backups to this directory:
Open UpdraftPlus in the local WP dashboard:
If all has gone well, the archives will now be visible in Updraft’s Restore panel. If not, you can rescan the local dir.
Run the restore:
The multi-step restore has some variations and can be a bit confusing. After choosing to update all the components, UpdraftPlus will notice that the site is being migrated. It will ask to perform search/replace in the database, which we want to do because the domain has changed. UpdraftPlus will then display a message that it has begun the restore — you don’t need to press the restore button on that window. During the restore, UpdraftPlus will create several temp files in it’s directory. Note that if you are installing a backup from your local server, UpdraftPlus will not display the search/replace screen as all of the URLs should be correct.
UpdraftPlus will display an activity log in the WP backend. When it is finished you will be logged out and will be presented with the WP login screen. If the login screen does not appear shortly after the log reports “Restore Successful” refresh the page and the login screen should appear. When you login you need to use a username/pwd from the source site. When logged in you can remove the plugins which were disabled on the source site before backing up (and any others that are not needed.
If all goes well, you’re done and ready to go. If the dashboard is missing some plugins, check to see if they’ve been cloned but deactivated — this is the most common problem I’ve encountered. It can happen if Updraft encounters a plugin which can’t be activated on the local site — see Cautions Section above. Reactivate the plugins you need. See also the note in the Troubleshooting Section below.
Consider also disabling plugins which you won’t use locally — especially if they are hitting the web.
Caution: Accidently activating something like Simple Maintenance Mode might throw you for a loop as your site will be in maintenance mode and you might think you’ve made a mistake…
After getting the local site setup correctly, you might want to run another backup. Then experiment and wreak havoc on your WordPress site and a fix is just a restore away — have at it!
Bitnami includes a server manager which can be launched from its root directory. It offers a variety of admin controls as seen in the screen grabs. If you launch phpMyAdmin, the login will be ‘root’. The password will be the password that was used during the install.
Kill the Cache
Generally speaking you will want to disable the server cache so your changes will be reloaded every time you refresh a page.
In order to disable the cache in the server, we disable OPCache, which is enabled by default. To disable OPCache, find opcache.enable in your php.ini (InstallDir\Bitnami\php\php.ini) file and set it to 0:
; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. (“1” means validate once per second, but only
; once per request. “0” means always validate)
The server needs to be restarted after making this adjustment. See Server Manager pix above.
If some or all of the plugins are deactivated after migration, you can determine which plugins are causing the migration problem. In the WP dashboard, view the Inactive Plugin list, select all, and Bulk Actions/Activate. The plugins will be activated in alphabetical order. If WP is unable to activate a plugin, it will stop the whole process, leaving the problem plugin and all the rest deactivated. Select them all again, deselect the top plugin and repeat the bulk activation.
SUGGESTION: Periodically backup the local site. This will allow you worry-free hacking with a restore only a couple of minutes away.
Part 2: Add Additional WordPress Sites to the Stack
Multiple WP sites can be added to a Bitnami Stack. To add this capability, download the WP WAMP Module and place the file into the root of the Bitnami install:
If you double click the installer, you will run into trouble as you are asked to install into the existing Bitnami folder and then after working thru all of the install screens you are told that you might overwrite your current install. Don’t do that! (and don’t ask me why it works that way).
An alternative is to install via a shell/command line/prompt/terminal, using the name of the new site as a flag in the command. For example:
prompt> D:\Projects\Bitnami\bitnami-wordpress-4.9.8–0-module-windows-installer.exe — wordpress_instance_name mySite2
The Bitnami installer will launch again, but this time with fewer steps. You’ll need the password from the install of the stack:
When this install is completed Bitnami will ask if you want to open the WP Module. If you do, it will open the original site. To open the new site, the URL will be something like: http://pixelmuncher/mySite2/. The admin login/pwd will now be the same as the those specified when the Bitnami Stack was installed.
Note that Bitnami will create a new dir for the site: \Bitnami\apps\mySite2
And so on…
Geeky Installation Details
If, like me, you have been burned at least 6.022 x 10²³ times by software, particularly Windows, then you might also have developed the habit of keeping an eye on what gets installed on your computer. If so, note that after the initial install of the Bitnami Stack, “Bitnami WordPress Stack” will be listed in Windows Apps & Features.
After installing the WordPress Module, there will an entry added for “Bitnami WordPress Module”. So what happens if you have multiple sites installed and you want to delete some of them? I didn’t test all the possibilities, but I did test one:
Each WP install includes an uninstaller in its root folder. When the uninstaller is double clicked, it will uninstall that site AND remove Bitnami WordPress Module from Apps & Features. So what about the others? They are all still there and each has an uninstaller (uninstall.exe) which will work correctly.
Okay, as usual a “simple tutorial that others might find useful” has required nth degree research, a few re-installs, consults with tech support, etc.
Now back to work…