Installing Apache 2.2, SSL and PHP5 on Windows 7

Having installed the new Windows 7 Release Candidate at home, I now need to re-install my Apache-PHP-SSL setup I sometimes use to make sure it works okay on the new OS. It seems no matter how many times I do this, it never seems to take under 2 hours - there’s always some file i haven’t copied or some setting I haven’t set in a conf file. It always seems to take ages of sifting through FAQs and documentation on the web referring to different versions of Apache, PHP and Windows. So here’s my reminder of how to do it for the future:

  • Download latest Apache 2.2 (the version including SSL) MSI installer from apache. Install with the usual defaults (server name and domain name = localhost) as service to run automatically.
  • Check its working by going to http://localhost
  • Download latest PHP5 MSI installer from Zend, run and tell it to install in C:\PHP-5
  • Edit httpd.conf:
    • Add LoadModule php5_module “c:/php-5/php5apache2_2.dll” to end of LoadModules.
    • Add:
      AddType application/x-httpd-php .php
      AddType application/x-httpd-php-source .phps
      inside IfModule mime_module tag
    • Add index.php to DirectoryIndex line
    • Set error logging as required
  • Edit php.ini:
    • check extension_dir is pointing to C:\php-5\ext
    • copy all dll files at the root of php directory into your system32 directory except those that is using php5*.dll
    • Edit error logging settings as required
    • edit session settings as required
  • Restart apache. Test with a phpinfo(); ?> page.
  • Download OpenSSL package for windows (Google for ‘OpenSSL for Windows’), hopefully you will find this.
  • Copy libeay32.dll and libssl32.dll to C:\Windows\System32.
  • Copy the executables (think you only need openssl.exe) and the openssl.cnf to C:\Program Files\Apache Software Foundation\Apache2.2\bin
  • Make sure you have a mod_ssl.so in C:\Program Files\Apache Software Foundation\Apache2.2\modules, if not find one and copy it there
  • Edit httpd.conf:
    • uncomment LoadModule ssl_module modules/mod_ssl.so
    • Make sure Include conf/ssl.conf is enabled in the IfModule mod_ssl.c tag.
    • Uncomment Include conf/extra/httpd-ssl.conf
  • Check C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-ssl.conf make sure you have Listen 443
  • Open command prompt, cd to C:\Program Files\Apache Software Foundation\Apache2.2\bin (where you copied the openssl executable. Note: Not sure why / if the executable needs to be here, but I got strange errors in the next steps if I ran it from System32)
  • type openssl req -config openssl.cnf -new -out my-server.csr.
  • Type openssl rsa -in privkey.pem -out my-server.key
  • Type openssl x509 -in my-server.csr -out my-server.crt -req -signkey my-server.key -days 1000. Respond to the questions at the command prompt.
  • Copy the generated file “my-server.key” from the Apache Group/Apache2/Bin directory to the Apache Group/Apache2/conf directory
  • Copy the generated file “my-server.crt” from the Apache Group/Apache2/Bin directory to the Apache Group/Apache2/conf directory
  • Edit C:/Program Files/Apache Software Foundation/Apache2.2/conf/extra/httpd-ssl.conf
    • Change SSLCertificateFile to “C:/Program Files/Apache Software Foundation/Apache2.2/conf/my-server.crt”
    • ChangeSSLCertificateKeyFile to “C:/Program Files/Apache Software Foundation/Apache2.2/conf/my-server.key”
  • Restart apache.
  • go to https://localhost:443 to test SSL.

posted 2 years ago