Tuesday, March 23, 2010

Installing Apache HTTP server 2.2.8

Apache HTTP server is an open source web server.

Prerequisites
None

Steps
  1. Download package from Apache HTTP server website, http://httpd.apache.org/
  2. Uninstall any previously installed version of Apache and delete all the folders where Apache was installed.
  3. Ensure no service is listening to port 80. Stop/disable any that are, e.g. IIS, Skype. This isn't mandatory as the port that Apache will listen to can be updated after the installation is done.
  4. Run the installer.
  5. On the Server Information page, put in “localhost” for the network domain and server name. Put anything for the administrator's address e.g. admin@localhost.com. Leave the default selection to install for all users to port 80 as a service.
  6. Click Next and choose Typical Installation
  7. Click Next and change the destination folder to C:\Apache instead of the default installation path. This is to avoid permission inconveniences when making updates if one installs to the Program Files folder.
  8. The Apache Service Monitor [feather icon] should show on the task bar after installation is complete.
  9. Navigate to http://localhost. If the page says “It works!”, then installation was successful.

To change the port on which Apache should listen e.g. if IIS was already listening on port 80 and it isn't desired to change this, update the httpd.conf file in the conf directory within the Apache install path. Change instances of port 80 to another unused port e.g. 8080. The editor needs to be run as administrator to be able to save the changes if installation was done to the Program Files folder. Restart Apache using the Apache monitor and navigate to http://localhost:8080 to confirm the changes work OK.



Setting up SSL (for https access)
  • Create an environment variable named OPENSSL_CONF with the value C:\Apache\conf\openssl.cnf
  • Open a command prompt window and navigate to c:\apache\bin
  • Type the following command sequence
openssl genrsa -des3 -out server.key 1024
  • Provide a pass phrase when prompted (4-500 characters)
openssl rsa -in server.key -out server.pem
openssl req -new -key server.key -out server.csr
  • After providing the passphrase, provide the requested information. Set the common name to localhost (or the fully qualified domain name for the web server). The other fields can be set as appropriate or left blank. Leave the extra information fields blank.
openssl x509 -req -days 999 -in server.csr -signkey server.key -out server.crt
  • Copy the files server.crt and server.pem from the c:\apache\bin folder to the c:\apache\conf folder

  • Edit the c:\apache\conf\http.conf file
  • Uncomment the line for loading the ssl module
LoadModule ssl_module modules/mod_ssl.so
  • Uncomment the line that includes ssl configuration
Include conf/extra/httpd-ssl.conf
  • Edit the c:\apache\conf\extra\httpd-ssl.conf
  • Set the SSLCertificateKeyFile attribute
SSLCertificateKeyFile "C:/Apache/conf/server.pem"
  • Also ensure the SSLCertificateFile attribute points to the server.crt file just created
SSLCertificateFile "C:/Apache/conf/server.crt"
  • Restart apache and try to access a website via https e.g. https://localhost/myapp/ (no need to specify the port number e.g. https://localhost/443/myapp)

No comments:

Post a Comment