Apache server

1°) Download & Install

The purpose of this guide is to install the APACHE server. The APACHE web server has been choosen because it is the most used at the moment. In addition, it is free and its source code is available on the site: http://www.apache.org.

Warning!! the OVH system already has the configuration. You can find too the standard scripts of compilation on our server:

  • ftp://ftp.ovh.net/made-in-ovh/patch

1.1 Go & Search for the sources on the web site

The version on which we are going to work in this guide is the 1.3.4. You can find it on the site http://www.apache.org
You must download the file apache1.3.4.tar.gz

1.2 Decompress the sources in a temporary directory

Before unzipping the downloaded file, you must create a temporary directory with the command:

mkdir directory-name

Next, you must decompress the file with the following commmand:

tar zxvf file-name.tar.gz

The file is zipped and tar. You must decompress the sources into the temporary directory, which was previously created.

1.3 Read the files, which allow the APACHE installation

The files allowing the Apache set up are as follows:
install and all the files contained in the htdocs/manual directory

Thanks to these files, we have been able to know that the minimun space to install Apache is 12 MB and that the installation needs a C ANSI compiler.

1.4 Compile the web server

To compile the Apache server, you must type the following commands:

./configure --prefix=PREFIX where PREFIX corresponds to the installation path (For example: /usr/local/apache)
make install

PREFIX/sbin/apachectl start, which allows to start the HTTPD daemon and then to check if the compilation has been successful.
PREFIX corresponds to the setup directory too.

1.5 Edit the configuration files

Even if 2 software exist to configure the APACHE server, here we will give the configuration methods of APACHE by modification of text files contained in the conf directory.

The configuration files are in the /etc/httpd/conf directory

There are 3 important files in the configuration:

  • access.conf: contains the instructions allowing to manage the access rights on the server
  • srm.conf: contains the instructions managing the names and the types reachable to the connected users from their web browser.
  • http.conf: contains the own directives for the functioning of the server.

1.6 Launch the web server

The following command allows to start the server:
apachectl start

The following command allows to restart the server:
apachectl retstart

1.7 Stop the web server

The following command allows to stop the server:

apachectl stop

2°) Configuration of web server

2.1 change the port and the user name

In the following parts, it is necessary to have previously created a user. If it is not the case, you must create it with the command: adduser

e.g a toto user
adduser -g users toto

To change the user name, who will launch the web server (here toto), you must edit the http.conf file. Find the line where User is written and replace nobody by toto.

#User is the username with which the server accesses to resources of the computer.
User toto

To change the virtual port on which the web server goes lock on, you must edit too the http.conf file. Find the line where Port is written and replace the value which is after the port number that you want.
Warning: some ports are reserved (FTP, Telnet, ...)
The configuration thus is as follows:

#The server port by default is 80 and we have replaced it by 3000
Port 3000

Warning!! If you change the virtual port, when you connect on the toto web site, you must specify the new port

2.2 Change the root directory name of the users

In this part, we want to change the configuration when we search the url http://my-server/toto, APACHE search the tutu.html file in the WWW directory of the toto user.

To do so, we must edit the srm.conf file. Find the line where "DirectoryIndex" is written and replace the following by the file to load.

Name of file(s) to display by default, when no file is given in the URL

If you want to specify many files, you must put them one after the other
DirectoryIndex path/toto/WWW/tutu.html

2.3 Change the error messages

It is possible to change the error messages by editing the srm.conf file and modify the content following the keyword ErrorDocument?
For Example:

ErrorDocument 500 "the server made a mistake"
ErrorDocument 500 "The server did not make a mistake"


ErrorDocument 404 /missing.html
will have for consequence to display the missing.html page when the server does not find a page (404 error code)

3°) Server test

There are two ways to test a server:

The first one is very classic, try to display a page with a web browser.

The second one is to test a connection on the web server by the telnet tool. By telnet, we can directly write the request to receive the response in text mode.
Here is an example of use with the telnet command: we can recover the presentation page of a web site by typing telnet vodka 8080 then get /index.html HTTP/1.0 followed by double ENTER.

The server response is in two parts:

First, the header which indicates if the question has been understood by sending a return value (here 200 OK), if the resource has been found, the resource type, etc ...

HTTP/1.0 200 OK
Server : JavaWebServer/1.0.2
Content-Length : 1721
Content-type : text/html
Last-modified : Fri, 30 Jan 1998 13:55:28 GMT
Connection :Close
Date : Wed, 06 Jan 1999 16:12:28 GMT
then the own resource: the HTML page, the GIF picture, etc ...
Some different return codes:
404 Not Found : The page does not exist
400 Bad Request : The request can not be understood

The Content-Length and Content-Type fields correspond to the size and document type.

4°) Performance

In order the server to use the least of process at the start, you must edit the httpd.conf file and research the string "startservers". We find after this string the number 5, replace this number by 1 to launch only one process.

5°) Some questions

5.1 The VirtualHost mechanism

VirtualHost allows to configure many virtual machines on the same server. The server must be setup to accept many Ip addresses. In general, we configure the linux kernel of server. The configuration can be found in the http.conf file and has the following kind:

ServerAdmin webmaster@my-domain.extension
DocumentRoot /directory
ServerName domain.name.extension
ErrorLog relative directory
TransferLog relative directory

5.2 Definition of keepAlive, FollowSymLinks and FancyIndexing

Definition of KeepAlive:
If this variable is put on ON in the http.conf file, it authorizes the web browser to order the connection to keep alive. If this variable is put on OFF, it is desactivated.
Then we find after this variable other ones linked to KeepAlive such as MaxKeepAliveRequests, which gives the connections number being able to keep alive at the same time or KeepAliveTimeout which gives the maximum delay in second in order the connections kept alive to wait for without action.

Definition of FollowSymLinks:
The FollowSymLinks variable is in the access.conf file. If this variable is in the OptionsIndexes field, the exploitation of symbolic links or shortcuts will be authorized.

Definition of FancyIndexing:
If this variable is put on ON in the srm.conf file, the files icons will be displayed with the directories. With the OFF value, the directories are only displayed in HTML.

We must find a serie of icons names (keyword AddIcon), which allows to link the files types to icons when the FancyIndexing mode is on ON. That allows to redefine the icons related to files when directories display.

6°) The accesses rights

The purpose is to restrict the access rights of a web site directory. this is done in two steps:

  • Indicate that the directory has specific rights in the access.conf file
The protection of a page by a password is done in a simple way by adding the directive shown below in the access.conf file

AuthName Label displayed in the protected window
AuthType Basic
AuthUserFile /etc/users.http
require valid-user

/directory/page.html is the protected page

AuthName is the label which is displayed in the protected window
AuthType is in general with the Basic value
AuthUserFile is the file containing the user names, who has the right to access to the page with their associated password
require is a directive, which can take the valid-user value

  • Create an user and a pasword

The creation of a password is possible with htpasswd programm, which takes the following syntax:

htpasswd [-c] passwordfile username

with the -c option, the file is created; without the -c option, the file is completed by the new entry.
passwordfile is the file name containing the passwords.
username is the user name