Installing Apache HTTPD web server with PHP and OpenSSL support on Windows box is not a trivial task nowadays. First, Apache site does not provide Win32 binaries for the latest HTTPD versions anymore. When you manage to find the place to get the binary itself, you get challenged with additional questions – which binary matches the OpenSSL version of your PHP installation and where to get VC redistributable it requires. This article aims to cover all those topics.
We are going to install Apache HTTPD 2.4.3 with PHP 5.4.11 (latest versions at the moment of writing) on Windows 2003 server.
Fresh Apache HTTPD binaries can be found on Apache Lounge site. Note that you will need the binary compiled with OpenSSL 0.9.8 to work with our future PHP installation. Also, there is a link to VC10 redistributable somewhere at the top part of the download page. Make sure to grab it and install on your Windows box before you start with Apache HTTPD installation and configuration.
Fresh Apache HTTPD distributions come as an archive and not as an installer, but don’t be afraid. Just extract the content of the package and move “Apache24” directory to the “C:” drive. You can start the web server by running “httpd.exe” from
“C:\Apache24\bin” folder. In the same folder you can find useful ApacheMonitor utility, which allows you to start and stop the server conveniently. I recommend to create a shortcut to this utility and place it to the startup folder (either yours or for all users). Also, Apache HTTPD can be set up to run as a service on system startup by executing
“C:\Apache24\bin\httpd.exe -k install” command.
The minimal web server setup includes changing ServerName in
“C:\Apache24\conf\httpd.conf” to be the real FQDN of your server. Now you can start the web service and verify that it is up and running.
The next step is to get latest PHP binary distribution for Windows from PHP for Windows site. There are “Thread Safe” and “Non Thread Safe” distributions; you will need the Zip archive of the Thread Safe one to run it inside the web server. The site mentions that it requires VC9 runtime, but VC10 you’ve installed for Apache HTTPD is even better. Note that some manuals instruct you to download Apache HTTPD module for PHP support separately, but there is no need for that – it is already included in recent PHP distributions.
Extract the content of the distribution archive to
“C:\PHP” folder and copy relevant “php.ini-something” to “php.ini”. Inside “php.ini”, uncomment “extension_dir” configuration option and the line that contains “php_openssl” extension definition. Don’t forget to add
“C:\PHP” to your system PATH variable, as some extensions (and OpenSSL among them) rely on it to find additional libraries.
To configure PHP in your web server add the following lines at the bottom of “httpd.conf” file:
# PHP 5 LoadModule php5_module "c:/php/php5apache2_4.dll" AddHandler application/x-httpd-php .php PHPIniDir "C:/php"
In addition, you may want to update “DirectoryIndex” directive to contain “index.php” also.
Now it is the time to restart Apache HTTPD server. Note that you will need to explicitly stop and start the server as two separate operations, as “Restart” button from the Apache Monitor does not reload the system properties. In order to verify your PHP setup, add the following “phpinfo.php” to your web server root:
<?php phpinfo(); ?>
You can verify the parameters of your installation by going to
http://localhost/phpinfo.php in the web browser. Don’t forget to remove this file after the test if this is going to be your production setup!
On remote server PHP errors will be shown as messages on the server console and not in your RDP window.
One thought on “How to install Apache HTTPD with PHP and OpenSSL on Windows”
I just can say: YOU SAVED MY LIFE
Thank you for yor awesome tutorial, Anton.
From now, you’re my superhero 😉