These tools are simple Cygwin shell scripts used to install, uninstall, start, stop and monitor the Apache
WebServer as a service on
CygWin - useful for
TWikiOnCygwin where you are running Apache for Cygwin (
CygwinApache) (not Apache for Win32 (
WindowsApache).
The Cygwin
cygrunsrv tool doesn't completely work when starting/stopping Apache as a service, for reasons that aren't clear but may be because Apache puts itself in the background (which is not expected of a service). (
UPDATE: see below for a fix.)
Sometimes Apache under Cygwin won't start as a service after a system reboot - check
/var/log/apache.log for any errors relating to the service not starting, as sometimes such messages are spurious (or just do
apachectl start to test-run it as a normal process). If one or more process IDs are listed by
srv-apache-start, Apache has started OK.
The scripts require
pskill.exe from the
Sysinternals pstools package (freeware)
- this is a tool that lets you kill an Apache process even though it was started as part of an NT/Win2000 service.
The scripts should be self-explanatory, let me know if you have comments.
You should install the scripts and
pskill in
/usr/local/bin, to keep them out of the way of Cygwin upgrades.
--
RichardDonkin - 29 Mar 2002
I got Cygwin Apache working as a service on Windows XP Home Edition (SP2) as follows:
- Edit
/etc/apache/httpd.conf to include User Fred, where Fred is a user with local Administrator rights ('computer administrator' in XP Home Edition).
- Run the following command to install Apache as a service - the
-F is the option to keep Apache running, supersedes the obsolete -k option that you may find mentioned elsewhere
cygrunsrv -I "Apache-Cygwin" -p /usr/sbin/httpd.exe -t auto -a '-F'
- Start the service - you can use the normal Windows Services folder under Control Panel, or
net start Apache-Cygwin, or Cygwin's cygrunsrv -S Apache-Cygwin
The service should start automatically on boot. You might need to redo the installation of the service to add service dependencies to the
cygrunsrv -I line - e.g.
--dep 'Network Connections' might help on XP. However, I have not tested this.
Scripts attached here have not yet been updated.
--
RichardDonkin - 08 May 2005