Portable Apache Web Server

When you are developing php applications for the web, you need to have a development server. Normally I install one on my local harddrive.  There are many Apache server downloads for Windows (wamp: Windows, Apache, MySql, PHP) ; xampp, wampserver etc. When I changed computers, I sometimes installed a wamp server, or put my own server together. Struggling to get ssl working was one of my favorites 🙂

When my current laptop was ready to be replaced, (dropped it too many times, crashed when stressed etc) The Apache server (with all its data) had to moved of course  I don’t like it.

So, bright idea, lets find a solution so I never have to move a server again. Search for Portable Apache web server on the net.

Ah, many…A pretty heavy (or less heavy) loaded portable version of rank high in Goolge, but I also found this one http://www.usbwebserver.net/en/ . Installed it and it works nicely, it has all I need actually, without any bells and whistles….

What I do need however are Virtual Hosts, because I have many local “domains” running, and sometimes let the “real domain” run on my local Apache server for testing purposes.

The USB web server does not have any configuration ready for that, so I needed to add a Virtual Hosts configuration to it.

First, how can the USB webserver work from any installed path?. The USB webserver does the following; before it starts the server, it opens a httpd.conf located in its settinsg directory and replaces {path} with the actual path of the server. (and {port} with the port Apache is listening to) and copies it to the Apache2 configuration.

Easy, just add the Virtual hosts configuration to the httpd.conf file….

NameVirtualHost *:{port}
<VirtualHost *:{port}>
 DocumentRoot "{path}/root"
 ServerName localhost
 </VirtualHost>
<VirtualHost *:{port}>
 ServerAdmin webmaster@www.spice.dom
 DocumentRoot "{path}/root/www/www.spice.dom"
 ServerName www.spice.dom
 ErrorLog "logs/www.spice.dom-error.log"
 CustomLog "logs/www.spice.dom-access.log" common
</VirtualHost>

And add more virtual hosts after that….

And of course, enable the virtual hosts module:

LoadModule vhost_alias_module modules/mod_vhost_alias.so (remove the # in front)

Now just create the directory in the “root” directory of the USB webserver, and add the “domain” to your hosts file C:\Windows\System32\Drivers\etc\hosts like:

127.0.0.1 www.spice.dom

Restart the USB webserver, and you have your own “domain” running….

I have changed php versions, Apache Versions with the USB web server, and except for some funny errors in loading some modules, thing work nicely.

At first I used the USB web server on a kingston usb stick, fast enough. But alter misplacing it one time (they are small 🙁 ) I now use the server on a 1tb USB 3.0 WD Passport drive. Also small, but not so easy to loose….

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *