Setting up Apache 2.4 and PHP under Cygwin (updated) (Quick & easy Cygwin Apache/PHP setup guide)

Note: This information is updated to include a recent change to Apache 2.4 for Cygwin. The old command to configure the Apache web server /usr/sbin/httpd2-config is now obsolete. The new command is /etc/rc.d/init.d/httpd install

Also note that the old Cygwin package apache2-mod_php5 is now called httpd-mod_php5

See below for full instructions.

1. Install Cygwin or Cygwin64

2. During install, select the following packages to install:

httpd libapr1-devel libaprutil1-devel httpd-mod_php5

If you want other optional PHP components, select those also. Here are a few popular examples:

php-fileinfo php-mysqli php-gd php-Archive_Tar php-bz2 php-zlib

3. After the install is finished, open a Cygwin terminal as Administrator and run:

cygserver-config (answer “yes” to prompt)

/etc/rc.d/init.d/httpd install

4. Start cygserver and httpd:

From within the same Cygwin terminal running as Administrator, run:

cygrunsrv -S cygserver

cygrunsrv -S httpd

5. Everything should be working. If there was an error at startup look at /var/log/httpd/error_log

6. Reload Apache with the new configuration:

from the Administrator terminal run:

/etc/rc.d/init.d/httpd reload

8. The document root is at:


References: Re: New apache 2.4 package

If something goes wrong, look at the logfile /var/log/httpd.log

I had the following error when trying to start httpd:

(20014)Internal error (specific information not available): AH00058: Error retrieving pid file /var/run/httpd/
AH00059: Remove it before continuing if it is corrupted.

What happened is that Apache probably crashed in the past and the PID file in /var/run never got deleted. This was solved by manually deleting /var/run/httpd/ and restarting httpd.