by Lars Vogel

Follow me on twitter

Lars Vogel on Google+

Apache HTTP Server

Lars Vogel

Version 0.3

27.05.2011

Revision History
Revision 0.1 21.04.2010 Lars
Vogel
created
Revision 0.2 - 0.3 27.05.2011 - 28.05.2011 Lars
Vogel
bug fixed and enhancements

Apache HTTP

This articles contains some information about handling the Apache HTTP server.


Table of Contents

1. Apache HTTP
1.1. Commands
1.2. Configuration Files
1.3. Apache Configuration via .htaccess
1.4. Performance - Turn on gzip compression
2. Thank you
3. Links and Literature

1. Apache HTTP

The following describes the configuration files and commands for the Apache HTTP webserver on Ubuntu.

1.1. Commands

Table 1. 

Command Description
/etc/init.d/apache2 -l List the available modules of Apache
/etc/init.d/apache2 restart Restart the apache2 webserver

1.2. Configuration Files

The main configuration file for the Apache Http server is /etc/apache2/apache2.conf.

Apache HTTP can be running in different modes. These modes determine how the web requests of users are answered. These modes are called Multi-Processing-Module (MPMs). The selected mode is compiled into the server and can be seen via the command "apache2 -l".

You find several sections in apache2.conf for configuring the different modules. Configure only the module which your server is using. For example if you see the modul "prefork.c" then you only need to configure the "mpm_prefork_module".

Table 2. 

File Description
/etc/apache2/apache2.conf Configuration File for Apache2
/var/log/apache2/error.log Error log for Apache2

1.3. Apache Configuration via .htaccess

Use the file ".htacess" to configure certain behavior of Apache HTTP. One major application of this file is to redirect URL to other URL's.

The following .htacess file reroutes that http://vogella.de to http://www.vogella.de. It also redirect access to a certain webpage (/articles/SpringFramework/article.html) to another webpage via a 301 redirect. The 301 redirect will tell search engines that this side has moved and is the recommended way to move webpages.

				
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.vogella\.de$
RewriteRule ^(.*)$ http://www.vogella.de/$1 [L,R=301] 
redirect 301 /articles/SpringFramework/article.html http://www.vogella.de/articles/SpringDependencyInjection/article.html

			

1.4. Performance - Turn on gzip compression

To optimize the download time of your webpages you can turn on gzip compression. This require the Apache module "mod_deflate" which can be installed by the following command:

				
a2enmod deflate 
/etc/init.d/apache2 restart

			

The compression can be activate via your ".htaccess" file.

				
# compress all text & html:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

			

2. Thank you

Please help me to support this article:

Flattr this

3. Links and Literature

http://httpd.apache.org/ Apache HTTP Homepage