microapache.png (24029 bytes)

Home Page
Tips and Tricks Page

 

This project is shared with the community at in good faith and at no cost and using whatever free time I have available. Sorry but I do not have time to give one-to-one support for Apache Webserver. If you use MicroApache then please link to this page or mention MicroApache! Please see the licensing conditions for each component

 

 

 

MicroApache Installation and Configuration
  • You do need to unzip the program and set your document root unless you really do want to share the whole drive.
  • Just unzip to a convenient folder and run MAPACHE.EXE or click GO.BAT to start your server (launch13x.exe for Apache 1.3.x)
    If you need a freeware ZIP program try 7-Zip
    Ensure you don't have Apache already running on the same "port" (8800) before you run MicroApache
  • You may delete the example CGI apps in /cgi-bin if you wish. TailCGI.exe may be useful to monitor the server but you should see TailCGI and set up Apache security access to it if used on a live website.
  • If you wish to test PHP copy phpinfo.php into the webroot of your configured website and "view" the file using your browser.
    **** Ensure you DELETE phpinfo.php after testing and before you make your server live on a public network! ****
  • Try the Tips and Tricks Page for more information and please see the FAQ section below
    See the Apache Win32 Read-me-first page. For Apache 1.3.x see this Windows readme
  • Bear in mind that, by default, MicroApache will probably share the whole drive or device it is running from so take care if you intend to create a "public-facing" webserver!
  • Note that by default the server directory is not browsable. You'll have to put any included example code into a browsable folder

Security Notes - Using MicroApache on Other Than "Safe" Networks

Please note that this product is intended primarily for sharing the contents of floppy disks, USB sticks and optical media within a "safe" local area network such as running a private Wiki (such as DokuWiki) or private PHP "sandbox". Given proper configuration it can be used in a net-facing environment but you should not put MicroApache live on the internet without knowing what you are doing and without making appropriate changes to the configuration file. Such changes would include correctly setting a restrictive document root and ensuring all recommended "safe" options have been set for Apache, PHP, or any other bundled module. Attention should also be given to Windows user-account permissions to prevent breaches of security on the host PC. If you adapt or include MicroApache in any other project then be sure to address these issues.

Check out Apache Security (O'Reilly) and the official Apache Security Tips page.

MicroApache  - General Release Notes

  • Licence: Please see the Licensing Information section
  • Configuration Tips: Check out the Tips and Tricks Page for more information on configuring Apache safely
  • Source Code: The source code and build is unchanged. To comply with the GPL licence you can obtain the source code from http://www.apache.org or request a download link on this site by email. (note that bandwidth is very limited on this site - about 180kbps - that's BITS per second not bytes!)
  • Physical location: The floppyweb-distro httpd.conf is configured to run from drive B: Edit /conf/httpd.conf and change the drive to whatever drive you intend to run on. Even if you have a floppy drive it may still be a good idea to run from drive B. You can also run from a floppy image using VFDWin floppy drive emulator for NT/2k/XP only. You can then run the floppy image from a ramdisk for maximum speed. If you run from an alternate drive you will need to edit all config files and change all instances of drive B: to the drive you are using.
    Later distros are configured to be "driveless" by default and share the root of the server's drive. This is specifically intended for use with optical media and USB or mini hard-drives
  • Ports: It is important to note that the port is set to 8800 to ensure that you can run Micro-Apache on a PC or server which already has a webserver (port 80) or proxy server (8080). To change this edit the Listen directive. If you're trying to connect but having problems then remember to add a colon and 8800 to the end of your URL (e.g. http://localhost:8800)
  • Executable Naming: apache.exe is purposely renamed as mapache.exe so you can dual-host it with a other currently-installed copies of standard Apache server and use "kill.exe", "tskill.exe", killproc or apachekill to end the Micro-Apache process separately from any standard Apache processes. Bear in mind that you still need to use unique ports and cannot use port 80 (HTTP) if this is already in use on your workstation.
    Update: As of December 2007 I have provided a freeware/open-source task-killer to stop MicroApache called ApacheKill which is freely distributable with no restrictions. The "C" source code is available here.
  • Tweaks: It is recommended that you ensure you set Win32DisableAcceptEx On in your httpd.conf. (Yes it also works without the "On bit - don't email and tell me unless you want to prove you're a complete geek!).
  • Modules: In Windows the Dynamic Shared Object (DSO) modules are actually standard Win32 DLLs. Didn't know that, huh?. Well, it's true. This means that you can rename them from SO to DLL and persuade UPX to "pack" them down to about half their original size. They work just the same and makes perfect sense once you know about dynamic linking.
  • Dynamic Compression: Mod_deflate is enabled as standard as this module performs exceptionally well in Apache and negotiates ok on all modern browsers. Browsers which don't send the "accept encoding" request are sent an uncompressed page automatically. This can reduce the size of web pages by over 50%. This will help Apache home servers hosted on an asymmetric standard broadband line where the uplink speed is usually about a 10th of the downlink speed. For example, I have 2Mbit broadband and the uplink is about 200kbps so compression is really important, particularly on uncompressed material such as large web-pages. mod_deflate and Apache will also cache compressed pages to reduce CPU use.
    Test to see if your pages are successfully compressed using this page
  • USB Key Drives: Someone managed to squeeze Win98 into a 128mb USB drive. When linked with Micro-Apache and a little more use of UPX you could have a bootable webserver on a pen drive!. Please let me know if you manage this and I will link to your project.
  • Recommended FTP Daemon: Use SlimFTPd from Whitsoft - 3.17 or higher
  • Modules included: A useful selection of basic modules is included and configured in the httpd.conf file (all 2.0.61 modules downloadable here)

    mod_access
    mod_alias
    mod_autoindex
    mod_cgi
    mod_deflate
    mod_dir
    mod_mime

    mod_env
    mod_setenvif
  • PHP Security: Please ensure you configure your PHP.INI for maximum security - See security advice at www.php.net
  • Running as a Service: This isn't really something suited to use with removable media such as floppy disks, USB pen-drives or optical media. The reason is that the service-control-manager (SCM) creates registry-entries which include PATH information regarding where the service executable (EXE) is currently located. This may change with removable media. These changes of path may also make it difficult to remove registered services if you don't have the original service located in the correct path any longer. However, for the brave I am working on a set of SCM batch files.
  • Using ApacheMonitor: This is a Service Control application which monitors Apache when installed as service and not when running in EXE mode. (See above for reasons why Service Mode isn't recommended). For this reason the ApacheMonitor utility can't really be used with MicroApache

Installing MicroApache on USB Drive With The PortableApps Menu

You can install MicroApache on your USB drive and use Apache to share the whole (or part of the) contents of the drive or any website held on the drive in a matter of minutes. Once configured you can plug in your drive and have your site online in seconds. I have just installed it to my own keydrive and the installed footprint including PHP 4.4.4 is 1MB with deletable demo apps taking a mere 60kb of that 1mb.

You need to extract the supplied ZIP file containing the "apache" directory and all subdirectories underneath (into) the .\PortableApps\ folder on your keydrive (it may be installed in different levels depending on whether you share with say a U3 application launcher. Extract to say \PortableApp\Apache\  Once extracted, the PortableApps launcher program will automatically "pick up" and add the Micro Apache EXE (and any other optional EXE found) to the menu.

Before you can launch the application you may need to configure the httpd.conf file and change the ServerRoot and DocumentRoot entries to suit your requirements. Again, these may vary depending on the drive letter in use or what level you install your master "PortableApps" folder to. If you launch MicroApache and the console window exits immediately you most likely have a bad path entered.

Note that "Apache Stop" will only halt MicroApache (mapache.exe) and will not affect any currently installed copy of standard Apache (apache.exe)

Portable Apps Menu

MicroApache and ApacheKill showing in the PortableApps menu - click for bigger image. ApacheStop will only affect MicroApache

Assuming you have the most complex setup of, say, a combined U3 setup with F:\System\Apps\PortableApps on your USB key-drive with MicroApache installed to F:\System\Apps\PortableApps\Apache\ - and your  in this case you will need to enter the following in your HTTPD.CONF (note that you MUST use Linux-style forward-slashes "/", and NOT Windows/DOS back-slashes "\"). Note that versions of Apache may vary in how well they accept "driveless" path parameters.

ServerRoot PortableApps/Apache
DocumentRoot /Documents

or, say -

ServerRoot PortableApps/Apache
DocumentRoot /

or, say

ServerRoot PortableApps/Apache
DocumentRoot /Documents/Webroot

Note you can change the document root to suit whatever you deem to be appropriate to share. Bear in mind when you connect that you will need to specify the port (8800 is usually set in the default MicroApache config). Note particularly that Apache will run in console mode rather than installing as a service on your local machine so you will see an icon, when running, on the taskbar which can be maximised and minimised.

Stopping and Starting MicroApache

  • You can start MicroApache by clicking the "Apache HTTP Server" icon for mapache.exe in the Portable Apps Menu.
  • To stop MicroApache safely, maximise the MicroApache console icon and press CTRL+C in the Apache server console window. MicroApache will halt in a few seconds once all processes have been shut down.
  • If you wish to be able to "terminate" Apache conveniently from the Portable Apps Menu then download ApacheKill.exe (18kb) and copy to your MicroApache install folder (usually "\PortableApps\Apache"). This program will automatically be included by the PortableApps menu when you load it as an item called "Apache Stop (MicroApache)".
    When you click on this icon it will terminate any process called "mapache.exe" on your PC. Since the MicroApache binary is purposely named to be different to the standard Apache HTTP Server binaries this will specifically affect ONLY copies of MicroApache you have running on your PC. Please note that this app may need to terminate multiple instances of mapache.exe which have been launched and will therefore not check to see if you have other copies of MicroApache running (with other multiple instances). i.e. if you use ApacheKill then any and all copies of MicroApache on that PC will be terminated.
  • ApacheKill is a slightly modified version of freeware KillProc.exe which is configured in source-code, when run, to terminate all instances of mapache.exe by default with no other intervention. It is identical to using the full command -  "KillProc.exe mapache.exe -all
    Note that you can use ApacheKill with parameters to kill other processes or use KillProc to kill mapache.exe.
    Use ApacheKill /? or KillProc /? for the help screen and information on how to use.

Security Configuration: As always, you MUST double-check your PHP configuration in PHP.INI to be sure security matches your needs and if you add MySQL also check your SQL and PHP security. This is VITAL if you intend to run your server outside a friendly "home network" in a public-facing internet situation.

You can download the excellent PortableApps menu from www.portableapps.com or visit the Pensuite website

The PortableApps site also has a version of Xampp and Xampp lite for Win32/USB but this is quite bulky at 25Mb/17Mb (compressed) if all you need is a simple micro-webserver which can share a the files on your USB or a website hosted on it.

Wish List for the PortableApps Menu:

  • Configuration options either by right-click of file entry for each menu option (i.e. "Properties") which permit say mapache.exe to be launched with the -w switch and minimised as an icon
  • A "send-to-tray-on-launch" feature would be really nice
  • The ability to tick a property for any or all programs on the PortableApps menu to auto launch when the app menu launches. This would then permit the Apache server to auto-run on insertion (unless insertion is "grabbed" by the U3/SmartStuff menu)
  • U3-style encrypted partition loading on insertion with password prompt as per the U3 loader. Maybe using TrueCrypt?
  • Up/down arrows scroll the menu panel

Page Top


MicroApache 1.3.x Auto-Launch and Configuration Utility

Since there are problems with Apache 1.3.x handling "drive-less" configuration entries for DocumentRoot such as "/" - and given that there is a specific desire to share the entire media from "root" ("/") when using USB sticks  -  I have written a small binary which will both create a configuration include stub file and launch MicroApache 1.3.x in a single-click. This will be most useful for launching MicroApache 1.3.x via the PortableApps (TM) menu system.

At present this is a quick and hard-coded utility which expects to find the mapache.exe binary for Apache 1.3.x in the same folder as the utility itself - and the Apache conf/ directory underneath it's current location when launched. I could easily make this configurable via an INI file to add configuration more flexibility when launching using the PortableApps Menu. However, this is just a proof-of-concept.

Portable Apps Menu

The PortableApps menu showing launch13x.exe (top) as "Apache 1.3.x Dynamic Launch Config" with apachekill.exe as "Apache Stop (MicroApache) below

To use the application (currently named launch13x.exe for want of a better name!) - you need to specify NO DocumentRoot, ServerRoot or ScriptAlias in your httpd.conf - but instead add an "include" statement which reads a file called "docroot.conf" from the server's conf/ folder. Once run, launch13x will query the current drive letter, create the stub include file "docroot.conf" with a root which includes the correct drive letter and full-path required by Apache 1.3.x's slightly less-flexible code - it will then launch mapache.exe from the same folder as itself. This ensures you will (or should) always have the correct drive letter specified for your USB stick, DVD or micro-hard drive you are running MicroApache from and don't inadvertently share some other location!. If you don't want to share the entire media then please do-not launch MicroApache using this utility. Instead properly configure your httpd.conf file.

In your httpd.conf file make sure you use (or leave intact) the entry -   include conf/docroot.conf

For ease of programming, the Windows START command is used to launch with the following parameters. Due to this Windows 9x and ME may not be supported as the START command differs slightly. The path specified by /D is wrapped in double-quotes to prevent paths with spaces from failing to launch.

  • START /MIN /D"<mapache.exe-full-path>" mapache.exe

You can run launch13x.exe from the command-line or using Windows Explorer - it also accepts the switch /V to produce Verbose output

If this proves successful for Apache 1.3.x I may make it more configurable (e.g. specify DocumentRoot paths such as /Documents in an INI file)

Remember: MicroApache is specifically intended to share the ENTIRE contents of the media it was launched from!

No modules are included with the 1.3.x distro but you can download the relevant modules as a single ZIP file. These have been renamed as *.DLL and compressed using UPX.

An example "driveless" stub config file created automatically by launch13x.exe v1.01 is as follows...

# Apache include file: docroot.conf
# This file was dynamically created by D:\MicroApache-1.3.37-no-PHP\launch13x.exe - (v1.01)
# Created on: Mon Dec 31 17:46:20 2007
# Purpose: To share the entire root of a drive where the drive letter is not known
# Include into your httpd.conf using "include docroot.conf" in the httpd.conf file
# If you have problems check the date/time this file was created
ServerRoot D:/Apache
DocumentRoot D:/
ScriptAlias D:/Apache/cgi-bin/
  • Launch13x is:
  • For use ONLY with MicroApache 1.3.x (won't work with standard/non-micro Apache unless I make it more configurable)
  • Tested with the PortableApps.com Menu December 2007
  • The program is approximately 28kb (compressed EXE) - Download here (MicroApache 1.3.x only) - Please use the contact form for bug-reports
  • Bundled with MicroApache 1.3.37+ - Use PortableApps menu item "Apache 1.3.x Dynamic Launch Config" to configure and launch

Web-Compression

  • Mod_deflate is not available for Apache 1.3.x/Win32 as far as I am aware and the author has abandoned the project.
  • You can enable seamless GZIP compressing for PHP-generated content using this method (note this only applies to PHP-generated content)
  • You can also enable in-line compression of PHP code using the ob_start("ob_gzhandler"); method - see here
  • Test to see if your pages are successfully compressed using this GZIP test page

Launch13x.exe Updates

  • Launch13x.exe is used to launch MicroApache 1.3.x and address some of the shortcomings in the Apache code.
  • Launch13x.exe also enables control as a true "portable app" from within say the PortableApps.com menu software
  • This was modified from v1.03 to deny access to the server root via conf\docroot.conf. This is needed since you cannot deny the "current" folder using a <Directory "."> directive in Apache 1.3.x (It does not work as with later versions). You can override this behaviour by using the switch /NoDenyServerRoot.
  • Also modified from v1.02 to clear out any existing PID file from the logs directory before launching. Override this behaviour using the /NoClearPID switch.
  • Use launch13x.exe /? for info

IMPORTANT Ensure you "harden" MicroApache security before using on a public-facing server

Page Top


IMPORTANT: PHP Configuration and Security - PHP.INI

The supplied configuration should work for a very basic test setup. If you intend to put a live webserver on the internet you should always read and apply any recommended security settings. You can find the PHP documentation at www.php.net. In particular pay attention to remote file includes or shell execution etc. You may find that certain software such as BB software will only work with lowered security settings. Always set high when your site goes live, then lower carefully.

Please note these comments from the guys at PHP. This is the default settings file for new PHP installations.; By default, PHP installs itself with a configuration suitable for  development purposes, and *NOT* for production purposes. For several security-oriented considerations that should be taken before going online with your site, please consult php.ini-recommended and http://php.net/manual/en/security.php

Also ensure you at least set the following option in PHP.INI

  • register_globals=OFF  ; Disable exposed global variables

See see this advice re: remote file inclusion/hacking

See the PHP FAQ

IMPORTANT Ensure you harden MicroApache security before using on a public-facing server

Page Top


MicroApache Configuration - Server Root

Please note that ServerRoot can be omitted if desired to keep MicroApache as "portable" as possible, in which case the following strategy is used by Apache to determine the server root - these switches follow the executable on a command line (mapache.exe) ,,,

  • A ServerRoot directive via a -C switch
  • The -d switch on the command line
  • The current working directory
  • A registry entry, created if you did a binary install (not recommended for a portable install)
  • The server root compiled into the server.

The above does not apply of you modify the configuration to use the -f or -n switch

For an in-depth discussion of general Apache configuration see the Apache Documentation pages

IMPORTANT Ensure you "harden" MicroApache security before using on a public-facing server

Page Top

 

Page last updated on 25 February 2021 - This page is optimised for 1024x768 or higher screens

do not click this link