Tag Archives: Windows 7

Install Apache web server on Windows 7 with php

Here’s the steps I followed to install Apache web server on Windows 7 with php.

I have been running an application on a Windows XP PC for years.  The application was web enabled on top of Apache for Windows.  This note captures the steps to move my application over to my Win7 PC; since I’ve done this before, this should be easy.  Well no, I had some bumps and these notes are to help me for next time.

For starters, I decided to follow the nice how-to found at Badprog.

1. Install Apache httpd.

  • Download from here
  • For Network Domain, I entered my domain name.
  • For Server Name, I entered my private IP address, 192.168.x.x
  • I verified my setup, by trying http://192.168.x.x.  Look for “It Works!”

.2. Install PHP

  • Download from here. I used VC9 x86 Thread Safe (2012-Nov-21 21:22:38), v5.4.9
  • unzip and copy to C:\Program Files (x86)\PHP
  • rename folder to php-5.4.9

3. Configure

  • C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf
 LoadModule php5_module "C:/Program files (x86)/\
 PHP/php-5.4.9/php5apache2_2.dll"
 LoadModule ssl_module modules/mod_ssl.so
 LoadModule rewrite_module modules/mod_rewrite.so
 AddType application/x-httpd-php .php
 # for .htaccess
 AllowOverride All
 # for dir_module
 DirectoryIndex index.php index.html
 <Directory "C:/public_html">
 Include conf/extra/httpd-ssl.conf
 # at end of file:
 PHPIniDir "C:/Program Files (x86)/PHP/php-5.4.9"
  • In same directory create a .htpasswd file
  • In c:\public_html, create file phptest.php
 <?php
 phpinfo();
 ?>
 
  • create file .htaccess
AuthUserFile "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/.htpasswd"
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic require user j****k
  • verify http://192.168.100.153/phptest.php
  • C:\Program Files (x86)\PHP\php-5.4.9:
    • rename php.ini-development -> php.ini
 date.timezone = "America/Chicago"
 ForceType application/x-httpd-php

Key stuck point for me when setting up my Apache Web Server on Windows 7:

Remember: restart httpd with “Run as Administrator” !!

Restart - must run as Administrator

Whenever the httpd.conf file is changed you need to restart the Apache web server.  Just selecting and running Restart doesn’t work, except if you run it as an Administrator. From the Start menu, find Restart, the right-mouse click it, and select “Run as Administrator.” It took me two hours to figure this out.  Since my old installation was on Windows XP, I never had this issue.

4. Configure SSL

  • edit file: “C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/extra/httpd-ssl.con”
 DocumentRoot "c:/public_html"
 Servername cisco163.kozikfamily.net:443
 SSLCertificateFile "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/cisco163_kozikfamily_net.crt"
 SSLCertificateKeyFile "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/cisco163.kozikfamily.net.key"
 SSLCertificateChainFile "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/cisco163_kozikfamily_net.ca-bundle"

#Because of syntax error on Windows:
SSLSessionCache "shmcb:C:/Progra\~2/Zend/Apache2/logs/ssl_scache(512000)"