Vous êtes sur la page 1sur 9

LPIC-2 / examen LPI 202 :

WEB : Apache a Squid

Atelier
version 0.1
Novembre 2012
(Hedi MAGROUN)

---------------------------------------------------------------------------
--- Apache : installation, configuration par défaut et test
---------------------------------------------------------------------------

---> Installation d'apache

root@serveur:~# apt-get install apache2


Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
Lecture des informations d'état... Fait
Les paquets supplémentaires suivants seront installés :
apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
Paquets suggérés :
apache2-doc apache2-suexec apache2-suexec-custom openssl-blacklist
Les NOUVEAUX paquets suivants seront installés :
apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common
libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
0 mis à jour, 10 nouvellement installés, 0 à enlever et 0 non mis à jour.
Il est nécessaire de prendre 2 073 ko dans les archives.
Après cette opération, 6 963 ko d'espace disque supplémentaires seront utilisés.
Souhaitez-vous continuer [O/n] ? o
...
Traitement des actions différées (« triggers ») pour « man-db »...
Paramétrage de libapr1 (1.4.2-6+squeeze4) ...
Paramétrage de libaprutil1 (1.3.9+dfsg-5) ...
Paramétrage de libaprutil1-dbd-sqlite3 (1.3.9+dfsg-5) ...
Paramétrage de libaprutil1-ldap (1.3.9+dfsg-5) ...
Paramétrage de apache2.2-bin (2.2.16-6+squeeze8) ...
Paramétrage de apache2-utils (2.2.16-6+squeeze8) ...
Paramétrage de apache2.2-common (2.2.16-6+squeeze8) ...
Enabling site default.
Enabling module alias.
Enabling module autoindex.
Enabling module dir.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module status.
Enabling module auth_basic.
Enabling module deflate.
Enabling module authz_default.
Enabling module authz_user.
Enabling module authz_groupfile.
Enabling module authn_file.
Enabling module authz_host.
Enabling module reqtimeout.
Paramétrage de apache2-mpm-worker (2.2.16-6+squeeze8) ...
Starting web server: apache2apache2: Could not reliably determine the server's

LPIC-2 / examen LPI 202 / WEB - Atelier - version 0.1 / Hedi MAGROUN 1/9
fully qualified domain name, using 127.0.1.1 for ServerName
.
Paramétrage de apache2 (2.2.16-6+squeeze8) ...
Paramétrage de ssl-cert (1.0.28) ...

root@serveur:~# ps -ef | grep apache


root 1515 1 0 00:18 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 1518 1515 0 00:18 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 1520 1515 0 00:18 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 1521 1515 0 00:18 ? 00:00:00 /usr/sbin/apache2 -k start
root 1614 1112 0 00:19 pts/0 00:00:00 grep apache

root@serveur:~# /etc/init.d/apache2 status


Apache2 is running (pid 1515).
root@serveur:~#

---> Côté client :

- en utilisant un navigateur web :

- en utilisant la commande wget :

hedi@client:~$ wget http://192.168.56.101


--2012-11-30 00:21:30-- http://192.168.56.101/
Connexion vers 192.168.56.101:80...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: 177 [text/html]
Sauvegarde en : «index.html»

100%[======================================>] 177 --.-K/s ds 0s

2012-11-30 00:21:30 (420 KB/s) - «index.html» sauvegardé [177/177]

---> fichiers de configuration :

root@serveur:~# cat /etc/apache2/apache2.conf


#
# Based upon the NCSA server configuration files originally by Rob McCool.
#
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.

LPIC-2 / examen LPI 202 / WEB - Atelier - version 0.1 / Hedi MAGROUN 2/9
...

# These need to be set in /etc/apache2/envvars


User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#

AccessFileName .htaccess

...

# ErrorLog: The location of the error log file.


# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

# Include module configuration:


Include mods-enabled/*.load
Include mods-enabled/*.conf

# Include all the user configurations:


Include httpd.conf

# Include ports listing


Include ports.conf

...

# Include generic snippets of statements


Include conf.d/

# Include the virtual host configurations:


Include sites-enabled/

root@serveur:~# ls /etc/apache2/sites-enabled/
000-default

root@serveur:~# cat /etc/apache2/sites-enabled/000-default


<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>

LPIC-2 / examen LPI 202 / WEB - Atelier - version 0.1 / Hedi MAGROUN 3/9
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/


<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,


# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined


</VirtualHost>

root@serveur:~# ls -l /etc/apache2/mods-enabled/dir*
lrwxrwxrwx 1 root root 26 30 nov. 00:18 /etc/apache2/mods-enabled/dir.conf
-> ../mods-available/dir.conf
lrwxrwxrwx 1 root root 26 30 nov. 00:18 /etc/apache2/mods-enabled/dir.load
-> ../mods-available/dir.load

root@serveur:~# cat /etc/apache2/mods-enabled/dir.load


LoadModule dir_module /usr/lib/apache2/modules/mod_dir.so

root@serveur:~# cat /etc/apache2/mods-enabled/dir.conf


<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

root@serveur:~# ls /var/www/
index.html

root@serveur:~# cat /var/www/index.html


<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>

---> outils a2*

root@serveur:~# apropos apache


a2dismod (8) - enable or disable an apache2 module
a2dissite (8) - enable or disable an apache2 site / virtual host
a2enmod (8) - enable or disable an apache2 module
a2ensite (8) - enable or disable an apache2 site / virtual host
ab (1) - Apache HTTP server benchmarking tool
apache2 (8) - Apache Hypertext Transfer Protocol Server
apache2ctl (8) - Apache HTTP server control interface
apachectl (8) - Apache HTTP server control interface
check_forensic (8) - tool to extract mod_log_forensic output from apache lo...
logresolve (1) - Resolve IP-addresses to hostnames in Apache log files
rotatelogs (8) - Piped logging program to rotate Apache logs
root@serveur:~#

LPIC-2 / examen LPI 202 / WEB - Atelier - version 0.1 / Hedi MAGROUN 4/9
root@serveur:~# ls -l /etc/apache2/sites-*/
/etc/apache2/sites-available/:
total 12
-rw-r--r-- 1 root root ... default
-rw-r--r-- 1 root root ... default-ssl

/etc/apache2/sites-enabled/:
total 0
lrwxrwxrwx 1 root root ... 000-default -> ../sites-available/default

root@serveur:~# a2dissite default


Site default disabled.
Run '/etc/init.d/apache2 reload' to activate new configuration!

root@serveur:~# /etc/init.d/apache2 reload


Reloading web server config: apache2apache2: Could not reliably determine the
server's fully qualified domain name, using 127.0.1.1 for ServerName
[Fri Nov 30 00:35:05 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
.
root@serveur:~# ls -l /etc/apache2/sites-*/
/etc/apache2/sites-available/:
total 12
-rw-r--r-- 1 root root 692 9 sept. 22:17 default
-rw-r--r-- 1 root root 7251 9 sept. 22:17 default-ssl

/etc/apache2/sites-enabled/:
total 0
root@serveur:~#

- côté client :

- réactivant le site par défaut :

root@serveur:~# a2ensite default


Enabling site default.
Run '/etc/init.d/apache2 reload' to activate new configuration!

root@serveur:~# ls -l /etc/apache2/sites-*/
/etc/apache2/sites-available/:
total 12
-rw-r--r-- 1 root root 692 9 sept. 22:17 default
-rw-r--r-- 1 root root 7251 9 sept. 22:17 default-ssl

LPIC-2 / examen LPI 202 / WEB - Atelier - version 0.1 / Hedi MAGROUN 5/9
/etc/apache2/sites-enabled/:
total 0
lrwxrwxrwx 1 root root ... 000-default -> ../sites-available/default

root@serveur:~# /etc/init.d/apache2 reload


Reloading web server config: apache2apache2: Could not reliably determine the
server's fully qualified domain name, using 127.0.1.1 for ServerName
.
---> l'ajout d'une page de test

root@serveur:~# nano /var/www/test.html


root@serveur:~# cat /var/www/test.html
<html>
<head>
</head>
<body>
Ceci est une page html de test
</body>
root@serveur:~#

- côté client :

LPIC-2 / examen LPI 202 / WEB - Atelier - version 0.1 / Hedi MAGROUN 6/9
---------------------------------------------------------------------------
--- Apache : PHP
---------------------------------------------------------------------------

---> installation du module PHP

root@serveur:~# apt-get install libapache2-mod-php5


Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
Lecture des informations d'état... Fait
Les paquets supplémentaires suivants seront installés :
apache2-mpm-prefork libonig2 libqdbm14 php5-cli php5-common php5-suhosin
Paquets suggérés :
php-pear
Les paquets suivants seront ENLEVÉS :
apache2-mpm-worker
Les NOUVEAUX paquets suivants seront installés :
apache2-mpm-prefork libapache2-mod-php5 libonig2 libqdbm14 php5-cli
php5-common php5-suhosin
0 mis à jour, 7 nouvellement installés, 1 à enlever et 0 non mis à jour.
Il est nécessaire de prendre 6 662 ko dans les archives.
Après cette opération, 17,3 Mo d'espace disque supplémentaires seront utilisés.
Souhaitez-vous continuer [O/n] ? o
...
Paramétrage de libapache2-mod-php5 (5.3.3-7+squeeze14) ...

root@serveur:~# ls -l /etc/apache2/mods-*/*php*
-rw-r--r-- 1 root root ... /etc/apache2/mods-available/php5.conf
-rw-r--r-- 1 root root ... /etc/apache2/mods-available/php5.load
lrwxrwxrwx 1 root root ... /etc/apache2/mods-enabled/php5.conf ->
../mods-available/php5.conf
lrwxrwxrwx 1 root root ... /etc/apache2/mods-enabled/php5.load ->
../mods-available/php5.load

root@serveur:~# /etc/init.d/apache2 reload


Reloading web server config: apache2apache2: Could not reliably determine the
server's fully qualified domain name, using 127.0.1.1 for ServerName
.
root@serveur:~# nano /var/www/test.php
root@serveur:~# cat /var/www/test.php
<?php
echo " Ceci est une page PHP de test"
?>

LPIC-2 / examen LPI 202 / WEB - Atelier - version 0.1 / Hedi MAGROUN 7/9
---------------------------------------------------------------------------
--- Apache : Virtual host
---------------------------------------------------------------------------

LPIC-2 / examen LPI 202 / WEB - Atelier - version 0.1 / Hedi MAGROUN 8/9
---------------------------------------------------------------------------
--- Apache : SSL
---------------------------------------------------------------------------

LPIC-2 / examen LPI 202 / WEB - Atelier - version 0.1 / Hedi MAGROUN 9/9

Vous aimerez peut-être aussi