Serveur Mail · 4 min read · Dec 16, 2025
Le Serveur Parfait - Fedora 11 x86_64 [ISPConfig 2] - Page 4
9 MySQL (5.0)
Pour installer MySQL, nous faisons ceci :
yum install mysql mysql-devel mysql-serverEnsuite, nous créons les liens de démarrage système pour MySQL (afin que MySQL démarre automatiquement chaque fois que le système démarre) et démarrons le serveur MySQL :
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld startMaintenant, vérifiez que le réseau est activé. Exécutez
netstat -tap | grep mysqlCela devrait afficher quelque chose comme ceci :
[root@server1 named]# netstat -tap | grep mysql
tcp 0 0 *:mysql *:* LISTEN 1672/mysqld
[root@server1 named]#Si ce n’est pas le cas, éditez /etc/my.cnf et commentez l’option skip-networking :
vi /etc/my.cnf| [...] #skip-networking [...] |
et redémarrez votre serveur MySQL :
/etc/init.d/mysqld restartExécutez
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpasswordpour définir un mot de passe pour l’utilisateur root (sinon, n’importe qui peut accéder à votre base de données MySQL !).
10 Postfix Avec SMTP-AUTH Et TLS
Maintenant, nous installons Postfix et Dovecot (Dovecot sera notre serveur POP3/IMAP) :
yum install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain postfix dovecotMaintenant, nous configurons SMTP-AUTH et TLS :
postconf -e 'smtpd_sasl_local_domain ='
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'smtpd_sasl_security_options = noanonymous'
postconf -e 'broken_sasl_auth_clients = yes'
postconf -e 'smtpd_sasl_authenticated_header = yes'
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
postconf -e 'inet_interfaces = all'
postconf -e 'mynetworks = 127.0.0.0/8 [::1]/128'Nous devons éditer /usr/lib64/sasl2/smtpd.conf afin que Postfix autorise les connexions PLAIN et LOGIN (sur les systèmes 32 bits, ce fichier se trouve dans /usr/lib/sasl2/smtpd.conf). Il devrait ressembler à ceci :
vi /usr/lib64/sasl2/smtpd.conf| pwcheck_method: saslauthd mech_list: plain login |
Ensuite, nous créons les certificats pour TLS :
mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csropenssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crtopenssl rsa -in smtpd.key -out smtpd.key.unencryptedmv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650Ensuite, nous configurons Postfix pour TLS :
postconf -e 'smtpd_tls_auth_only = no'
postconf -e 'smtp_use_tls = yes'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtp_tls_note_starttls_offer = yes'
postconf -e 'smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key'
postconf -e 'smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt'
postconf -e 'smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem'
postconf -e 'smtpd_tls_loglevel = 1'
postconf -e 'smtpd_tls_received_header = yes'
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'
postconf -e 'tls_random_source = dev:/dev/urandom'Ensuite, nous définissons le nom d’hôte dans notre installation Postfix (assurez-vous de remplacer server1.example.com par votre propre nom d’hôte) :
postconf -e 'myhostname = server1.example.com'Après ces étapes de configuration, vous devriez maintenant avoir un /etc/postfix/main.cf qui ressemble à ceci (j’ai supprimé tous les commentaires) :
cat /etc/postfix/main.cf| queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix mail_owner = postfix inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost unknown_local_recipient_reject_code = 550 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /usr/share/doc/postfix-2.5.6/samples readme_directory = /usr/share/doc/postfix-2.5.6/README_FILES inet_protocols = all smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination mynetworks = 127.0.0.0/8 [::1]/128 smtpd_tls_auth_only = no smtp_use_tls = yes smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom myhostname = server1.example.com |
Maintenant, démarrez Postfix, saslauthd et Dovecot :
chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
chkconfig --levels 235 saslauthd on
chkconfig --levels 235 dovecot on
/etc/init.d/sendmail stop
/etc/init.d/postfix start
/etc/init.d/saslauthd start
/etc/init.d/dovecot startPour voir si SMTP-AUTH et TLS fonctionnent correctement, exécutez la commande suivante :
telnet localhost 25Après avoir établi la connexion à votre serveur de messagerie Postfix, tapez
ehlo localhostSi vous voyez les lignes
250-STARTTLSet
250-AUTH LOGIN PLAINtout va bien.
[root@server1 ssl]# telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 server1.example.com ESMTP Postfix
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@server1 ssl]#Tapez
quitpour revenir au shell du système.
10.1 Maildir
Dovecot utilise le format Maildir (pas mbox), donc si vous installez ISPConfig sur le serveur, veuillez vous assurer d’activer Maildir sous Gestion -> Serveur -> Paramètres -> Email. ISPConfig fera alors la configuration nécessaire.
Si vous ne souhaitez pas installer ISPConfig, vous devez alors configurer Postfix pour livrer les e-mails dans le Maildir d’un utilisateur (vous pouvez également le faire si vous utilisez ISPConfig - cela ne fait pas de mal ;-)) :
postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restartRecevez de nouveaux articles dans votre boîte de réception.
Aucun spam. Désabonnez-vous à tout moment.