WAMP/Apache
Views:
(Part of the WAMP documentation.)
Contents |
Installation
You can download the latest stable version from http://httpd.apache.org/download.cgi - installation is carried out by a setup program and it's pretty self explanatory.
Configuration
Directory Structure
Create a directory for the web site(s) such as "C:\Apache_Sites" and sub-directories for each virtual host.
C:\Apache_Sites\<host_name>\public C:\Apache_Sites\<host_name>\conf
E.g. C:\Apache_Sites\www_example_com\public and C:\Apache_Sites\www_example_com\conf. The "public" folder will be the document root for the web sites, other per-site folders can be created in C:\Apache_Sites\<host_name>\ as needed. "conf" will hold the web server configuration for that particular virtual host.
Basic Configuration
The main apache configuration file is @%PROGRAMFILES%@\Apache Software Foundation\Apache2.2\conf\httpd.conf
Some of the default settings are probably not necessary and can be turned off or tuned down for a small increase in performance or security. They can be disabled by commenting them out from the configuration files with a # at the start of the line.
Some modules are loaded by default and should be commented out:
LoadModule autoindex_module modules/mod_autoindex.so LoadModule cgi_module modules/mod_cgi.so LoadModule include_module modules/mod_include.so LoadModule isapi_module modules/mod_isapi.so
Mod Rewrite is pretty popular and should be un-commented:
LoadModule rewrite_module modules/mod_rewrite.so
Some other things that will need to be set to match up with your particular server
ServerName host.example.com:80 ServerAdmin webmaster@example.com
Some additional settings are in other files that can be pulled in to the main configuration:
Include conf/extra/httpd-vhosts.conf Include conf/extra/httpd-default.conf
Apache Default Configuration File httpd-default.conf
@%PROGRAMFILES%@\Apache Software Foundation\Apache2.2\conf\extra\httpd-default.conf
There are a couple of settings in the apache "default" configuration file that should be changed...
ServerTokens Full
...should be set to...
ServerTokens Prod
ServerSignature On
...should be set to...
ServerSignature Off
Apache Virtual Host Configuration File httpd-vhost.conf
The default apache virtual host configuration is only a basic example. If you're going to have a number of different virtual hosts then you should replace it with this:
NameVirtualHost *:80
<VirtualHost _default_:80>
ServerName default
</VirtualHost>
# Include a configuration file for each virtual host
# Include c:/Apache_Sites/www_example_com/conf/vhost.conf
Include c:/Apache_Sites/www_example_com/conf/vhost.conf
Per Virtual Host Configuration vhost.conf
This is an example configuration file that could be used for a web site available at the address www.example.com. The file would be placed in C:\Apache_Sites\www_example_com\conf\vhost.conf
<VirtualHost *:80>
ServerName example.com
RedirectMatch permanent (.*) http://www.example.com$1
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot C:/Apache_Sites/www_example_com/public
ServerAdmin webmaster@example.com
# NOTE: You *must* make sure the directory has been created before restarting
# the web server
CustomLog C:/Apache_Sites/www_example_com/logs/access.log combined
ErrorLog C:/Apache_Sites/www_example_com/logs/error.log
<Directory "C:/Apache_Sites/www_example_com/public">
Options Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Applying Configuration Changes
It's really important to run a test on the configuration files once they have been changed - any errors found when starting or restarting the server will cause it to fail to load.
To check the configuration is good, run the following command:
C:\ > "%PROGRAMFILES%\Apache Software Foundation\Apache2.2\bin\httpd.exe" -t
if any errors are found, the file name and line will be shown, with a terse explanation of the problem.
If there were no problems found, you can restart the server (with out kicking-off any current visitors) using the following command:
C:\ > "%PROGRAMFILES%\Apache Software Foundation\Apache2.2\bin\httpd.exe" -k restart
You might like to add the Apache directory to your path to save on typing ;)
Permissions
Create a new local user "APACHE2" and add them to the Users group. In Services.msc edit the properties for the Apache2.2 service and change the user account to APACHE2.
Make sure the APACHE2 user has write permissions to %PROGRAMFILES%\Apache Software Foundation\Apache2.2\logs. If there have been changes to permissions for %PROGRAMFILES% then also check for read and excute permissions for the apache installation folder, plus PHP and FastCGI installation folders.
Restart the Apache2.2 service.
The Users group should not have access to the directory structure of the web site(s) by default. The APACHE2 user account should be granted read and execute permissions for this directory structure.
- Remove all rights for the Users group from C:\Apache_Sites\
- Add RX for the APACHE2 user to C:\Apache_Sites\
- Add W for the APACHE2 user to C:\Apache_Sites\www_example_com\logs
