5

I'm trying to get an Apache server running on my Cygwin setup to follow the Java Ranch Cattle Drive tutorials online (basically, to learn Java EE web page development that uses a MySQL back end.)

I used the Cygwin Setup program to install httpd (which is how I installed most other dev tools I use on cygwin) and it says install complete, yet when I run 'httpd' it cannot find the command. It also appears the expected install directory (/usr/local/apache...) doesn't exist.

Does anyone have any experience using this setup, and if so, you could walk me through the initial steps of getting the server up and running and getting a browser to display the server's default page?

To keep answers focused, I didn't want to discus the drawbacks of running Apache on a Windows system - this is just for learning purposes. Thanks in advance.

dvanaria
  • 6,593
  • 22
  • 62
  • 82

4 Answers4

5

Looking at the Cygwin Package Listing for httpd, you can see that the executable is installed under /usr/sbin.

So, if /usr/sbin is not on your PATH (it isn't on mine, not by default anyhow), you would actually run:

/usr/sbin/httpd

And btw, if you would like to list the files installed for a certain package, you can use cygcheck:

cygcheck -l httpd
buruzaemon
  • 3,847
  • 1
  • 23
  • 44
2

cygrunsrv -I Apache -p /usr/sbin/httpd -a "-X"

This will solve the problem. This assumes you already have cyrunsrv set up. The reason httpd fails with cygrunsrv if you leave out the -X is that the process disconnects from the terminal and cygrunsrv considers that a failure. The -X option for httpd is the debug or terminal mode.

2

I couldn't find any detailed information on how to get Apache working on Cygwin, so here it is if someone's interested:

  • Install the httpd-* and httpd-mod_* packages you need. Note that the packages named "Apache" are deprecated. You need the ones named "httpd" (which are actually Apache).
  • Install cygrunsrv (normally this is a default Cygwin package)
  • Run /usr/bin/cygserver-config as admin. This is needed because Apache requires an IPC server running.
  • Open services.msc, then go to the CYGWIN Cygserver. Right-click on it and start it. If you don't do this, you'll probably get errors like "AH00023: Couldn't create the proxy mutex".
  • Finally, start Apache by running /usr/sbin/apachectl restart

Config is in /etc/httpd/.

alex.b
  • 4,547
  • 1
  • 31
  • 52
laurent
  • 88,262
  • 77
  • 290
  • 428
0

Some information about running Apache on Cygwin:

http://httpd.apache.org/docs/1.3/cygwin.html

http://www.issociate.de/board/goto/895433/apache2_does_not_start_in_cygwin.html

http://www.cygwin.com/ml/cygwin-apps/2005-02/msg00085.html

Personally, I would recommend installing WAMPServer or other WAMP stack and do it that way. There is no difference, except that you'll need to control Apache through Windows commands [net start, net stop], not Cygwin's ones.

Tomasz Kowalczyk
  • 10,472
  • 6
  • 52
  • 68
  • Use WAMP, but know this: accessing native windows-built MySql from tty-reliant terminals like RXVT does not work in Cygwin. http://stackoverflow.com/questions/5768019/command-line-mysql-from-xampp-in-cygwin – Myer Jun 07 '11 at 01:20
  • +1 for using WAMP... came here looking for Cygwin/Apache help and ended up going with WAMP and its been super easy. – David Hergert Oct 05 '12 at 16:23