SEARCH

How-To Geek

Turn a Flash Drive Into a Portable Web Server

Portable applications are very useful for getting work done on the go, but how about portable servers?  Here’s how you can turn your flash drive into a portable web server.

Getting Started

To put a full web server on our flash drive, we’re going to use XAMPP Lite.  This lightweight, preconfigured server includes recent versions of Apache, MySQL, and PHP so you can run most websites and webapps directly from it.  You could use the full XAMPP, which includes more features such as a FileZilla FTP server and OpenSSL, but for most purposes, the light version is plenty for a portable server.

Download the latest version of XAMPP Lite (link below).  In this tutorial, we used the self-extracting EXE version; you could choose the ZIP file and extract the files yourself, but we found it easier to use the executable.

sshot-45-maguay@live.com,Matthew-PC

Run the installer, and click Browse choose where to install your server.

sshot-47-maguay@live.com,Matthew-PC

Select your flash drive, or a folder in it, and click Ok.  Make sure your flash drive has at least 250MB of available storage space.  XAMPP will create an xampplite folder and store all the files in it during the installation.

 sshot-48-maguay@live.com,Matthew-PC

Click Install, and all of the files will be extracted to your flash drive.  This may take a few moments depending on your flash drive’s speed.

sshot-50-maguay@live.com,Matthew-PC

When the extraction process is finished, a Command Prompt window will open to finish the installation.  The first prompt will ask if you want to add shortcuts to the start menu and desktop; enter “n” since we don’t want to create start menu links to our portable server.

sshot-52-maguay@live.com,Matthew-PC

Now enter “y” to configure XAMPP’s directories automatically.

sshot-53-maguay@live.com,Matthew-PC

Finally, enter “y” to make XAMPP fully portable.  It will set up the servers to run without specific drive letters so your server will run from any computer.

sshot-55-maguay@live.com,Matthew-PC

XAMPP will finalize your changes; press Enter when everything is completed.

sshot-56-maguay@live.com,Matthew-PC

Setup will automatically launch the command line version of XAMPP.  On first run, confirm that your time zone is correct.

sshot-57-maguay@live.com,Matthew-PC

And that’s it!  You can now run XAMPP’s control panel by entering 1, or you can exit and run XAMPP from any other computer with your flash drive.

sshot-58-maguay@live.com,Matthew-PC

To complete your portable webserver kit, you may want to install Portable Firefox or Iron Browser on your flash drive so you always have your favorite browser ready to use.

Running your portable server

Using your portable server is very simple.  Open the xampplite folder on your flash drive and launch xampp-control.exe.

image

Click Start beside Apache and MySql to get your webserver running.

Please note: Do not check the Svc box, as this will run the server as a Windows service.  To keep XAMPP portable, you do not want it running as a service!

sshot-59-maguay@live.com,Matthew-PC

Windows Firewall may prompt you that it blocked the server; click Allow access to let your server run.

sshot-62-maguay@live.com,Matthew-PC

Once they’re running, you can click Admin to open the default XAMPP admin page running from your local webserver.  Or, you can view it by browsing to http://localhost/ or http://127.0.0.1/ in your browser.

image

If everything is working correctly, you should see this page in your browser.  Choose your default language…

sshot-63-maguay@live.com,Matthew-PC

And then you’ll see the default XAMPP admin page.

image 

Click the Status link on the left sidebar to make sure everything is running correctly.

image

If you click the Admin button for MySql in the XAMPP Control Panel, it will open phpMyAdmin in your default browser.  Alternately, you can open the MySql admin page by entering http://localhost/phpmyadmin/ or http://127.0.0.1/phpmyadmin/ in your favorite browser.

image

Now you can add your own webpages to your webserver.  Save all of your web files in the \xampplight\htdocs\ folder on your flash drive.

image

Install WordPress in your portable server

Since XAMPP Lite includes MySql and PHP, you can even run webapps such as WordPress, the popular CMS and blogging platform.  Download WordPress (link below), and extract the files to the \xampplite\htdocs folder on your flash drive.

image

Now all of the WordPress files are stored in \xampplite\htdocs\wordpress on your flash drive.

image

We still need to setup WordPress on our portable server.  Open your MySql admin page http://localhost/phpmyadmin/ to create a new database for WordPress.  Enter a name for your database in the “Create new database” box, and click Create.

image

Click the Privileges tab on the top, and the select “Add a new User”.

image 

Enter a username and password for the database, and then click the Go button on the bottom of the page.

image

Using WordPress

Now, in your browser, enter http://localhost/wordpress/wp-admin/install.php.  Click Create a Configuration File to continue.

image

Make sure you have your Database name, username, and password we created previously, and click “Let’s Go!”

image

Enter your WordPress database name, username, and password, leave the other two entries as default, and click Submit.

image

You should now have the database all ready to go.  Click “Run the install” to finish installing WordPress.

image

Enter a title, username, and password for your test blog, as well as your email address, and then click “Install WordPress”.

image

You now have a portable install of WordPress.  Click “Log In” to  access your WordPress admin page. Enter your username and password, and click Log In.

image

Here you can add pages, posts, themes, extensions, and anything else just like you would on a normal WordPress site.  This is a great way to experiment with WordPress without messing up your real website.

image

You can view your portable WordPress site by entering http://localhost/wordpress/ in your address bar.

image

Closing your server

When you’re done running your test server, click the Stop button on each of the services and then click the Exit button in the XAMPP control panel.  If you press the exit button on the top of the window, it will just minimize the control panel to the tray.

 image

Alternately, you can shutdown your server by running xampp_stop.exe from your xampplite folder.

image

Conclusion

XAMPP Lite gives you a great way to run a full webserver directly from your flash drive.  Now, anywhere you go, you can test and tweak your webpages and webapps from any Windows computer. 

Links

Download XAMPP Lite

Download WordPress

Matthew digs up tasty bytes about Windows, Virtualization, and the cloud, and serves them up for all to enjoy!

  • Published 05/7/10

Comments (25)

  1. Richtpt

    Apache wouldn’t start because I had Skype running. Closed Skype and it started, then I was able to restart Skype. Works great, thanks for the tip!

  2. Josh

    Just wondering what the point of having a wordpress install on a usb drive is? especially if you’re trying to share it with anybody else you’d need dyndns set up too and that would be changing based on where you’re plugging in the usb drive. Cool in concept. fail in the “why?” category.

  3. Spooter

    @ Josh

    Heres a reason why for you…

    Im using this method to carry round my live site and develop on it without affecting the live site.

    I used this in conjunction with http://www.howtogeek.com/howto/ubuntu/make-a-backup-copy-of-your-production-wordpress-blog-on-ubuntu/

    Perfect..

  4. Ralph

    What kind of conflicts will we encounter if we already have locally running xampp services,etc?

  5. Matthew Guay

    @ Ralph – We haven’t actually tested that scenario, so I’m not sure. I believe they could run simultaneous, but you’d have to try to see. Let us know how it works if you try it!

  6. Abhishek

    i tried this method n it worked fine…but after i logged out of the database…
    then the next time when i tried an error was displayed..and m not able to get rid of that error..
    the error is –
    MySQL said:

    #1045 – Access denied for user ‘root’@’localhost’ (using password: NO)

    phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
    what i shall i do to get rid of this error…
    please help me…
    thanx in advance

  7. Christopher Masiello

    This is a great tutorial. It’s nice to have a WordPress (or other app) installation that is portable to use as a testing server. You don’t want to test in Production, or you’ll screw up your site.
    Try stuff here and when it “WORKS” you can FTP it up to your real site.
    Thanks,
    Chris

  8. Jonathan

    Nice tutorial, I’ve been learning about an actual LAMP server under Debian but this is a good alternative if you need to carry your work around. The one thing I’d change in XAMPP is the last P, Python instead of Perl, however, this would take a lot of extra space. There is a Portable Python but I don’t know if you’d be able to integrate XAMPP Portable and Portable Python, using mod_python or CGI.

  9. Todd Corson

    I followed all of these instructions to the letter, but can’t get WordPress (2.9.2) to work. In the step where it asks for the Blog Title, the User Name and Password fields are missing. After I click the “Install WordPress” button, I never get a success message. If I try to go to the administration page, I get a message that says “One or more database tables are unavailable. The database may need to be repaired.”

    Any tips? So far every solution I’ve found with Google hasn’t helped. Also, is the phpMyAdmin page excruciatingly slow on everyone else’s XAMPP installation?

    Thanks.

  10. Robert Chapman

    I have just read how to turn a flash drive into a portable web server. The question I have is does it matter that my OS is windows 7 64bit?

    Bob

  11. Matthew Guay

    @Robert – It works great on Windows 7 64; that’s what I did the test on. And, even if you set it up on Windows 7 64-bit, it will still work fine on 32-bit editions of Windows.

  12. Jon

    One thing I cant find in any documentation so far is, is there a way to make this portable webserver so it can communicate through the internet ?

  13. royce

    GREAT tutorial – fantastic pictures to go along. only one problem after i made a new user – i had to go into the config for myphpadmin and change the password. other then that its flawless! :) good job bunjob

  14. c0ldb0y

    The second time, MySQL can’t start, it’s always busy :-s Any solutions for this problem?

  15. bgibson135

    During my first install, I had a problem with IIS running on my PC. It was running on the default port 80, so it was conflicting when I attempted to Start Apache (also port 80 default setting). You could change one or the other port, so there is no conflict, or shut down the conflicting app until you’re through with Apache.

  16. Jordon

    Does this work on a Mac?

  17. Debajyoti

    Hello Mathew,

    I have been a regular user of XAMPP for a long time. Its just great. I even use Tomcat on top of XAMPP. There is an addin by which you can get Tomcat integrated with XAMPP seamlessly. The entire thing works like a breeze from my flash drive.
    Recently I was trying to integrate an IDE called Eclipse with XAMPP. I have used the eclipse-jee-helios-win32 version. I have no problem in using Eclipse as a portalbe application from the same flash drive. The problem is with integrating Eclipse and XAMPP. There is a plugin for this – its called the PHPEclipse plugin. I installed the pluggin successfully and also did the configuration as much as I knew. Well, this plugin is supposed to give an interface enhancement in Eclipse so that XAMPP, Apache and MySQL can be controlled.

    Problem:
    1. The options to control XAMPP, Apache and MySQL which are visible in PHPEclipse menu in Eclipse are not able to function at all.
    2. Although Tomcat is installed, PHPEclipse is not showing it at all.

    Any suggestions would make me really happy.
    :D

  18. Elias Paixão

    After 3 days trying to configure xampp on my pendrive, I finally found this steps. I did it. It works. Thank you so much. Now I’ll start trying to make tomcat runnable.

  19. CrystalPhoenix

    I followed all the steps, but when I try to install WordPress, I get a “Error establishing a database connection” (right after entering the database name, user, and PW). The same happens when I try to run my localhost website installer. I’m pretty new at this – what am I doing wrong? I followed each step exactly as instructed.

  20. Ryan

    how do you change the port for Apache ?

  21. Bob

    I downloaded all as you instructed, started both Apache and MySql. Localhost status shows MySQL database activated.. Click on phpMyAdmin and I get #2003 – Can’t connect to MySQL server on ‘localhost’ (10061). Any ideas?

    Thanks.

  22. drewdin

    Did anyone else not have any luck finding xampp lite? I cant find it if my life depended on it…

  23. Star

    @drewdin The link to download it is at the bottom of the page just above the place where you wrote your comment.

  24. Earl

    I was wondering I am setting up a database on this portable server. I want other people to be able to put the flash drive in and be able to start a browser and pull up the information. Can I leave xampp running so PHP will be running when they put the flash drive in or do I have to shut xampp down every time I remove the flashdrive?

  25. Sajjad Khalid

    Excellent Article. I will definitely prepare my web server on a flash drive. In this way, i’ll be able to run my website sharing my resources from anywhere.

Enter Your Email Here to Get Access for Free:

Go check your email!