How to Install WordPress on a USB Flash Drive
Did you know you can install and run a WordPress site from a USB flash drive? Well, you can, and this little-known fact is more than just a neat trick. A portable WordPress installation can actually be quite useful.
Why in the world would you ever need to run WordPress from a flash drive? Shouldn’t this be filed away under “silly WordPress dev tricks” that might have marginal educational value with no real-world application and merit? Some might think so, but I can think of two scenarios where this “silly trick” proves that it has real-world merit:
- You need to work on a WordPress development project locally on more than one machine
- You want to distribute a copy of a WordPress site without hosting it on a web server
In those two scenarios – and there may be others, those are just the two scenarios that come to my mind – running WordPress on a USB flash drive will allow you to have a portable local WordPress site for development and demonstration purposes.
To run WordPress you need a web server that offers two things: PHP and a suitable database management system.
Sounds easy enough.
There is a long list of local development servers like XAMPP, MAMP, VVV, WAMP, and others that will do the trick, right? Well, maybe. While all of those options will do just fine when installed on a computer, we aren’t looking for a platform to install on a computer. PHP and MySQL packages must be designed to be portable in order to be installed on a flash drive.
After extensive research, or at least extensive Googling, I have determined that there are at least three server platforms under current ongoing development that meet the minimum requirements to run WordPress and can be installed and run from a flash drive:
I installed all three options on a flash drive and got a WordPress site up and running with each. So, in this article, I’ll give you the details on how easy each is to set up and which gets my vote as the best platform to use if you need or want to run WordPress from a flash drive.
It’s worth pointing out that all three of these options are for Windows computers only. While there may be options for Mac OS X that can be installed on a flash drive, I wasn’t able to locate those options.
XAMPP is the most robust and complete development system on this list and is primarily designed to be installed directly on a computer. As a result, the documentation available to help you get XAMPP set up on a flash drive is limited.
Actually, that’s a lie. It isn’t limited. There is no documentation for installing XAMPP on a flash drive, just a scattered assortment of StackOverflow discussions and tutorials on other blogs across the web.
Never fear. Installation is pretty easy.
To run XAMPP on a flash drive download the portable or lite version of XAMPP rather than the standard edition. First, head to the Apache Friends download page and select More Downloads.
Next, select XAMPP Windows to bring up a list of the available versions of XAMPP. Pick the version of XAMPP you want to install keeping in mind that the version name, 5.6.21 for example, refers to the version of PHP that ships with that edition of XAMPP. Once you’ve selected a version of XAMPP, you’ll be presented with a few different download options. Select the downloadable file that includes the word portable in the name and is executable (ends in .exe).
Once the installation file has downloaded, find it and run it. When you run the installation file, be sure to select your flash drive as the installation location. Since I’ll be installing three different web servers on this particular drive, I’ve created a directory called XAMPP in which to install XAMPP.
Once XAMPP is installed on the flash drive it will work just like a desktop XAMPP installation.
Next, lets install WordPress. With XAMPP started and both Apache and MySQL running, to install WordPress do four things:
- Access phpMyAdmin by going to http://localhost/phpmyadmin with XAMPP running and create a new database.
- Drop a fresh WordPress installation into the XAMPP htdocs directory on your flashdrive.
- Edit wp-config.php to tie WordPress to the database you just created.
- Edit the
max_execution_timesetting in php.ini. The default value is 30 seconds. Since you’re going to be writing and fetching contents from a USB drive, bump this value way up. At first I used 120 seconds, but after exceeding that value while installing WordPress I bumped it all the way up to 600 seconds. After adjusting this value you’ll need to restart MySQL and Apache to ensure the new settings take effect.
If you need detailed instructions on installing WordPress or editing PHP settings our previous tutorials on installing WordPress locally and troubleshooting common XAMPP issues will provide the details you need.
With those four steps completed and both Apache and MySQL started point your browser at http://localhost/directory_where_you_installed_WordPress to run the WordPress istallation script.
When all is said and done you’ll have WordPress and a XAMPP installation set up on a USB flash drive that you can use on any Windows machine.
UwAmp is designed to be an easy-to-use server much in the same vein as XAMPP. It is a full-fledged PHP development environment you can use for WordPress or to work with any other PHP and MySQL application.
One really nice feature offered by UwAmp is the ability to download, install, and run different versions of PHP automatically from the UwAmp control panel. Developing with the same version of PHP that will run on the live web server is always a good idea and UwAmp makes that easy. I can also see this feature being particularly useful to plugin and theme developers who need to be able to test their products using a variety of different versions of PHP.
Installation is simple. Head to the UwAmp website, select Download, and then select Download Exe/Install. Once the download has completed, find the downloaded installation file and run it making sure to select the flash drive as the installation location.
Once installation is complete, open the folder where you installed the application and look for UwAmp.exe. Select and run this file to launch the UwAmp control panel.
If you’ve worked with XAMPP, WAMP, or any other local development servers before you’ll recognize a lot of the options available in the UwAmp control panel. Here you can access phpMyAdmin, review and adjust PHP settings, start and stop MySQL and Apache, and much more.
Installing WordPress on UwAmp is exactly the same as installing WordPress on XAMPP.
- From the UwAmp control panel, select the document icon next to PHP Config, locate the max_execution_time setting, and increase the value from 30 seconds to something larger. Based on my experience running XAMPP from a flash drive I went with a value of 600. Save the file, close it, and UwAmp will automatically restart MySQL and Apache so that the settings take effect.
- Select PHPMyAdmin, use root as both the username and password to log in, and create a new empty database.
- Drop a fresh copy of WordPress into the directory at YourFlashDrive:\UwAmp\www.
- Edit wp-config.php using the name of the database you just created and the associated username and password (use root as both the username and password if you did not create and assign a user to the database when you created it).
- Point your browser at http://localhost/directory_where_you_installed_WP to launch the WordPress installation script.
So that’s that. You now have WordPress and UwAmp installed on a USB flash drive and ready to run on any Windows machine at a moment’s notice.
Instant WordPress is the purpose-built solution for powering WordPress from a USB flash drive. Created by a WordPress educator, the purpose of InstantWP is to make it as easy as possible to run WordPress–and nothing else–from a portable storage device.
In theory, since InstantWP is the purpose-built solution, it should be the clear-cut easy-to-use winner. But is it? Let’s find out.
To get the application head to the InstantWP website and click Download Now.
Installation is very straightforward. Once the installation file finishes downloading, locate it and run it making sure to select the appropriate directory on your flash drive during the installation process.
That’s it. No, really.
Unlike XAMPP or UwAmp, WordPress ships with InstantWP. Just head to the folder where you installed the application, find InstantWP.exe, and run the application.
From the InstantWP dashboard, you can launch the WordPress site homepage or admin login page, manually install plugins and themes, access phpMyAdmin to manage MySQL databases, and access the documentation.
Each InstantWP installation is completely self-contained. So you can rename the InstantWP folder anything you like and install additional copies of InstantWP to run multiple websites from the same flash drive without ever setting up a database, adjusting PHP settings in php.ini, or manually editing a wp-config.php file.
Summary of the Options
Each of these options comes with its own set of pros and cons.
XAMPP is the heaviest of the three and the most complex to set up and configure. However, it’s also the most capable if you plan to do anything other than WordPress development.
In my book, XAMPP is a complete solution for experienced developers who want to work on WordPress, but who also want to work on other PHP or Perl applications.
UwAmp is a great PHP and MySQL package, and the ability to pick between PHP versions and then adjust PHP settings and trigger an automatic reboot of Apache and MySQL is a really nice touch. However, like XAMPP, UwAmp is heavy enough that it sometimes bogs down and runs pretty slow from a flash drive.
Despite the sometimes sluggish performance, it’s possible that UwAmp is the ideal solution for WordPress developers who want PHP, MySQL, and nothing else.
Without a doubt, InstantWP is the easiest to install, easiest to set up, and offers the smoothest performance when running from a flash drive. However, the version of WordPress installed with InstantWP comes with a handful of preinstalled plugins, which will turn off some developers. In addition, InstantWP is only good for WordPress development. If you want to do anything other than fairly standard development with WordPress, InstantWP may not be up to the task.
InstantWP is the unquestioned winner if you want a plain-vanilla portable WordPress development environment that is as easy as possible to get set up.
And the Winner Is…
For my needs, UwAmp is the best choice.
While it doesn’t run quite as fast as InstantWP, I’m a bit turned off by the pre-configured flavor of WordPress that ships with InstantWP. In addition, as a current and ongoing PHP student, it’s important to me that my development environment is capable of powering more than just WordPress. Lastly, UwAmp has two really great features that neither other option offers: a server reboot process that starts automatically when a change is made to PHP configuration and the ability to change to any PHP version with ease.
If you want to run WordPress from a USB flash drive all three of these platforms are viable options, and the determination of which is best for you will depend on your development needs and preferences.