1 - Vérifier si le serveur Apache est actif :
Plusieurs solutions :2 - Configurez votre serveur :
Avec la commande ps :ps aux | grep httpdAvec la commande httpd status :
Cette commande vous répondra par exemple :
nobody 361 0.0 0.9 1532 580 ? S 17:47 0:00 httpd
...
...
nobody 494 0.0 0.9 1532 624 ? S 17:53 0:00 httpd/etc/rc.d/init.d/httpd statusSi vous constatez que httpd n'est pas en fonctionnement, vérifiez si le package a été installé avec le RPM Manager Gimp si ce n'est pas le cas, installez le avec la commande suivante :
Cette commande vous répondra par exemple :
httpd (pid 494 493 370 369 368 367 366 365 364 363 362 361 354) is running...
rpm -i -vv /mnt/cdrom/RedHat/RPMS/apache-1.26-5.i386.rpm
Les fichiers de configuration, sont situés dans le répertoire /etc/httpd/conf/3 - Démarrez votre serveur web :
Ils sont au nombre de trois :
httpd.conf
access.conf
srm.confLa couleur rouge indique les commentaires, la couleur verte les directives que j'ai modifiées.
2.1 - Le fichier httpd.conf :# This is the main server configuration file. See URL http://www.apache.org/
# for instructions.
# ServerType is either inetd, or standalone.
ServerType standalone
# If you are running from inetd, go to "ServerAdmin".
# Port: The port the standalone listens to.
Port 80
# HostnameLookups: Log the names of clients or just their IP numbers
HostnameLookups off
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
# User/Group: The name (or #number) of the user/group to run httpd as.
User nobody
Group nobody
# The following directive disables keepalives and HTTP header flushes for
# Netscape 2.x and browsers which spoof it.
BrowserMatch Mozilla/2 nokeepalive
BrowserMatch Java1.0 force-response-1.0
BrowserMatch JDK/1.0 force-response-1.0
# ServerAdmin: Your address, where problems with the server should be e-mailed.
ServerAdmin root@localhost
# ServerRoot: The directory the server's config, error, and log files are kept in
ServerRoot /etc/httpd
# BindAddress: You can support virtual hosts with this option.
#BindAddress *
# ErrorLog: The location of the error log file.
ErrorLog /var/log/httpd/error_log
# TransferLog: The location of the transfer log file
TransferLog /var/log/httpd/access_log
# PidFile: The file the server should log its pid to
PidFile /var/run/httpd.pid
# ScoreBoardFile: File used to store internal server process information.
ScoreBoardFile /var/run/apache_status
# ServerName allows you to set a host name which is sent back to clients for
# your server if it's different than the one the program would get
ServerName sti.pmcurie.net
# Timeout: The number of seconds before receives and sends time out
Timeout 300
# KeepAlive
KeepAlive On
# MaxKeepAliveRequests:
MaxKeepAliveRequests 100
# KeepAliveTimeout: Number of seconds to wait for the next request
KeepAliveTimeout 15
# Server-pool size regulation
MinSpareServers 8
MaxSpareServers 20
# Number of servers to start --- should be a reasonable ballpark figure.
StartServers 10
# Limit on total number of servers running
MaxClients 150
# MaxRequestsPerChild
MaxRequestsPerChild 100
# Proxy Server directives. Uncomment the following line to
# enable the proxy server:
ProxyRequests On
ProxyRemote * http://proxy.oleane.net:8080
# To enable the cache as well, edit and uncomment the following lines:
CacheRoot /home/httpd/proxy
CacheSize 5
CacheGcInterval 4
CacheMaxExpire 24
CacheLastModifiedFactor 0.1
CacheDefaultExpire 1
NoCache sti.pmcurie.net
2.2 - Le fichier acces.conf :
# access.conf: Global access configuration
# Online docs at http://www.apache.org/
# Be a little more paranoid
<Directory /home>
Options Indexes IncludesNOEXEC
AllowOverride None
</Directory>
# This should be changed to whatever you set DocumentRoot to.
<Directory /home/httpd/html>
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you (or at least, not yet).
Options Indexes Includes ExecCGI FollowSymLinks
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
AllowOverride None
# Controls who can get stuff from this server.
order allow,deny
allow from all
</Directory>
# /usr/local/etc/httpd/cgi-bin should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
<Directory /home/httpd/cgi-bin>
AllowOverride None
Options ExecCGI
</Directory>
# There have been reports of people trying to abuse an old bug from pre-1.1
# days. This bug involved a CGI script distributed as a part of Apache.
# By uncommenting these lines you can redirect these attacks to a logging
# script on phf.apache.org. Or, you can record them yourself, using the script
# support/phf_abuse_log.cgi.
<Location /cgi-bin/phf*>
deny from all
ErrorDocument 403 http://phf.apache.org/phf_abuse_log.cgi
</Location>2.3 - Le fichier srm.conf :
# With this document, you define the name space that users see of your http
# server. This file also defines server settings which affect how requests are
# serviced, and how results should be formatted.
# See the tutorials at http://www.apache.org/ for
# more information.
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot /home/httpd/html
# UserDir: The name of the directory which is appended onto a user's home
# directory if a ~user request is recieved.
UserDir private_html
....
....
Le reste, je ne l'ai pas modifié ;-)
4 - Modifier le fichier /etc/mime.type:/etc/rc.d/init.d/httpd start
Si tout est convenable vous obtenez la réponse suivante Starting httpd:
Testez votre serveur en saisissant par exemple l'adresse de localhost dans la fenêtre location de votre navigateur :
http://127.0.0.1/ ou http://localhost/ ou bien encore http://xxx.xxx.xxx.xxx (ou xxx.xxx.xxx.xxx est le n° d'IP de la machine Linux)
Vous obtiendrez normallement l'affichage de la page index.html située dans le répertoire de votre serveur web
/home/httpd/html/
Pour que votre serveur web puisse charger indifféremment les fichiers html et htm :
- éditer le fichier /etc/mime.types
- rechercher la ligne contenant html et ajouter htm à la suite.
- redémarrez votre démon httpd pour prendre en compte votre modification :
/etc/rc.d/init.d/httpd stop
/etc/rc.d/init.d/httpd start
5 - Créez des
répertoires pour vos utilisateurs :
Exemple vous disposez sur votre système d'un utilisateur qui répond au nom de : cdi6 - Références :
Votre serveur web répond au nom de domaine suivant : http://sti.pmcurie.net
Vous ouvrez un accès pour l'utilisateur cdi, qui pourra consulter et déposer ses pages à l'adresse suivante :
http://sti.pmcurie.net/~cdi/
Pour cela, il suffit de créer dans le répertoire de chaque utilisateur un répertoire : public_html
exemple pour l'utilisateur cdi
/home/cdi/private_html/
Apache Installation et mise en oeuvre Edition O'REILLY
Apache server project (http://www.apache.org)
ApacheWeek (http://wwwapacheweekcom/)
Doc concentrée pour Linux (http://www.alternatif.fr/linux-france/article/serveur/doc_concentree/doc_concentree.html)
Retour à la page précédente Lycée Pierre & Marie Curie Saint-Lô [Manche] dernière mise à jour : 18-01-1999