Download Manuel d`installation pour plateforme d`hébergement Ruby on Rails

Transcript
Manuel d'installation
pour plateforme
d'hébergement
Ruby on Rails
sur DEDIBOX
Table des matières
I) Installation d' u n environ ne me n t Ruby On Rails................................................................4
1) Se co n necter en ta n t q ue root s u r la platefor me.....................................................4
2) Installer Ruby et ses co m po sa n t s :..............................................................................4
3) Télécharger et installer Gems ........................................................................................4
4) Installer Rails.....................................................................................................................5
5) Installation d'a pache........................................................................................................5
6) Installation de Mysql et ses librairies..........................................................................6
7) Installer PHP4.....................................................................................................................6
8) Installation de p h p mya d min ..........................................................................................6
II) Configuration de la platefor me.............................................................................................7
1) Configurer Mysql..............................................................................................................7
a) Com m a n de s ajout de m o t de p a s se root............................................................7
b) Résultat s d es co m m a n d es p récé den tes ...............................................................7
c) Ajouter l'utilisateur Rails a mys ql.........................................................................7
2) Configurer Apache............................................................................................................8
a) Activer le m o de fastcgi.............................................................................................8
b) Activer le m o d ule rewrite........................................................................................8
c) Creer de ux d o s sier s p o u r les logs des vhos t s ....................................................8
d) Activer le m o d ule rewrite........................................................................................8
e) Il faut m o difier l'htaccess d a n s to u s les p r ojets / p u blic /.htacces s.............8
III) Installation s pécifique dé dié p o u r l'héberge me nt m u t ualisé.......................................9
1) Installation de bin d9 (dae mo n: n a me d)......................................................................9
2) Installation de ProFTP (dae mo n: p r oft p d)..................................................................9
3) Installation de q uota de dis q ue (Pas d e d ae m o n)....................................................9
4) Installation de Postfix (dae mo n: p o s tfix + picku p + q mgr)...............................1 0
5) Installation de la QOS....................................................................................................1 0
IV) Configuration de s ou tils p o ur l'héberge me n t m u t ualisé...........................................1 1
1) Configura tion de bin d9 .................................................................................................1 1
a) Modifier le fichier de configuration / e tc / bin d / n a m e d.conf........................1 1
b) Creer le fichier / e tc / bin d / d b.b4os.fr.................................................................1 1
c) Creer le fichier / e tc / bi n d / d b.b4os.fr.inv..........................................................1 2
2) Configura tion de ProFTP .............................................................................................1 2
3) Configura tion de s q uo tas .............................................................................................1 4
4) Configura tion de Postfix..............................................................................................1 5
5) Configura tion de la QOS...............................................................................................1 6
6) Configura tion d' u n firewall grace à IPTABLES........................................................1 6
V) Configuration avancé............................................................................................................2 0
1) Postfix................................................................................................................................2 0
2) Installation p os tfix TLS - SASL.....................................................................................2 2
3) Script de creation d' u tilisate ur ...................................................................................2 4
4) Script de s u p p r es sion d' utilisate ur ..........................................................................2 8
5) Configuraion de Logrotate ..........................................................................................3 0
a) d a n s / e tc / webalizer / c r o n.daily / all....................................................................3 0
b) da n s / e tc / webalizer / c r o n.weekly / all................................................................3 1
6) Installer le Vhost d'accueil + p h p mya d min............................................................3 5
VI) Installation d'o utils p o u r les perfor m a nces et tes t s ...................................................3 6
1) Pour les s tat s, installer Webalizer (logiciel u tilise p a r Free) :.............................3 6
2) Installation de n to p p o u r verifier la BP de to u s les p r ojets :.............................3 6
I) Installation d'un environnement Ruby On Rails
1) Se connecter en tant que root sur la plateforme
d e dib ox: / $ s u - root
Pour installer les a p plications il fau t absolu me n t avoir les d r oits neces saire
s u r le sys te me.
2) Installer Ruby et ses composants :
d e dib ox: / # apt - g et in stall rub y lib zlib - rub y rdoc irb
Reading Package Lists... Done
Building Dependency Tree... Done
T he following extra packages will be installed:
irb1.8 libreadline - ruby1.8 libreadline4 libruby1.8 rdoc1.8 ruby1.8
Suggested packages:
ruby1.8 - exa m ples ri1.8
T he following NEW packages will be installed:
irb irb1.8 libreadline - ruby1.8 libreadline4 libruby1.8 libzlib - r uby rdoc rdoc1.8 ruby ruby1.8
0 u pgraded, 10 ne wly installed, 0 to re move a nd 0 not upgraded.
Need to get 2202kB of archives.
A fter u n packing 7643kB of additional disk space will be used.
3) Télécharger et installer Gems
h t t p: / / r u byforge.org / p r ojects / r u byge m s /
(dedibox: / # wget h t t p: / / r u byforge.org / fr s / d ownloa d.ph p / 5 207 / r u byge m s - 0.8.11.tg z
le lien etait m o r t p o u r l'ins tall alors copie s ur site pers o)
d e dib ox: / # w g et http: / / p i erre.fauqu e m b ergu e.free.fr /rub y g e m s 0.8.1 1.tg z
d e dib ox: / # tar z x v f rub yg e m s - 0.8.1 1.tg z
d e dib ox: / # cd rub yg e m s - 0.8.1 1
d e dib ox: / # rub y s et up.rb all
Successfully built RubyGe m
Na m e: sources
Version: 0.0.1
File: sources - 0.0.1.ge m
4) Installer Rails
d e dib ox: / # g e m in stall rails - - includ e - d ep en d e n cie s
Atte m pting local installation of 'rails'
Local ge m file not fou nd: rails*.ge m
Atte m pting re mote installation of 'rails'
Updating Ge m source index for: http: / / ge ms.rubyforge.org
Successfully installed rails - 1.1.2
Successfully installed rake - 0.7.1
Successfully installed activesupport - 1.3.1
Successfully installed activerecord - 1.14.2
Successfully installed actionpack - 1.12.1
Successfully installed action m ailer - 1.2.1
Successfully installed actionwebservice - 1.1.2
Installing RDoc docu me ntation for rake - 0.7.1...
Installing RDoc docu me ntation for activesupport - 1.3.1...
Installing RDoc docu me ntation for activerecord - 1.14.2...
Installing RDoc docu me ntation for actionpack - 1.12.1...
Installing RDoc docu me ntation for action m ailer - 1.2.1...
Installing RDoc docu me ntation for actionwebservice - 1.1.2...
Rails est installé, no u s devons m ainte na n t inst aller u n serveur Web (apache2)
5) Installation d'apache
d e dib ox: / # apt - g et in stall apach e 2 libapach e 2 - m o d - fcgid libfcgi - rub y 1.8
Reading Package Lists... Done
Building Dependency Tree... Done
T he following extra packages will be installed:
apache2 - co m m o n apache2 - m p m - worker apache2 - utils libapr0 libexpat1 libfcgi0 libldap2
lib m agic1 libsasl2 m i m e - support openssl ssl - cert
Suggested packages:
apache2 - doc lynx w w w - browser file ca - certificates
Reco m m e n ded packages:
libsasl2 - m o d ules
T he following NEW packages will be installed:
apache2 apache2 - co m mo n apache2 - m p m - worker apache2 - utils libapache2 - m o d - fcgid
libapr0 libexpat1 libfcgi - ruby1.8 libfcgi0 libldap2 lib m agic1 libsasl2 m i m e - support
openssl ssl - cert
0 u pgraded, 15 ne wly installed, 0 to re move a nd 0 not upgraded.
Need to get 3226kB of archives.
A fter u n packing 10.1MB of additional disk space will be used.
6) Installation de Mysql et ses librairies
d e dib ox: / # apt - g et in stall m y s ql - s er v er - 4.1 lib m y s qlclient 1 4 lib m y s ql rub y 1.8
Reading Package Lists... Done
Building Dependency Tree... Done
T he following extra packages will be installed:
libdbd - m y sql - perl libdbi - perl lib m ysqlclient12 libnet - dae mo n - perl libplrpc - perl m ysql client - 4.1 m ysql - co m mo n - 4.1
Suggested packages:
dbishell libco m press - zlib - perl m ysql - doc - 4.1
Reco m m e n ded packages:
lib m ysqlclient14 - dev
T he following NEW packages will be installed:
libdbd - m y sql - perl libdbi - perl lib m ysql - ruby1.8 lib m ysqlclient12 lib m ysqlclient14 libnet dae mo n - perl libplrpc - perl m ysql - client - 4.1 m ysql - co m m o n - 4.1
m ysql - server - 4.1
7) Installer PHP4
d e dib ox: / # apt - g et in stall p hp 4 ph p 4 - m y s ql p hp 4 - cli libapach e 2 - m o d php 4
Reading Package Lists... Done
Building Dependency Tree... Done
T he following extra packages will be installed:
apache - co m m o n apache2 - m p m - prefork libapache - m o d - p hp4 libbz2 - 1.0 libkrb53
libncursesw5 libz zip - 0 - 12 lynx p hp4 - co m mo n
Suggested packages:
apache apache - ssl apache - perl php4 - pear libbz2 - dev b zip2 krb5 - doc krb5 - user
T he following packages will be REMOVED:
apache2 - m p m - worker
T he following NEW packages will be installed:
apache - co m m o n apache2 - m p m - prefork libapache - m o d - p hp4 libapache2 - m o d - php4
libbz2 - 1.0 libkrb53 libncursesw5 libz zip - 0 - 12 lynx php4 p hp4 - cli php4 - co m m o n p hp4 - m ysql
Pour vérifier q ue PHP fonction ne correcte m e nt avec a pache, il fa ut créer le fichier
/ v a r / www / a p ache2 - defa ult / t e s t.ph p :
< ? p h pi nfo(); ? >
8) Installation de phpmyadmin
d e dib ox # apt - get in stall ph p m yad min
1) Which web server would you like t o reconfigure a ut o m atically?
a pac he2
2) Would you res tar t a pache2 ?
yes
II) Configuration de la plateforme
1) Configurer Mysql
a) Commandes ajout de mot de passe root
d e dibo x: / # m y s ql - u root
m y s ql > UPDATE m y s ql.us er SET Pas s w ord =
PASSWORD('nou v eau_m ot_de_pas s e')
WHERE Us er = 'root';
m y s ql > FLUSH PRIVILEGES;
b) Résultats des commandes précédentes
d e dibo x: / # m y s ql - u root
Welco me to the MySQL m o nitor. Co m m a n ds end with ; or \ g.
Your MySQL connection id is 8 to server version: 4.1.11 - Debian_4sarge2 - log
Type 'help;' or ' \ h' for help. Type ' \c' to clear the buffer.
m y s ql > UPDATE m y s ql.us er SET Pas s w ord =
PASSWORD('nou v eau_m ot_de_pas s e') WHERE User =
'root';
Query OK, 2 rows affected (0.00 sec)
Rows m a tched: 2 Changed: 2 Warnings: 0
m y s ql > FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
c) Ajouter l'utilisateur Rails a mysql
d e dibo x: / # m y s ql - u root - p
m y s ql > GRANT ALL PRIVILEGES ON *.* TO 'rails'@'localh o st'
IDENTIFIED BY 'un_m ot_de_pas s e' WITH GRANT OPTION;
Résultat :
m ysql> GRANT ALL PRIVILEGES ON *.* TO 'rails'@'localhost' IDENTIFIED BY
'un_ mot_de_passe' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
2) Configurer Apache
a) Activer le mode fastcgi
d e dibo x: / # a2en m o d fcgid
Module fcgid installed; ru n / e tc /i nit.d / a pache2 force - reload to enable.
d e dibo x: / # / e t c / i nit.d / a pach e 2 restart
Forcing reload of web server: A pache2.
d e dibo x: / # g e m in stall fcgi
b) Activer le module rewrite
d e dibo x: / # a2en m o d re write
d e dibo x: / # / e t c / i nit.d / a pach e 2 reload
c) Creer deux dossiers pour les logs des vhosts
d e dibo x: / # / v ar / l o g / a pach e 2 / error
d e dibo x: / # / v ar / l o g / a pach e 2 / a cc e s s
d) Activer le module rewrite
Apres les 2 lignes s uivantes d a n s / e tc / a p ac he2 / a p ac he2.conf
LogFor m a t "%h %l %u %t \ "%r \" %>s %b \ "%{Referer}i \" \ "%{User - Agent}i \"" co m bine d
LogFor m a t "%h %l %u %t \ "%r \" %>s %b" co m m o n
Ajouter cet te ligne
LogFor m a t "%v %h %l %u %t \ "%r \" %>s %b \ "%{Referer}i \" \ "%{User - Agent}i \""
co m bine dvhos t h
e) Il faut modifier l'htaccess dans tous les projets
/ public /.htaccess
On co m m e n te
AddHa n dler fastcgi - script .fcgi
Et o n re m place p ar
AddHa n dler fcgid - script .fcgi
On pe u t a u s si cha nger la règle d e réécriture p a r :
RewriteRule ^(.*)$ dis pa tc h.fcgi \ [QSA,L \]
III) Installation spécifique dédié pour l'hébergement
mutualisé
1) Installation de bind9 (daemon: named)
d e dib ox: / # apt - get in stall bind 9
Reading Package Lists... Done
Building Dependency Tree... Done
T he following extra packages will be installed:
libdns16 libisc7 libisccc0 libisccfg0 liblwres1
Suggested packages:
dnsutils bind9 - doc
T he following NEW packages will be installed:
bind9 libdns16 libisc7 libisccc0 libisccfg0 liblwres1
0 upgraded, 6 ne wly installed, 0 to re move and 0 not upgraded.
Need to get 1141kB of archives.
A fter u n packing 2720kB of additional disk space will be used.
2) Installation de ProFTP (daemon: proftpd)
d e dibox: / # apt - g et in stall proftpd
Reading Package Lists... Done
Building Dependency Tree... Done
T he following extra packages will be installed:
proftpd - co m m o n ucf
Suggested packages:
proftpd - doc
Reco m m e nded packages:
debconf - utils
T he following NEW packages will be installed:
proftpd proftpd - co m m o n ucf
0 upgraded, 3 ne wly installed, 0 to re move and 0 not upgraded.
Need to get 598kB of archives.
A fter u n packing 1589kB of additional disk space will be used.
Choisir l'option 'sta n d alone' p o u r de m eilleures perfor m a nces
3) Installation de quota de disque (Pas de daemon)
d e dib ox: / # apt - get in stall qu ota
Reading Package Lists... Done
Building Dependency Tree... Done
T he following NEW packages will be installed:
quota
0 upgraded, 1 ne wly installed, 0 to re move and 0 not upgraded.
Need to get 419kB of archives.
A fter u n packing 1122kB of additional disk space will be used.
Répo n d re 'Yes' p o ur envoyer u n ra p pel si l'utilisateur dé pa s se s o n q uot a.
Puis d o n ner l'adres se e m ail a contacter en cas de p roblè me.
4) Installation de Postfix (daemon: postfix + pickup + qmgr)
d e dibox: / # apt - g et in stall p o stfix
Reading Package Lists... Done
Building Dependency Tree... Done
Suggested packages:
proc m ail postfix - m ysql postfix - pgsql postfix - ldap postfix - pcre
Reco m m e nded packages:
resolvconf
T he following packages will be REMOVED:
exi m 4 exi m 4 - base exi m 4 - config exi m 4 - dae mo n - light
T he following NEW packages will be installed:
postfix
0 upgraded, 1 ne wly installed, 4 to re move and 0 not upgraded.
Need to get 802kB of archives.
A fter u n packing 1118kB disk space will be freed.
Ques tions relatvies à l'ins tallation :
a) General type of conffiguration = > 'Internet Site'
b) Where s ho ul d m ail for root go = > 'kinder'
c) Mail na m e (after @) = > 'b4os.fr'
d) Other d es tinations t o accept m ail for? = > 'b4o s.fr, s d - 2 1 5 6.dedibox.fr,
de v 4ror.b4o s.fr, localhost.dedibox.fr, localhost'
e) Force sync hro no u s u p d a tes on m ail q ue ue? = > 'Yes' (plus lent, m ais sa ns per te de m ail)
Lors de l’ins tallation de Postfix, a p t - get d oit s u p p ri mer a ut o m a tique m e n t Exim4.
5) Installation de la QOS
****** A FAIRE ****************
Pour l'insta n t, QOS avec iptables :
# Priorisation des connexions ftp et ssh
iptables - A PREROUTING - t m a n gle - p tcp - - sport ssh - j TOS - - set - tos Mini mi ze - Delay
iptables - A PREROUTING - t m a n gle - p tcp - - sport ftp - j TOS - - set - tos Mini mi ze - Delay
# On don ne u n m axi m u m de débit aux transferts ftp, peu i m porte la latence
iptables - A PREROUTING - t m a n gle - p tcp - - sport ftp - data - j TOS - - set - tos Maxi mi ze T hroughp ut
******** A FAIRE *************
IV) Configuration des outils pour l'hébergement mutualisé
1) Configuration de bind9
a) Modifier le fichier de configuration
/ e tc /bind / named.conf
Ajouter ces lignes en fin de fichier :
/ /M a z o ne a m oi !
z o ne "b4os.fr" {
type m a s ter;
file " /etc / bi n d / d b.b4os.fr";
};
/ / Z o ne inverse a m oi
z o ne "151.21.191.88.in - a d d r.ar pa" {
type m a s ter;
file " /etc / bi n d / d b.b4os.fr.inv";
};
b) Creer le fichier / e tc /bind / db.b4os.fr
Puis ajouter ces lignes :
;
; BIND reverse da t a file for local loopback interface
;
$TTL 604800
@
IN
SOA dev4ror.b4os.fr. root.localhos t. (
1
; Serial
604800
; Refres h
86400
; Retry
2419200
; Expire
604800 )
; Negative Cache TTL
;
@
IN
NS
dev4ror.b4os.fr.
1.0.0 IN
PTR
localhos t.
dev4ror IN A 88.191.21.151
www IN CNAME dev4ror.b4os.fr.
;** Les lignes s uivantes d \ xc3 \ xa9finissen t la ta ble ent re les n o m s et les IP
www IN A
88.191.21.151
s ho p IN A
88.191.21.151
c) Creer le fichier / e tc /bind / db.b4os.fr.inv
;
; BIND reverse da t a file for local loopback interface
;
$TTL 604800
@ IN SOA
ror.zieute.co m. root.zieute.co m. (
1
604800
86400
2419200
604800 )
@ IN NS dev4ror.b4os.fr.
1 IN PTR dev4ror.b4os.fr.
2 IN PTR s ho p.b4os.fr.
3 IN PTR www.b4os.fr.
Pour tes ter q ue le de m o n fonction ne bien, re de m a rrer le service co m m e s uit :
d e dib ox: / # / e t c / i nit.d / bind 9 restart
Vérifier les logs :
de dibo x: / # tail - 3 0 / v ar / l o g / s y sl og
2) Configuration de ProFTP
En p re mier te m p s, securiser so n ft p
d e dibo x: / # cp / e t c / p a s s w d / e t c / f tp u s er s
Ens uite il faut e diter le fichier d e config
d e dibo x: / # v i / e t c / pr oftpd.conf
#
# / e t c / p r oft p d.conf - - This is a b asic ProFTPD configur ation file.
# To re all y a p pl y ch an ges reloa d p r oft p d aft er m o difications.
#
Serv erNa m e
Serv erT y pe
DeferWelco m e
MultilineRFC22 2 8
DefaultSer ver
ShowS y mlinks
Ti m eoutNoTr ansfer
Ti m eoutStalled
Ti m eoutIdle
"FTP B4OS"
st an d alone
off
on
on
on
600
600
1200
Serv erIdent on "Authentification en cours..."
Dis pl a yLogin
w elco m e. ms g
Dis pl a yFirstCh dir
.mess a ge
ListO ptions
"-l"
Den yFilter
\*.* /
#
# Auth
#
AccessGr antMsg "Connexion Reussie..."
AccessDen yMsg "Authentification Incorrecte..."
RequireV alidShell
off
#
# Log
#
Serv erLog / v a r / l o g / p r oft p.log
Tr ansferLog / v a r / l o g / p r oft p - tr ansfert.log
# Unco m m e nt this if y ou ar e using NIS or LDAP to retrie ve p a ss w or ds:
#PersistentPass w d
off
# Unco m m e nt this if y ou w ould use TLS m o dule:
# TLSEngine
on
# Unco m m e nt this if y ou w ould use quot a m o dule:
# Quot as
on
# Unco m m e nt this if y ou w ould use r atio m o dule:
#Ratios
on
# Port 2 1 is the st an d ar d FTP por t.
Port
21382
# To p r e v ent DoS at t acks, set the m axi m u m nu m b er of child p r ocesses
# to 3 0. If y ou need to allow m o r e th an 3 0 concur rent connections
# a t once, si m pl y incre ase this v alue. Note th at this ONLY w or ks
# in st an d alone m o d e, in inet d m o d e y ou should use an inetd ser v er
# th at allo ws y ou to li mit m axi m u m nu m b er of p r ocesses p e r ser vice
# (such as xinet d)
MaxInst ances
30
# Set the user an d gr ou p th at the ser ve r nor m ally runs a t.
User
nobod y
Grou p
nogr ou p
# U m as k 0 2 2 is a goo d st an d ar d u m as k to p r e v ent ne w files an d dirs
# (secon d p a r m) fro m bein g g rou p an d w orld w rit a ble.
U m as k
022 022
# Nor m all y, w e w an t files to be o ver w rite a ble.
Allow O v er w rite
on
#Connexion st an d a r d
Defaultroot ~
#Utilisateur au torises
<Li mit LOGIN >
AllowUser kin der
Den yAll
< / Li mit >
3) Configuration des quotas
il fa ut m o n ter la pa r tition q ui sera l'objet de q uot as avec l'option dé sirée :
u s r q uot a : active les q uo tas u tilisate urs
gr pq uo ta : active les q uot as grou pes
Nous choisiron s ici l'op tion u s r q uo ta; p o ur l'a p pliquer à la pa r tition / h o m e, ouvre z
/ e t c / f s t ab :
de dibo x: / # vi / e t c / f stab
et ajouter ",usrq uota" a près les o p tions exista n tes :
/ dev /sda3
/ home
ext 3
defaults,usr quot a
0
2
créer le fichier aq uot a.user à la racine de la p a rtition à laquelle vous vouler a p pliquer les
q uot as, p uis le re n d re exécutable.
de dibo x: / # touch / h o m e / a q u ota.u s er
d e dib ox: / # ch m o d 6 0 0 / h o m e / a q u ota.u s er
Il faut alors re m o n ter les p a rtition s en q ues tion :
de dibo x: / # m o u nt - o rem ou nt / h o m e
Vérifiez ens uite le systè me de q uot a à l'aide de la co m m a n de :
d e dib ox: / # qu otach ec k - au v g
Atte n d re la fin d u t raite me n t de la co m m a n de :
quotacheck: WARNING - Quotafile / h o m e / a q uota.user w as probably tru ncated. Can't
save quota settings...
quotacheck: Scanning / d e v / s da3 [/ho m e] quotacheck: Old group file not found. Usage
will not be substracted.
done
quotacheck: Checked 5 directories a nd 6 files
Pour activer les q uo tas, u tilise z la co m m a n de :
d e dib ox: / # qu otaon - a
Il faut finale me n t a p pliquer les q uo tas p o u r chaq ue u tilisate ur
d e dib ox: / # ed qu ota - u u s er
S'ouvre alors le fichier q ui définit les q uot as de l'utilisateur; il est cons tit ué de t rois
colon nes, p ar exe m ple :
Disk quotas for user test (uid 1001):
Filesyste m blocks soft hard inodes soft$
/ d e v / h d a3 12 0 100000 3 0$
Pour kin der :
Disk quotas for user kinder (uid 1000):
Filesyste m blocks quota li mit grace files quota li mit grace
/ d e v / s da3
16 900000 1000000
4
0
0
Filesyste m co m por te les Systè me s de fichiers concernés p a r les q uo ta s;
Blocks es t l'es pace u tilsié
Soft es t la limite d o uce a p pliquée aux blocks : l'utilisateur sera se ule me nt p révenu,
Hard es t la limite d u re a p pliquées a ux blocks : l'utilisateur ne p o u rra p as dé pa s ser cet te
limite.
Les inodes cons tit ue nt des "cartes d'iden tité" p o ur chaq ue fichier.
Ici, auc u ne limite d o uce n'es t fixée (La valeur de "/ dev / h d a 3" p o u r soft es t "0"),
ta n dis q ue l'utilisateur ne p o u rra p as occu per pl us de 100Mo d a n s so n es pace p ers o n nel
(la valeur de " / dev / h d a 3" p o ur "har d" es t 100000)
Pour Prevenir l'utilisate ur lors q u'il a at tein d s a limite s oft, m o difier le fichier
/ e t c / wa r n q uo ta.conf
4) Configuration de Postfix
Détail de la configuration d u fichier « / e tc / p o s tfix / m ain.cf »
Définition d u n o m d u serveur et d u d o m aine :
m y h ostn a m e = m ail. mon do m aine.co m
m y d o m ain = m on do m aine.co m
Lire les req uêtes de p uis to u tes les interfaces résea u :
inet_interfaces = all
Quel d o m aine afficher da n s le courrier sort a n t :
m y o rigin = $ m y d o m ain
De q uels d o m aines recevoir le courrier :
m y d es tin ation = $ m y hostn a m e localhost.$ m y d o m ain $ m y d o m ain
De q uels client s relayer le courrier :
m y n et w or ks = 1 9 2.1 6 8.0 / 8, 1 0.2.2 / 8, 1 0.2.3 / 8, 1 2 7.0.0.0 / 8
Gestion de s aliases et de la re - direction de s m ails :
alias_ m a ps = h ash: / etc / p ostfix / aliases
Adres se d u relais SMTP p o u r les cour rier no n t raités p a r le serveur :
rela y host = s m t p.free.fr
Ré - écrit ure de l’adres se de l’expéditeur (ligne à ajouter - > facultatif) :
sen der_canonical_m a ps = h ash: / e tc / p ostfix / c a nonical
ATTENTION : A chaq ue m o dification de ce fichier ou de s ta bles ci - de s s o us, il faut
recharger la configuration :
d e dib ox: / # / e t c / rc.d / init.d / p o stfix reload
5) Configuration de la QOS
************* A FAIRE *****************
Pour l'ins ta n t gere avec iptables
************* A FAIRE *****************
6) Configuration d'un firewall grace à IPTABLES
Pour finir l'ins tallation, on ins talle u n firewall afin de sécuriser la platefor m e.
Mettre le fichier ci des so u s da n s / e tc /i nit.d / firewall.sh
Et lui ajoin dre les d roits neces saire a l'execution :
d e dibo x: / # ch m o d u g o + x / e t c / i nit.d / fire wall.sh
****************************** DEBUT DU FIREWALL **********************************
#! / bin / s h
# Firew all d e v 4 r or
fire w all_start() {
echo "[De m ar r a ge du fire w all]"
# # # # # # # # # # # # # # # # # # # # CHARGEMENT DES MODULES # # # # # # # # # # # # # # # # # # #
echo "[Char ge m ent d es m o dules]"
m o d p r o be ip_tables
m o d p r o be ipt a ble_filter
m o d p r o be ipt a ble_ m an gle
m o d p r o be ipt a ble_nat
# # # # # # # # # # # # # # # # # # # # # # REGLES PAR DEFAUT # # # # # # # # # # # # # # # # # # # # # # #
echo "[Initialisation de la t a ble filter]"
ipt a bles - F
#Eli mine toutes les re gles
ipt a bles - X
#Su p pr ession d'une ch aine vi de
echo "[Politique p a r d éf aut d e la t a ble filter]"
# On ignore tout ce qui entr e ou tr ansite p a r la p asserelle
ipt a bles - P INPUT DROP
ipt a bles - P FORWARD DROP
# On acce pte, ce qui sort
ipt a bles - P OUTPUT ACCEPT
# Pour é viter les m a u v aises su prises, on v a
# autoriser l'accès à la loop b ac k, c'est vit al !
ipt a bles - A INPUT - i lo - j ACCEPT
ipt a bles - A OUTPUT - o lo - j ACCEPT
# # # # # # # # # # # # # # # # # # # # # # # # LOCAL - INTERNET # # # # # # # # # # # # # # # # # # # # # # #
echo "[On autorise les clients à accé der à internet ]"
# On créé une nou v elle ch aîne "local - internet"
ipt a bles - N local - internet
#Nou v elle ch aine
ipt a bles - A local - internet - m st ate - - st ate NEW - i ! eth 1 - j ACCEPT
ipt a bles - A local - internet - m st ate - - st ate ESTABLISHED,RELATED - j ACCEPT
# On ter mine en indiqu ant que les connections a p p a r t en ant à "local - internet"
# accè dent à internet de m a nière tr ans p ar ent e.
ipt a bles - A INPUT - j local - internet
ipt a bles - A FORWARD - j local - internet
# # # # # # # # # # # # # # # # # # LES TABLES NAT ET MANGLE # # # # # # # # # # # # # # # # # # # #
echo "[Initialisation des t a bles n at et m a n gle]"
ipt a bles
ipt a bles
ipt a bles
ser veurs
ipt a bles
m a s quer a d e
ipt a bles
ipt a bles
ipt a bles
ipt a bles
ipt a bles
- t n at - F
#Eli mine les re gles
- t n at - X
#Su p pri m e la ch aine vi de
- t n at - P PREROUTING ACCEPT
#Chgt d e p olitique pour
- t n at - P POSTROUTING ACCEPT
- t n at - P OUTPUT ACCEPT
-t
-t
-t
-t
m a n gle
m a n gle
m a n gle
m a n gle
#Ch gt d e politique pour
#Pout la p asse relle elle m e m e
-F
-X
- P PREROUTING ACCEPT
- P OUTPUT ACCEPT
#O p ti mise la connexion
# # # # # # # # # # # # # # # # # # # # # # # # # PAS DE SPOOFING # # # # # # # # # # # # # # # # # # # # # # # #
echo "[Pas de s poofing]"
if [ - e / p r oc / s y s / n et / i p v 4 / c onf / all / r p_filter ] ; th en
for filtre in / p r oc / s y s / n e t / i p v 4 / c onf /* / r p_filter
do
echo 1 > $filtre
done
fi
# # # # # # # # # # # # # # # # # # # # # PAS DE SYNFLOOD # # # # # # # # # # # # # # # # # # # # # # # # # #
echo "[Pas de s ynflood]"
if [ - e / p r oc / s y s / n et / i p v 4 / t c p_s yncookies ] ; then
echo 1 > / p r oc / s y s / n et / i p v 4 / t c p_s yncookies
fi
# # # # # # # # # # # # # # # # # # # # # # # # # PAS DE PING # # # # # # # # # # # # # # # # # # # # # # # # # # #
# co m m en te z ces 6 lignes, si v ous au torise z les pin gs sur v ot re p a sser elle
echo "[Pas ping]"
echo 1 > / p r oc / s y s / n et / i p v 4 / ic m p_echo_ignore_all
echo 1 > / p r oc / s y s / n et / i p v 4 / ic m p_echo_ignore_broa dc asts
if [ - e / p r oc / s y s / n et / i p v 4 / ic m p_ignore_bogus_error_res ponses ] ; then
echo 1 > / p r oc / s y s / n et / i p v 4 / ic m p_ignor e_bogus_error_res ponses
fi
# # # # # # # # # # # # # # # # # # # CONNECTION SSH # # # # # # # # # # # # # # # # # # # # # # # # # #
echo "[Connection SSH Dis ponible ]"
ipt a bles - A INPUT - p tc p - - d p ort 2 2 3 3 3 - j ACCEPT
#Priorité aux connexions ssh
ipt a bles - A PREROUTING - t m a n gle - p tcp - - s port 2 2 3 3 3 - j TOS - - set - tos
Mini mi z e - Dela y
# # # # # # # # # # # # # # # # # # # # # # CONNECTION FTP # # # # # # # # # # # # # # # # # # # # # # # #
echo "[Connection FTP Disponible ]"
ipt a bles - A INPUT - p tc p - - d p ort 2 1 3 8 2 - j ACCEPT
#Priorité aux connexions ft p
ipt a bles - A PREROUTING - t m a n gle - p tcp - - s port 2 1 3 8 2 - j TOS - - set - tos
Mini mi z e - Dela y
# # # # # # # # # # # # # # # # # AUTORISATION DU FORWARD 8 0 # # # # # # # # # # # # # # # #
echo "[Ser veu r a p ache visible de puis internet ]"
ipt a bles - A INPUT - p tc p - - d p ort 8 0 - j ACCEPT
# # # # # # # # # # # # # # # # # AUTORISATION DU PORT 2 2 0 8 0 # # # # # # # # # # # # # # # # #
echo "[Ser veu r NTOP accessible ]"
ipt a bles - A INPUT - p tc p - - d p ort 2 2 0 8 0 - j ACCEPT
# # # # # # # # # # # # # # # # # # # # # AUTORISATION SMTP 2 5 # # # # # # # # # # # # # # # # # # #
echo "[Ser veu r m ail autorise ]"
ipt a bles - A INPUT - p tc p - - d p ort 2 5 - j ACCEPT
#i pt a bles - A OUTPUT - o eth 0 - p tcp - - s port 1 0 2 4: - - d p ort 2 5 - m st ate - - state !
INVALID - j ACCEPT
#i pt a bles - A INPUT - i eth 0 - p tc p - - s por t 2 5 - - d por t 1 0 2 4: - m st ate - - st at e
RELATED,ESTABLISHED - j ACCEPT
# # # # # # # # # # # # # # # # # # # # AUTORISATION DNS 5 3 # # # # # # # # # # # # # # # # # # # # # #
echo "[Ser veu r DNS fonctionnel ]"
ipt a bles - A INPUT - p ud p - - d p ort 5 3 - j ACCEPT
#i pt a bles - A OUTPUT - o eth 0 - p u d p - - s por t 1 0 2 4: - - d p ort 5 3 - m st at e - - st at e !
INVALID - j ACCEPT
#i pt a bles - A INPUT - i eth 0 - p u d p - - s port 5 3 - - d p ort 1 0 2 4: - m st ate - - st ate
RELATED,ESTABLISHED - j ACCEPT
# # # # # # # # # # # # # # # # # # # # # FIN DU FIREWALL # # # # # # # # # # # # # # # # # # # # # # #
echo "[fire w all activé !]"
}
fire w all_stop() {
ipt a bles
ipt a bles
ipt a bles
ipt a bles
ipt a bles
-F
-X
- P INPUT ACCEPT
- P FORWARD ACCEPT
- P OUTPUT ACCEPT
ipt a bles
ipt a bles
ipt a bles
ipt a bles
ipt a bles
-t
-t
-t
-t
-t
n at
n at
n at
n at
n at
ipt a bles
ipt a bles
ipt a bles
ipt a bles
-t
-t
-t
-t
m a n gle
m a n gle
m a n gle
m a n gle
-F
-X
- P PREROUTING ACCEPT
- P POSTROUTING ACCEPT
- P OUTPUT ACCEPT
-F
-X
- P PREROUTING ACCEPT
- P OUTPUT ACCEPT
echo " [fire w all d escativé! ]"
}
fire w all_rest ar t() {
fire w all_stop
slee p 2
fire w all_start
}
case "$1" in
'start')
fire w all_start
;;
'stop')
fire w all_stop
;;
'rest art')
fire w all_rest ar t
;;
'status')
ipt a bles - L
ipt a bles - t n at - L
ipt a bles - t m a n gle - L
;;
*)
echo "Usage: fire w all {start |s to p | r est ar t |st atus}"
es ac
****************************** FIN DU FIREWALL ************************************
Puis ajou ter u n lien sy m bolique d a n s rc.d p o ur q u'il s oit lancé a chaq ue de m a rrage :
d e dib ox: / # ln - s / e t c / i nit.d / fire wall.sh / e t c / rc 2.d /S 1 2fire wall
V) Configuration avancé
1) Postfix
Création d u fichier de s aliases « / e tc / p o s tfix / aliases »
Le fichier de s alias per m et de re - diriger u ne a d res se vers u ne a ut re boite (même exter ne)
o u d’écrire
u ne m ê m e a dres se so u s pl usieur s for mes.
La création de la table de s aliases s’effect ue avec la co m m a n de s pécifique « p os talias » et
en m e t t a nt le signe « : » co m m e sé parateu r de colon ne alors q ue les au tres tables
(canonical, tra n s por t...)
s o nt créées avec la co m m a n de « p os t m a p » s a ns le signe « : » co m m e sé parateur :
Éditer le fichier « / e tc / p o s tfix / aliases » et s aisir les infor m a tions so u s la for me s uivante :
root :
pglinux
pglinux :
to ny.gal [email protected] m
tg :
to ny.gal [email protected] m
Créer la ta ble à p a rtir d u fichier texte :
d e dib ox: / # p o stalias / e t c / p o s tfix / alias e s
ATTENTION : Après chaq ue m o dification de ce fichier, il faut recréer la table et recharger
le fichier de configura tion :
d e dib ox: / # p o stalias / e t c / p o stfix / alias e s
d e dib ox: / # / e t c / i nit.d / p o stfix reload
Création d u ficher de ré - écrit ure de l’adresse de l’expé dite ur.
L’utilisation de ce fichier es t facultatif p o u r le fonction ne me nt de « Postfix »
Éditer le fichier / e tc / p o s tfix / ca no nical et s aisir les infor m a tions s o us la for m e s uivante :
tg
t o [email protected] m
Créer la ta ble à p a rtir d u fichier texte :
d e dib ox: / # p o st map / e t c / p o stfix / can onical
ATTENTION : Après chaq ue m o dification de ce fichier, il faut recréer la table et recharger
le fichier de configura tion :
d e dib ox: / # p o st map / e t c / p o stfix / can onical
d e dib ox: / # / e t c / i nit.d / p o stfix reload
Création d u fichier de s m o de s d e t ra n s por t.
Ce fichier pe r m e t de s pécifier u n m o de de t ra n s por t différent de « SMTP » ou u n relais
SMTP s pécifique en fonction de chaq ue d o m aine.
Éditer le fichier « / e tc / p o s tfix / t r a ns p or t » et s aisir les infor m ations s o us la for me
s uivante :
d o m aine1.co m
local:
d o m aine2.co m
s m t p : 10.2.2.1
Créer la ta ble à p a rtir d u fichier texte :
d e dib ox: / # p o st map / e t c / p o stfix / tran s p ort
ATTENTION : Après chaq ue m o dification de ce fichier, il faut recréer la table et recharger
le fichier de configura tion :
d e dib ox: / # p o st map / e t c / p o stfix / tran s p ort
d e dib ox: / # / e t c /r c.d / i nit.d / p o stfix reload
Cons ultation des logs
Lire les logs des m e s s ages envoyés :
d e dib ox: / # tail - f / v ar / l o g / m ail / inf o
Com p ter les m e s sages deffere d pa r Pos tfix :
d e dib ox: / # find / v ar / s p o ol / p o s fix / d e ff ered - t yp e f | w c
*********************** FICHIER POSTFIX m ain.cf ****************************
# See / u s r / s h ar e / p ostfix / m ain.cf.dist for a co m m e nte d, m o r e co m plete v e rsion
s m t p d_banner = Ser veur d e De v B4OS / / ESMTP
biff = no
# Repertoires d'inst allation d e Postfix:
co m m a n d_director y = / u s r / s bin
d a e m on_director y = / u s r / li b / p ostfix
p ro gr a m_director y = / u s r / lib / p o s tfix
queue_director y = / v a r / s p ool / p ostfix
#Mise en place d es Per missions
set gid_grou p = post dro p
m ail_owner = p ostfix
#Configur ation m a chine
m y h ostn a m e = de v 4 ror.b 4os.fr
m y d o m ain = b 4os.fr
m a s quer a d e_do m ains = b 4 os.fr
m y n et w or ks = 1 2 7.0.0.0 / 8
#Par a m et r es d'en voi des courriers
m y o rigin = $ m y do m ain
d ef ault_tr ans por t = s m t p
alias_m a ps = h ash: / e tc / aliases
alias_dat a b as e = h ash: / e tc / aliases
m y d estination = $ m y h ostn a m e, localhost.$ m y d o m ain, $ m y d o m ain, localhost
# rela y host = s m t p.free.fr
# m ailbox_co m m a n d = p r oc m ail - a "$EXTENSION"
# m ailbox_si z e_li mit = 0
# recipient_deli miter = +
inet_interfaces = all
2) Installation postfix TLS - SASL
d e dib ox: / # apt - g et in stall p o stfix - tls lib sa sl 2 lib sa sl 2 - m o d ule s sa sl 2 - bin
o p e n s sl
Généro ns le certificat SSL valable 1 an p o u r le TLS de p o s tfix :
d e dib ox: / # cd / e t c / p o stfix
d e dib ox: / # o p e n s sl req - n e w - outf orm PEM - o ut / e t c / p o stfix / s mt p d.cert
- n e w k e y rsa:20 4 8 - n od e s - k e y o ut / e t c / p o stfix / s m t p d.k e y - k e y f or m
PEM - da y s 3 6 5 - x 5 0 9
Répo n d e z a ux q uelques q ue s tions de m a n dées, la pl us im por ta n te éta nt : "Com m o n Na me (eg,
YOUR na m e) :", o ù il fau d ra indiquer le FQDN de votre m achine (machine.do m aine.org).
Cou nt ry Name (2 letter code) [AU]: = > FR
State or Province Name (full n a m e) [Some - State] : FRANCE
Locality Name (eg, city) : BORDEAUX
Organi zation Na me (eg, co m p a ny) [Inter net Widgits Pty Ltd] : B4OS
Organi zational Unit Na me (eg, section) : SSLL
Com m o n Name (eg, YOUR na m e) :dev4ror.b4os.fr
Email Addres s : pierre.fauq ue m [email protected]
Corrigeon s m ainte na n t les d r oits s u r le fichier de la clé p o ur éviter q u'u n u tilisateu r m al
inte ntion né vienne la lire.
d e dib ox: / # ch m o d o = / e t c / p o stfix / s m t pd.k e y
Ajoute z l'utilisateu r p os tfix a u grou pe sa sl, ceci per m et tra à p o s tfix d'aller dialoguer avec
saslaut h d grâce a u socket u nix / v a r / r u n / s a sla ut h d / m ux.
d e dib ox: / # addu s er p o stfix sa sl
Passon s m ai ntena nt à la configuration d e s aslaut h d :
Edite z le fichier / e tc / d efa ult / s a slaut h d :
Déco m m e n te z START =yes en enlevant le # en dé b ut de ligne.
Spécifiez : MECHANISMS="pa m s ha dow".
Pour q ue p o s tfix p uisse lire le fichier / e tc / s ha dow :
d e dib ox: / # addu s er p o stfix s had o w
Ensuite crée z le ré per toire / e tc / p o s tfix / s asl :
d e dib ox: / # m k dir / e t c / p o stfix / s a sl && ch o w n root:po stfix
/ e t c / p o stfix / s a sl
Et crée z y le fichier s m t p d.conf conte na n t :
pwcheck_met ho d: sa sla ut h d
m ec h_list: plain login
allow_plaintext: tr ue
On indique m ainte na nt à PAM q ue l'on désire u tiliser u ne a ut he n tification de type UNIX
. Ceci se fait en crea nt le fichier / e tc / p a m.d / s m t p :
#
# The PAM configuration file for t he s m t p service
#
# The s ta n da r d Unix au t he n tication m o d ules, u se d with
# NIS (man n s switch) as well as n or m al / e t c / p a s sw d an d
# / e tc / s h a dow en tries.
@include co m m o n - au t h
@include co m m o n - accou nt
@include co m m o n - ses sion
@include co m m o n - pa s swor d
Il faut m ai nte na nt m o difier le fichier / e tc / p o s tfix / m a s ter.cf en deco m m e n t a n t cette ligne :
smtps
inet n
n
s m t p d_sasl_aut h_enable =yes
-
-
s m t p d - o s m t p d_tls_wra p per m o de =yes - o
Et finisson s avec la configuration de p o s tfix :
Editons le fichier / e tc / p o s tfix / m ai n.cf, et ajout o n s :
s m t p d_recipient_res trictions = per mit_mynetworks, per mit_sasl_aut hen ticate d,
reject_una u t h_des tination
s m t p d_sasl_aut h_enable = yes
broken_sasl_aut h_client s = yes
s m t p d_use_tls = yes
s m t p d_tls_cert_file = / e tc / p o s tfix / s m t p d.cert
s m t p d_tls_key_file = / e tc / p o s tfix / s m t p d.key
s m t p d_sasl_local_do m ain = $ myhos t na m e
s m t p d_sasl_security_options = n oa no ny m o u s
* on crée u n ré pert oire / v a r / r u n d a n s / v a r / s p ool / p o s tfix
d e dib ox: / # m k dir - p / v ar / s p o ol / p o stfix / v ar /run
* on dé place / v a r / r u n / s a slaut h d d a n s / v a r / s p o ol / p o s tfix /var / r u n
d e dib ox: / # m v / v ar /ru n / s a slauthd / v ar / s p o ol / p o stfix / v ar /run
* on crée u n lien sy m bolique de / v a r / s p ool / p o s tfix /var / r u n / s a slau t h d vers / v a r / r u n
d e dib ox: / # ln - s / v ar / s p o ol / p o stfix / v ar /run / s a slauthd
/ v ar /run / s a slauthd
Enfin, re dé m arro ns le to u t :
d e dib ox: / # / e t c / i nit.d / p o stfix re start
d e dib ox: / # / e t c / i nit.d / s a slauthd re start
Voila ! Il ne vous res te pl u s q u'à configurer votre client m ail favori p o u r se con necter en TLS
avec a ut he ntification "PLAIN", y indiquer votre login et votre m o t de p a s se.
3) Script de creation d'utilisateur
#! / bin / b as h
if [ $UID - eq 0 ]
then
if [ ! $ 3 ]
then
echo "Usage: ` b a s en a m e $ 0 `
exit 1
fi
no m_utilisateur
m o t_de_passe
no m_du_proj et"
#V aria ble intialisation
user ="$1"
p ass ="$2"
p roj ect ="$3"
#Cre ation de l'utilisateur
/ u s r / s bin / u s er a d d - g r ailers - s / b i n / f alse $user
#Met a jour le m o t d e p asse
echo $u ser:$p ass | / u s r / s bin / c h p ass w d
if g r e p - E "^$user:" / e t c / p a ss w d > / d e v / n ull ;
then
echo "Utilisateur $u ser cree a v ec succes"
else
echo "L'utilisateur $ us er n'a p as pu etre cree"
exit 1
fi
#Cre ation de son r e pe rtoire d'acceuil
/ b i n / m k dir / h o m e / $ u ser
/ b i n / c ho w n $ us er / h o m e / $ u s er
if [ - d / h o m e / $ us er ]
then
echo "Le re pertoire / h o m e / $ u ser est cree"
else
echo "Le re pertoire / h o m e / $ u ser n'a p a s pu et re cree"
exit 1
fi
#Cre ation de son co m p t e MYSQL
sql ="CREATE DATABASE $ p r oject;"
sql ="$sql GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP"
sql ="$sql ON $ p r oj ect . * TO '$user'@'%' IDENTIFIED BY '$pass'"
#fichier te m p or aire
echo "$sql" > te m p.s ql
#lance m ent de la re quet e
echo "Com pte MYSQL créer"
/ u s r / bin / m y s ql - u r ails - p 6 v d ela p 1 m y s ql < te m p.sql
# eff acer le fichier te m p or aire
r m te m p.s ql
#Cree le co m p t e FTP
echo " Cre ation du co m p t e FTP "
cp / e tc / p r oft p d.conf / t m p / p r oft p d.txt
se d - e 1 3 2"i \ AllowUser $ us er" / t m p / p r oft p d.txt > / t m p / p r oft p d.t m p
cp / t m p / p r oft p d.t m p / e t c / p r oft p d.conf
# On r elance le ser vice ft p
echo " Relance le ser vice FTP "
/ e t c / i nit.d / p r oft p d reloa d
#Cre ation du quot a d e dis que
echo " Cre ation du quot a d e dis que "
/ u s r / s bin / e d quot a - p kin de r $user
# Cre ation du dossier de logs a p ache et w e b ali z er
/ b i n / m k dir - m 7 7 7 / v a r / l o g / a p ache 2 / e r ror / $ p r oject
/ b i n / m k dir - m 7 7 7 / v a r / l o g / a p ache 2 / a ccess / $ p r oject
/ b i n / m k dir - m 7 7 7 / v a r / w w w / w e b ali z er / $ p r oject
#Creer un hote virtuel p our APACHE
echo " Cree un hote virtuel "
text =" <Virtu alHost *:80 > \ n"
text ="$text Serv erNa m e $ p r oject \ n"
text ="$text Serv erAlias $ p r oj ect.b4os.fr \ n"
text ="$text Docu m entRoot / v a r / w w w / $ p r oject / p u blic / \ n"
text ="$text ErrorLog / v a r / l o g / a p ache 2 / e r ror.log \ n"
text ="$text ErrorLog / v a r / l o g / a p ache 2 / e r ror / $ p r oject / e r ror.log \ n"
text ="$text Custo mLog / v a r / l o g / a p ache 2 / a ccess.log co m bined \ n"
text ="$text Custo mLog / v a r / l o g / a p ache 2 / a ccess.vhost.log co m bine d v host \ n"
text ="$text Custo mLog / v a r / l o g / a p ache 2 / a ccess / $ p r oj ect / a ccess.log co m bine d
\ n"
text ="$text Custo mLog / v a r / l o g / a p ache 2 / a ccess / $ p r oj ect / a ccess.vhost.log
co m bine d vh ost \ n"
text ="$text Serv erPath / v a r / w w w / $ p r oj ect / p u blic / \ n"
text ="$text SetEnv RAILS_ENV p r o duction \ n"
text ="$text < Di rector y / v a r / w w w / $ p r oject / p u blic / > \ n"
text ="$text
O ptions ExecCGI FollowSy mLinks \ n"
text ="$text
Ad dH an dler fcgid - script .fcgi \ n"
text ="$text
Allow O v e rride all \ n"
text ="$text
Or der allow,den y \ n"
text ="$text
Allow fro m all \ n"
text ="$text < / Dir ector y > \ n"
text ="$text < / Virtu alHost > \ n"
echo - e "$text" > / e t c / a p ache 2 / sites - a v aila ble / $ p r oject
#Aj out d ans Logrot at e
echo " Ajout d ans Logrot ate "
insert =" \ n #Projet $ p r oj ect \ n"
insert ="$insert / v a r / l o g / a p ache 2 / a ccess / $ p r oj ect /*.log { \ n"
insert ="$insert w e e kl y \ n"
insert ="$insert m issingo k \ n"
insert ="$insert rot ate 5 2 \ n"
insert ="$insert co m p r ess \ n"
insert ="$insert dela yco m p r ess \ n"
insert ="$insert notife m p t y \ n"
insert ="$insert cre ate 6 4 0 root a d m \ n"
insert ="$insert sh are dscri pts \ n"
insert ="$insert postrot ate \ n"
insert ="$insert / e t c / i nit.d / a p ache 2 reloa d > / d e v / n ull \ n"
insert ="$insert
insert ="$insert
en dscript \ n"
} \ n \ n"
echo - e "$insert" > > / e t c / l og rot at e.d / a p ache 2
#Aj out du fichier w e b ali z er conf p ou r le p r ojet
#Aj out d ans w e b ali z er d aily
echo " Ajout d ans w e b ali z er d aily "
d aily ="#! / bin / s h"
d aily ="$d aily \ n #Po w er e d b y B4OS \ n"
d aily ="$d aily \ nWEBALIZER_BIN = / u s r / bin / w e b ali z er"
d aily ="$d aily \ nWEBALIZER_CONF = / e tc / w e b ali z er / c onf / $ p r oject.conf \ n"
d aily ="$d aily \ n # See if the w e b ali z er bin ar y a n d config file exists"
d aily ="$d aily \ n[ - f \ ${WEBALIZER_BIN} ] | | exit 0"
d aily ="$d aily \ n[ - f \ ${WEBALIZER_CONF} ] | | exit 0 \ n"
d aily ="$d aily \ n # Figure out non - rot ate d logfile"
d aily ="$d aily \ n nonrot at e dlog = \ ` e g r e p '^LogFile' \ $WEBALIZER_CONF | \"
d aily ="$d aily \ n s e d - e 's /[[:space:]] \ + / / ' | \"
d aily ="$d aily \ n cut - d ' ' - f2 | \"
d aily ="$d aily \ n s e d - e 's / \ .[[:digit:]][ \.g z]* \ $ / / ' \ ` \ n"
d aily ="$d aily \ n # Can w e r e a d it? "
d aily ="$d aily \ n[ - r \ ${ nonrot at e dlog} ] | | exit 0 \ n"
d aily ="$d aily \ n # Check for e m p t y logfile"
d aily ="$d aily \ nlogs z = \ ` e cho \ ${ nonrot ate dlog} | \"
d aily ="$d aily \ n s e d - e 's /[[:space:]] \ + / / ' | \"
d aily ="$d aily \ n cut - d ' ' - f2 | \"
d aily ="$d aily \ nxar gs ls - l | \"
d aily ="$d aily \ n s e d - e 's /[[:space:]] \ + / / g' | \"
d aily ="$d aily \ n cut - d ' ' - f5 \ `"
d aily ="$d aily \ n[ \ $ l o gs z - gt 0 ] | | exit 0 \ n"
d aily ="$d aily \ n # Run w e b ali z e r quietl y"
d aily ="$d aily \ n \ ${WEBALIZER_BIN} - c \ ${WEBALIZER_CONF} - q \ ${nonrot ate dlog}
\ n"
d aily ="$d aily \ n # Exit with w e b ali z e r's exit code"
d aily ="$d aily \ n exit \ $? "
echo - e "$daily" > / e t c / w e b ali z er / c r on.daily / $ p r oject
#Aj out d ans w e b ali z er w e e kl y
echo " Ajout d ans w e b ali z er w e e kl y "
w e e kly ="#! / bin / s h"
w e e kly ="$ wee kl y \ n #Po w ere d b y B4OS \ n"
w e e kly ="$ wee kl y \ nWEBALIZER_BIN = / u s r / bin / w e b ali ze r"
w e e kly ="$ wee kl y \ nWEBALIZER_CONF = / e tc / w e b ali ze r / c onf / $ p r oject.conf \ n"
w e e kly ="$ wee kl y \ n # See if the w e b ali z er binar y a n d config file exists"
w e e kly ="$ wee kl y \ n[ - f \ ${WEBALIZER_BIN} ] | | exit 0"
w e e kly ="$ wee kl y \ n[ - f \ ${WEBALIZER_CONF} ] | | exit 0 \ n"
w e e kly ="$ wee kl y \ n # Figure out non - rot ate d logfile"
w e e kly ="$ wee kl y \ n \ ${log} = \ ` e g r e p '^LogFile' \ $ WEBALIZER_CONF | \"
w e e kly ="$ wee kl y \ n s e d - e 's /[[:space:]] \ + / / ' | \"
w e e kly ="$ wee kl y \ n cut - d ' ' - f2 | \"
w e e kly ="$ wee kl y \ n s e d - e 's / \ .[[:digit:]][ \.g z]* \ $ / / ' \ ` \ n"
w e e kly ="$ wee kl y \ n # Can w e r e a d it? "
w e e kly ="$ wee kl y \ n[ - r \ ${ \ ${log}} ] | | exit 0 "
w e e kly ="$ wee kl y \ n # Check for e m p t y logfile "
w e e kly ="$ wee kl y \ nlogs z = \ ` e c ho \ ${ \ ${log}} | \ "
w e e kly ="$ wee kl y \ n s e d - e 's /[[:space:]] \ + / / ' | \ "
w e e kly ="$ wee kl y \ n cut - d ' ' - f2 | \ "
w e e kly ="$ wee kl y \ nxar gs ls - l | \ "
w e e kly ="$ wee kl y \ n s e d - e 's /[[:space:]] \ + / / g' | \ "
w e e kly ="$ wee kl y \ n cut - d ' ' - f5 \ ` "
w e e kly ="$ wee kl y \ n[ \ $ l o gs z - gt 0 ] | | exit 0 \ n"
w e e kly ="$ wee kl y \ n # Run w e b ali z e r quietl y"
w e e kly ="$ wee kl y \ n \ ${WEBALIZER_BIN} - c \ ${WEBALIZER_CONF} - q \ ${ \ ${log}} \ n"
w e e kly ="$ wee kl y \ n # Exit with w e b ali z e r's exit code"
w e e kly ="$ wee kl y \ n exit \ $? "
echo - e "$wee kly" > / e tc / w e b ali z er / c r on.weekl y / $ p r oject
#Ren dr e ces fichiers execut a ble
/ b i n / c h m o d 7 5 5 / e tc / w e b ali z e r / c r on.d aily / $ p r oj ect
/ b i n / c h m o d 7 5 5 / e tc / w e b ali z e r / c r on.wee kl y / $ p r oject
#Creer le fichier d e conf
conf ="# Webali z e r configur ation file"
conf ="$conf \ n #For $ p r oject.b4os.fr do m ain"
conf ="$conf \ n #Po w er e d b y B4OS \ n"
conf ="$conf \ nLogFile / v a r / l o g / a p ache 2 / a ccess / $ p r oj ect / a ccess.log.1"
conf ="$conf \ n Out putDir / v a r / w w w / w e b ali z e r / $ p r oject"
conf ="$conf \ nRe por tTitle Statistiques pour"
conf ="$conf \ nHostNa m e $ p r oj ect.b 4os.fr \ n"
conf ="$conf \ n #Referers a cacher"
conf ="$conf \ nHideRefer rer *.b4os.fr"
echo - e "$conf" > / e tc / w e b ali z er / c onf / $ p r oj ect.conf
#Cree le re p ertoire du site
echo " Cree un lien s y m b olique entr e le r e pe rtoire d e l'utilisateur "
echo " Et le che min d'acces d u re pertoire pu blic a p ache "
ln - s / h o m e / $ us er / v a r / w w w / $ p r oject
#Acti ve l'hote virtuel
echo "Active l'hote virtuel"
/ u s r / s bin / a 2 ensite $ p roject
#Relance APACHE
echo " Relance le ser vice A p ache "
/ e t c / i nit.d / a p ache 2 reloa d
#Enre gistr e m ent DNS d ans la z o ne locale Zieute
echo " Enregistre le p r ojet d an s la z on e DNS "
echo - e "$project IN A 8 8.1 9 1.2 1.1 5 1" > > / e t c / bin d / d b.b 4os.fr
#Rech ar g e le DNS
echo " Rechar ge la z on e DNS "
/ e t c / i nit.d / bin d 9 r eloa d
else
echo "Vous n'ave z p as les dr oits necess aires"
fi
4) Script de suppression d'utilisateur
#! / bin / b as h
if [ $UID - eq 0 ]
then
if [ ! $ 2 ]
then
echo "Usage: ` b a s en a m e $ 0 `
exit 1
fi
no m_utilisateur no m_du_projet"
#V aria ble intialisation
user ="$1"
p roj ect ="$2"
#Su p pr ession d e l'utilisateur
/ u s r / s bin / u s er del $user
#Su p pr ession d e son re p ertoire d'acceuil
/ b i n / r m / v a r / w w w / $ p r oj ect
/ b i n / r m - Rf / h o m e / $ u ser
if [ - d / h o m e / $ us er ]
then
echo "Le re pertoire / h o m e / $ u ser est toujours exist ant"
exit 1
else
echo "Le re pertoire / h o m e / $ u ser est su p p ri m é"
fi
#Su p pr ession d e son co m p t e MYSQL
sql ="DROP DATABASE $ p r oj ect;"
sql ="$sql REVOKE ALL PRIVILEGES, GRANT OPTION FROM $user;"
sql ="$sql DROP USER $user;"
#fichier te m p or aire
echo "$sql" > te m p.s ql
#lance m ent de la re quet e
echo "Suppr ession du co m p t e MYSQL"
/ u s r / bin / m y s ql - u r ails - p 6 v d ela p 1 m y s ql < te m p.sql
# eff acer le fichier te m p or aire
/ b i n / r m te m p.s ql
#Su p pr ession du co m p te FTP
echo " Suppr ession du co m pt e FTP "
cptft p = ` / bi n / s e d - n "/^Allo wUser $user / =" / e t c / p r oft p d.conf `
if [ ! $c ptft p ]
then
echo "Utilisateur non inscrit d ans Proft p"
else
/ b i n / s e d "$cptft p d" / e t c / p r oft p d.conf > / t m p / c p t ft p
cp / t m p / c p tft p / e t c / p r oft p d.conf
fi
# On r elance le ser vice ft p
echo " Relance le ser vice FTP "
/ e t c / i nit.d / p r oft p d reloa d
# Sup pression du d ossier d e logs a p ache et w e b ali z er
/ b i n / r m - Rf / v a r / l o g / a p ach e 2 / e r r or / $ p r oject
/ b i n / r m - Rf / v a r / l o g / a p ach e 2 / a ccess / $ p r oject
/ b i n / r m - Rf / v a r / w w w / w e b ali z er / $ p r oj ect
#Su p pr ession d a ns Logrot ate
echo " Suppr ession d a ns Logrot ate "
ligne = ` / bi n / s e d - n "/Projet $ p r oj ect / =" / e t c / l og rot at e.d / a p ache 2 `
if [ ! $ligne ]
then
echo "Projet non inscrit d a ns logrot ate"
else
/ b i n / s e d "$ligne,$(($ligne + 1 3))d" / e t c / l ogr ot at e.d / a p ache 2 > / t m p / l o g rot ate
cp / t m p / l o gr ot ate / e tc / lo gr ot ate.d / a p ache 2
fi
#Su p pr ession d a ns w e b ali z e r d ail y
/ b i n / r m - f / e t c / w e b ali z e r / c r on.daily / $ p r oject
#Su p pr ession d a ns w e b ali z e r w e e kl y
/ b i n / r m - f / e t c / w e b ali z e r / c r on.wee kly / $ p r oject
#Su p pr ession du fichier d e conf
/ b i n / r m - f / e t c / w e b ali z e r / c onf / $ p r oject.conf
#Des acti ve l'hote virtuel
echo "desacti ve l'hote virtuel"
/ u s r / s bin / a 2 dissite $ p r oject
#Su p pr ession d e l'hote virtuel
echo " Suppr ession d e l'hote virtuel "
/ b i n / r m - f / e t c / a p ache 2 / sites - a v ailable / $ p r oject
#Relance APACHE
echo " Relance le ser vice A p ache "
/ e t c / i nit.d / a p ache 2 reloa d
#Su p pr ession DNS d ans la z on e locale b 4 os
echo " Suppr ession du p r ojet d a ns la z o ne DNS "
no m dn s = ` / bi n / s e d - n "/^$ project / =" / e t c / bin d / d b.b 4os.fr `
if [ ! $ no m dns ]
then
echo "Projet non inscrit d a ns la z on e dns"
else
/ b i n / s e d "$no m d ns d" / e t c / bin d / d b.b 4os.fr > / t m p / n o m d ns
cp / t m p / n o m d ns / e t c / bin d / d b.b 4os.fr
fi
#Rech ar g e le DNS
echo " Rechar ge la z on e DNS "
/ e t c / i nit.d / bin d 9 r eloa d
else
echo "Vous n'ave z p as les d r oits necess aires"
fi
5) Configuraion de Logrotate
Cree 3 d o s siers a la racine de / e tc / webalizer /
* conf
* cron.daily
* cron.weekly
Prene z le fichier / e tc / cro n.daily / webalizer et sa uvegar de z le
( /e tc / webalizer / webalizer.cron.daily.old).
Modifie z ens uite le fichier / e tc / cr o n.daily /webalizer de cet te façon :
#! / bin / s h
run - p a rts - - r e por t / e t c / w e b ali z e r / c r on.dail y
Ide m p o u r le fichier / e t c / c ro n.weekly / webalizer, sa uvegar de z le p uis m o difiez le :
#! / bin / s h
run - p a rts - - r e por t / e t c / w e b ali z e r / c r on.wee kl y
On cree de ux fichiers p o u r l'analyse de to u tes les z o nes :
a) dans / e tc / webalizer /cron.daily /all
#! / bin / s h
#Pow er e d b y B4OS
WEBALIZER_BIN = / u s r / bin / w e b ali z er
WEBALIZER_CONF = / e tc / w e b ali z er / c onf / all.conf
# See if the w e b ali ze r bin ar y an d config file exists
# if not, exit without w a rning to p r e v ent d aily m ails
[ - f ${WEBALIZER_BIN} ] | | exit 0
[ - f ${WEBALIZER_CONF} ] | | exit 0
# Figure out non - rot ate d logfile
nonrot ate dlog = ` e g r e p '^LogFile' $WEBALIZER_CONF | \
se d - e 's /[[:space:]] \ + / / ' | \
cut - d ' ' - f2 | \
se d - e 's / \ .[[:digit:]][ \.g z]*$ / / ' `
# Can w e re a d it?
[ - r ${nonrot ate dlog} ] | | exit 0
# Check for e m p t y logfile
logs z = ` e c ho ${nonrot ate dlog} | \
se d - e 's /[[:space:]] \ + / / ' | \
cut - d ' ' - f2 | \
xar gs ls - l | \
se d - e 's /[[:space:]] \ + / / g' | \
cut - d ' ' - f5 `
[ $logs z - gt 0 ] | | exit 0
# Run w e b ali z er quietl y
${WEBALIZER_BIN} - c ${WEBALIZER_CONF} - q ${nonrot ate dlog}
# Exit with w e b ali z er's exit code
exit $?
b) dans / e tc / webalizer /cron.weekly /all
#! / bin / s h
#Pow er e d b y B4OS
WEBALIZER_BIN = / u s r / bin / w e b ali z er
WEBALIZER_CONF = / e tc / w e b ali z er / c onf / all.conf
# See if the w e b ali ze r bin ar y an d config file exists
# if not, exit without w a rning to p r e v ent d aily m ails
[ - f ${WEBALIZER_BIN} ] | | exit 0
[ - f ${WEBALIZER_CONF} ] | | exit 0
# Figure out non - rot ate d logfile
${log} = ` e g r e p '^LogFile' $WEBALIZER_CONF | \
se d - e 's /[[:space:]] \ + / / ' | \
cut - d ' ' - f2 | \
se d - e 's / \ .[[:digit:]][ \.g z]*$ / / ' `
# Can w e re a d it?
[ - r ${${log}} ] | | exit 0
# Check for e m p t y logfile
logs z = ` e c ho ${${log}} | \
se d - e 's /[[:space:]] \ + / / ' | \
cut - d ' ' - f2 | \
xar gs ls - l | \
se d - e 's /[[:space:]] \ + / / g' | \
cut - d ' ' - f5 `
[ $logs z - gt 0 ] | | exit 0
# Run w e b ali z er quietl y
${WEBALIZER_BIN} - c ${WEBALIZER_CONF} - q ${${log}}
# Exit with w e b ali z er's exit code
exit $?
Creation d u d o s sier / v ar / www / webali zer / all
d e dib ox # m k dir - m 7 7 7 / v ar / w w w / w e baliz er / all
et Un fichier p o u r le fichier de conf : / e tc / webalizer / co nf / all.conf
Le fichier de configura tion p o ur TOUS les d o m aines
# Web ali z e r configur ation file
# For all do m ain a bout b 4os.fr
# Power e d b y B4OS
LogFile / v a r / l o g / a p ache 2 / a ccess.log.1
Out putDir / v a r / w w w / w e b ali z e r / all
ReportTitle Statistiques pour Tous les do m aines B4OS
HostNa m e de v 4 ror.b4os.fr
# Referers à cacher
HideRefer rer de v 4 r or.b 4os.fr
# End of configur ation file... Have a nice d a y!
La m a ni p ulation éta nt exacte me n t la m ê me p o ur / e tc / webalizer / c ro n.weekly, je vous laisse
l'acco m plir, re pre ne z pa r contre le fichier / e tc / c ro n.weekly / webalizer q ue vous aviez s a uvé.
Le fichier / e t c / webalizer.conf
Nous allons de créer a ut a n t de fichier d e configura tion q ue de d o m aines, m ais il y a u n
fichier p ri ncipal à créer, q ui contient les directives néces saires à to u s les d o m aines / v ho s t s,
c'est le fichier / e tc / webalizer.conf.
# Sa m ple Web ali ze r configur ation file
# Power e d b y B4OS
LogT y p e w e b
Histor yNa m e w e b ali z e r.hist
Incre m en t al y es
Incre m en t alNa m e w e b ali z er.current
HTMLExtension ht ml
UseHTTPS no
HTMLHea d < META n a m e ="ke y w or ds" content ="we b ali z er">
HTMLBod y <BODY BGCOLOR ="#E8E8E8" TEXT ="#0 0 0 0 0 0" LINK ="#0 0 0 0FF"
VLINK ="#FF00 0 0" >
HTMLPost <BR CLEAR ="all">
HTMLTail B4OS !
HTMLEnd < / B ODY > < / H TML >
Quiet no
ReallyQuiet no
Ti m eMe no
GMTTi m e no
De bu g no
IgnoreHist no
HourlyGr a ph y es
HourlySt ats y es
Countr yGr a ph y es
DailyGr a ph y es
DailySt ats y es
PageT y p e
PageT y p e
PageT y p e
PageT y p e
*.ht m
*.ht ml
*.php
*.w ml
Gra phLegen d y es
Gra phLines 2
VisitTi m eout 1 8 0 0
#Se archEngine est dé j à défini d ans le code p our p as m al d e m o t eurs.
AllAgents y e s
AllReferrers y es
AllSites y es
AllURLs y es
AllSearchStr y es
AllUsers y es
TopSites 2 0
TopKSites 2 0
TopURLs 2 0
TopKURLs 2 0
TopRefer rers 2 0
TopA gents 1 5
TopCountries 2 0
TopEntr y 2 0
TopExit 2 0
TopSe arch 1 5
TopUsers 1 0
# = = = = = SITES = = = = =
HideSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
Grou pSite
*dev 4r or
*aol.co m AOL
*wana doo.fr Wan a doo
*proxa d.net Free
*tiscali.fr Tiscali
*club - internet.fr Club - Internet
*neri m.net Neri m
*minds pring.co m EarthLink
*veri z on.net Veri z on Online
*t - di alin.net T - Online
*co mcast.net Co mc ast
*optonline.co m O pti m u m Online
*sy m p a tico.ca Sy m p a tico.ca
*rogers.co m Rogers
*skynet.be Skynet
*noos.fr Noos
*noos.net Noos
# = = = = = REFERRERS = = = = =
# A cacher sui v ants les do m aines
#HideReferrer m o o m ooc a m p.net
#HideReferrer p o w ah.net
#HideReferrer y a z 0 r.net
#HideReferrer d a r k m oo.net
#HideReferrer dh m 2 0 0 0.or g
# Toujours cachés, p our ceux la.
HideRefer rer
d e v 4r or /
HideRefer rer Direct Request
# Grou pons les
Grou pReferrer
Grou pReferrer
Grou pReferrer
Grou pReferrer
Grou pReferrer
Grou pReferrer
Grou pReferrer
Grou pReferrer
Grou pReferrer
m o teurs d e recherche
y a hoo.co m / Yahoo!
y a hoo.fr / Yahoo!
htt p: / / s e a rch.y ahoo Yahoo!
excite.co m / Excite
infosee k.co m / InfoSee k
w e bcr a wler.co m / WebCr a wler
google.co m / Google
google.fr / Google
htt p: / / w w w.goo gle Google
# Cachons tout ça, p uisqu'il sont gr ou pés juste au dessus
HideRefer rer y ah oo.co m /
HideRefer rer y ah oo.fr /
HideRefer rer htt p: / / s e a rch.y ahoo
HideRefer rer goo gle.co m /
HideRefer rer goo gle.fr /
HideRefer rer htt p: / / w w w.google
HideRefer rer excite.co m /
HideRefer rer infoseek.co m /
HideRefer rer w e bcr a wler.co m /
# = = = = = URLS = = = = =
HideURL
HideURL
HideURL
HideURL
HideURL
HideURL
HideURL
HideURL
HideURL
HideURL
HideURL
*.gif
*.GIF
*.jpg
*.JPG
*.jpeg
*.JPEG
*.png
*.PNG
*.b m p
*.BMP
*.ra
Grou pURL / c gi - bin /*
# = = = = = AGENTS = = = = =
# Créons d es g rou pes p our les b r o w ers, et ne cachons p as les d ét ails.
Grou pA gent MSIE Microsoft Internet Explorer
Grou pA gent Mo zilla
Grou pA gent Lynx
Grou pA gent Wina m p Nullsoft Wina m p
Grou pA gent Googlebot
Grou pA gent Kon queror
Grou pA gent O per a
Grou pA gent FAST - WebCr a wler
Grou pA gent GetRight
Grou pA gent Wget
Grou pA gent Links
Grou pA gent FrontPage
Grou pA gent Scooter
Grou pA gent Mos aic
Grou pA gent DA* Do w nloa d Acceler ator
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
#HideAgent
MSIE
Mo zilla
Lynx
Wina m p
Googlebot
Kon queror
O per a
FAST - WebCr a wler
GetRight
Wget
Links
FrontPage
Scooter
Mos aic
DA*
MangleA gents 4
# Et pour finir qu elques o ptions bi don
IgnoreSite
localhost
IgnoreReferrer
localhost
Grou pSha ding y es
Grou pHighlight y es
6) Installer le Vhost d'accueil + phpmyadmin
Cree le fichier s uivant : / e tc / a p ac he2 / sites - available / accueil
Na m eVirtu alHost *:80
< Virtu alHost *:80 >
Serv erNa m e d e v 4 r or
Serv erAlias de v 4 r or.b 4os.fr
ErrorLog / v a r / l o g / a p ache 2 / w w w_error.log
Custo mLog / v a r / l o g / a p ache 2 / w w w_access.log co m bine d
Redirect p er m a nent / htt p: / / w w w.b 4os.fr
< / Virtu alHost >
< Virtu alHost *:80 >
Ser verNa m e ph p m y a d min
Ser verAlias p h p m y a d min.b 4os.fr
ErrorLog / v a r / l o g / a p ach e 2 / p h p m y a d min_error.log
Custo mLog / v a r / l o g / a p ache 2 / p h p m y a d min_access.log co m bine d
Docu m entRoot / v a r / w w w / p h p m y a d min /
< / Virtu alHost >
Cree le fichier s uivant : / e tc / a p ac he2 / sites - available / www
< Virtu alHost *:80 >
Serv erNa m e w w w
Serv erAlias w w w.b 4os.fr
ErrorLog / v a r / l o g / a p ache 2 / w w w_error.log
Custo mLog / v a r / l o g / a p ache 2 / w w w_access.log co m bine d
Docu m en tRoot / v a r / w w w / w w w / p u blic /
Serv erPath / v a r / w w w / w w w / p u blic /
< Director y / v a r / w w w / w w w / p u blic / >
O ptions ExecCGI FollowSy mLinks
A d dH an dler fcgi d - script .fcgi
Allow O v er ri de all
Or de r allo w,den y
Allow fro m all
< / D irector y >
< / Virtu alHost >
telecharger le p r ojet ici
d e dib ox # cd / v ar / w w w /
d e dib ox # w g et
http: / / pi erre.fauqu e m b ergu e.free.fr / di v ers / rails w w w.tar.gz
d e dib ox # tar z x v f rails w w w.tar.g z
Puis activer les vhost s :
d e dib ox # a2 en site w w w
d e dib ox # a2 en site accu eil
VI) Installation d'outils pour les performances et tests
1) Pour les stats, installer Webalizer (logiciel utilise par Free) :
d edibo x: / # apt - g et in stall w e baliz er
Reading Package Lists... Done
Building Dependency Tree... Done
T he following extra packages will be installed:
libfreetype6 libgd2 - noxp m libjpeg62 libpng12 - 0
Suggested packages:
libfreetype6 - dev libgd - tools
T he following NEW packages will be installed:
libfreetype6 libgd2 - noxp m libjpeg62 libpng12 - 0 webalizer
0 upgraded, 5 ne wly installed, 0 to re move a nd 0 not upgraded.
Need to get 1059kB of archives.
A fter u npacking 3232kB of additional disk space will be used.
Ques tions a l'ins tallation :
Which directory s ho ul d webalizer p u t t he o ut p u t in? = > ' / var / w w w / w e balizer'
Enter t he title of t he re port s webalizer will generate. = > 'Statistique s pour '
What is t he filena m e of t he rot ate d webserver log? = > ' / var /l og / apach e / acc e s s.log.1'
Ass ure z vous q ue votre serveur a pache génère de s log en m o de : co m bine d, da n s votre
fichier h t t p d.conf
Cus to mLog / l ogs / acces s_log co m bine d
Ensuite m o difier le fichier / e t c / webalizer.conf en fonctions des besoins.
Puis p o ur enregistrer cette configuration faite :
d e dib ox: / # $WEBALIZER / bin / w e bali z er - c / e t c / w e baliz er.conf
2) Installation de ntop pour verifier la BP de tous les projets :
d e dibox: / # apt - g et in stall ntop
Reading Package Lists... Done
Building Dependency Tree... Done
T he following NEW packages will be installed:
ntop
0 upgraded, 1 ne wly installed, 0 to re move a nd 0 not upgraded.
Need to get 2402kB of archives.
A fter u npacking 6525kB of additional disk space will be used.
Ques tions a l'ins tallation :
Which interfaces s ho ul d n t o p liste n on? = > 'eth0'
Which is t he n a m e of t he u s er to r u n t he n t o p d ae m o n as ? = > 'ntop'
Inst allation sa ns a ucu n p roble me s u r Debian Sarge ...
Bon alors no t p c'es t sy m pa m ais s a d oc elle es t vrai me n t p a s RTFM frien dly, elle devrait
vrai me nt p réciser ces de ux / t rois t r ucs p o u r éviter de galérer :
si o n lance le d ae m o n :
d e dib ox: / # / e t c / i nit.d / n t op start
Ca m a rc he pa s, le dae m o n pla nte en q uelques secon des ...
- Il faut lancer n t o p à la m ain a u m oi ns u ne fois, p o ur q u'il vous de m a n de u n m o t de pa s se
a d mi n, a près ca ira mie ux :
d e dibo x: / # ntop - u ntop
- u n t o p c'est p o u r dire à n t o p d'u tiliser l'utilisateur sys tè m e "nto p", n t o p ne d oit p a s
t our ner en root
- Après u ne pe tite m o dification de / e tc /i nit.d / n t o p :
#! / b i n / s h
DAEMON =" / usr / s bin / n t o p"
NAME ="ntop"
DESC ="net wor k to p d a e m on"
INIT =" / etc / d ef ault / n to p"
HOMEDIR =" / v a r / li b / n to p"
LOGDIR =" / v a r / l og / n t o p /"
test - f $ DAEMON | | exit 0
test - f $INIT | | exit 0
. $INIT
case "$1" in
st art)
echo - n "Starting $DESC: "
st art - stop - d ae m on - - st art - - quiet - - n a m e $NAME - - exec $DAEMON - - \
- d - L - u $NAME - P $HOMEDIR - - s ki p - v e rsion - check \
- a / v a r / l o g / n t o p / a ccess.log - i "$INTERFACES" \
- w 22080 \
- O $LOGDIR $GETOPT
if ps xa | g re p - v gr e p | gr e p / u s r / s bin / n t o p > / d e v / n ull ; then
echo nto p
else .....
si o n (re)lance le d ae m o n :
d e dib ox: / # / e t c / i nit.d / n t op start
o n d oit p o uvoir accé der à la p age : h t t p: / / a d re s seIPmachine:22080