Apache
Compile-time options
SyntaxModules
- ./configure [option]*
Examples
- --prefix=<path> (where to install Apache)
- --enable-<module>[=shared] (add [DSO] module)
- --disable-<module>
- --with-port=<port> (the port number to listen to) (used for generating the httpd.conf file)
- --enable-module-name (add "mod_module_name")
- --disable-module-name (disable "mod_module_name")
- --enable-module-name=shared (add "mod_module_name" as a DSO module that can be loaded or unloaded at runtime)
- mod_cgi: CGI scripts (default: enabled)
- mod_include: Server side includes
- mod_so: DSO modules
- mod_speling: Correcting common URL mispellings
- mod_ssl: SSL/TSL (Secure Sockets Layer / Transport Layer Security) via OpenSSL
- mod_unique_id: Provides an environment
variable--UNIQUE_ID--with a unique identifier for each request
- mod_usertrack: User tracking (formerly mod_cookies)
- <?php phpinfo(); ?> (list currently loaded modules)
- <apache>/bin/apachectl -l (list static compiled modules)
Running apache (requires root
access)
- <path>/bin/apachectl [start, stop, restart]
- /etc/httpd/conf/httpd.conf
Running CGI scripts
- ServerAdmin admin@your-domain.com
- DefaultType [text/plain, application/octet-stream]
- DefaultLanguage en
- AddDefaultCharset ISO-8859-1
- DocumentRoot "/var/www/html"
- <Directory /> ... </Directory> # Default directory options
- <Directory "/var/www/html"> ... </Directory> # html directory options
- <Directory "/var/www/cgi-bin"> ... </Directory> # cgi-bin directory options
- <Directory "/var/www/icons"> ... </Directory> # icons directory options
- <Directory "/var/www/manual"> ... </Directory> # manual directory options
- <Directory "/var/www/error"> ... </Directory> # error directory options
- ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
- Alias /icons/ "/var/www/icons/"
- Alias /manual "/var/www/manual"
- Alias /error/ "/var/www/error/"
- If a different location is used for one of the above directories, the location needs to be changed in the following places:
- The <Directory ...> tag
- The DocumentRoot, ScriptAlias, or Alias value
- Set the permission for the script files to allow execution.
- AddType text/html .shtml
- AddOutputFilter INCLUDES .shtml
- For the relevant html directories add "Includes" to the "Options" directive
Enabling mod_spelingExamples
<Directory "/var/www/html">
Options Indexes FollowSymLinks Includes
</Directory>
- CheckSpelling [on, off] (default:
off)
- LoadModule php5_module modules/libphp5.so # Avoid redundant copies of this line.
- DirectoryIndex index.html index.php # Add index.php to the DirectoryIndex.
- AddType application/x-httpd-php .php
- AddType application/x-httpd-php-source phps # Syntax highlighting for PHP source-code.
- Often ISPs will block port 80, the default port for http; as a work-around for this, Apache can be set to listen to a different port number for http (in this example, port 8080)
- Listen 8080
- Firewalls often won't allow access to another local computer via an external IP address; due to NAT (Network Address translation), IP masquerading.
- With virtual hosting, a web site hosted on the local network can be accessed either by the internal IP address or by the external IP address.
Examples
NameVirtualHost 192.168.1.100 # Internal IP address
NameVirtualHost 11.22.33.44 # External IP address
<VirtualHost 192.168.1.100 11.22.33.44>
DocumentRoot /var/www/html
ServerName www.my-domain.com
ServerAlias my-server
</VirtualHost>
Parent URL:
category/network
Resources URL:
notes/apache/resources
Sources URL:
notes/apache/sources
Topic type:
Topic