Multiple XAMPP Servers on USB - Setup Guide

Creating Portable Web Servers with XAMPP and the 'subst' Command
The pursuit of a rapid and straightforward method for establishing virtual web servers – essentially local development environments – on a portable hard drive has been ongoing. The goal wasn't simply to create one, but to facilitate the deployment of multiple configurable web servers accessible as localhost with minimal effort.
As readers of my previous work may recall, I previously explored this functionality using Server2Go. This approach garnered positive feedback. However, a limitation of Server2Go is its design, which prioritizes a clean testing environment with each launch, resulting in poor retention of configurations upon shutdown.
XAMPP as a Suggested Alternative
Numerous readers recommended XAMPP as a superior solution. XAMPP has long been a popular choice within the web development community. It was featured by Aibek in a compilation of 100 top portable applications, and Dave provided a guide on setting up an XAMPP server on a standard PC.
Initially, a standard XAMPP installation necessitates placement on the root drive. This limits portability, effectively tying the web server to a single drive. To overcome this constraint, I investigated whether the "subst" command within DOS could provide a solution – and it proved successful!
The "subst" command allows for the creation of virtual drives, effectively mapping a folder on a portable drive to a drive letter. This enables the installation of XAMPP onto the portable drive, and then accessing it as if it were installed on the root drive.
This method allows for the creation of multiple, independent web server environments on a portable drive, each configurable and accessible via localhost. It combines the robust features of XAMPP with the flexibility of a portable setup.
Setting Up Multiple Portable XAMPP Web Servers
To begin, it’s essential to designate a specific folder on a portable storage device, such as a portable hard drive or a sufficiently large USB drive, to contain all website files. A root directory, for example, named "TopSecretWriters," can be created for this purpose.
The next step involves informing Windows to recognize the directory on the portable drive as a root directory, utilizing the SUBST command. In a DOS command prompt, the command "subst X: H:\TopSecretWriters" can be entered.
This configuration establishes drive X: as a direct reference to the TopSecretWriters directory located on the portable drive. Remember this assignment, as it will be necessary to execute this command each time the web server is to be launched, ensuring proper Xampp functionality.
Now, obtain the Xampp ZIP archive – avoiding the Windows installer – and extract the Xampp folder into the newly created directory.
Navigate into the Xampp folder and initiate the "setup_xampp.bat" file by double-clicking it.
Subsequently, execute "xampp-control.exe" to access the following interface:
Select both the Apache and MySQL services, then start them. Upon successful installation and a "running" status, launch a web browser and navigate to "http://localhost/". This will display the Xampp welcome screen.
Click on "Status" to verify that the majority of the components are activated and functioning correctly.
Additional Considerations
- Portability: This setup allows for a fully portable web server environment.
- Command Line: The SUBST command is crucial for mapping the portable drive.
- ZIP Archive: Using the ZIP archive avoids potential installation issues.
Running the Server
Ensure the SUBST command is executed before launching xampp-control.exe. This ensures the server correctly identifies the website files. The Apache and MySQL services must be running to host dynamic websites.
Installing a Complete Backup of a WordPress Website
You have now completed the setup of the Xampp web server. Simply transfer your website’s files into the HTDOCS directory, and it will become accessible at http://localhost/.
Recognizing the common desire for a local replica of a WordPress blog or website, the following instructions detail how to install a complete, local instance of your site. You will require access to your blog’s MySQL database, along with its associated username and password.
Initiate phpMyAdmin within your local Xampp installation by navigating to http://localhost/phpmyadmin/. Enter the desired name for your database in the “create new database” field and then click “Create”.

Remember to configure “Privileges” by adding a new user. This user should possess the username and password corresponding to your site’s database, and the host should be specified as “Localhost”.
Obtain and extract a WordPress copy that aligns with the version currently running on your live site. Configure your local wp-config.php file with the correct database name, username, and password. Then, access http://localhost/wp-admin/install.php to begin the installation process.
Finally, transfer the entire wp-content folder from your live WordPress website to the corresponding wp-content folder within your local web server’s WordPress installation.

The remaining step involves exporting your website’s MySQL database to your local environment, completing the mirroring process, including all posts, comments, and other data. Access your CpanelX control panel, select “Backups”, and then choose the database associated with your blog.

The database will be saved as a .GZ zip file; retain this file as a backup. Return to MyPhpAdmin within your local web server environment, select your database, and click the “Import” button. On the subsequent screen, use the Browse function to locate and select the .gz file you previously downloaded.

This action will import your entire database. Visiting http://localhost/ will now display a precise replica of your live website. You can now safely experiment with themes, advertisements, or other modifications in this local environment before implementing them on your live site.
To replicate this setup for another website, restart the process from the beginning of this guide. Create a new directory on your portable drive for the second website, and select a different drive letter during the SUBST command execution.
All preceding steps pertain to establishing your own local web server. To launch a specific local web server instance, navigate to its directory and execute the “xampp_start.exe” file. Conversely, “xampp_stop.exe” will terminate that local web server. It’s important to note that this configuration functions optimally when only one localhost web server is active at a time.
We encourage you to test this setup and share your experiences. Do you have a requirement for running multiple local web servers concurrently? Does this solution address your needs? Please share your feedback and any additional insights in the comments section below.