Configurazione Server · 4 min read · Oct 16, 2025

La Configurazione Perfetta - CentOS 4.4 (32-bit) - Pagina 5

10 Postfix Con SMTP-AUTH E TLS

Ora installiamo Postfix e dovecot (dovecot sarà il nostro server POP3/IMAP):

yum install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain postfix dovecot

Successivamente configuriamo SMTP-AUTH e 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_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
postconf -e 'inet_interfaces = all'
postconf -e 'mynetworks = 127.0.0.0/8'

Dobbiamo modificare /usr/lib/sasl2/smtpd.conf affinché Postfix consenta accessi PLAIN e LOGIN. Su un Centos 4.4 a 64 bit, devi modificare il file /usr/lib64/sasl2/smtpd.conf invece. Dovrebbe apparire così:

vi /usr/lib/sasl2/smtpd.conf

| pwcheck_method: saslauthd mech_list: plain login |

mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
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'

Dopo questi passaggi di configurazione, ora dovresti avere un /etc/postfix/main.cf che appare così (ho rimosso tutti i commenti):

vi /etc/postfix/main.cf

| queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/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 xxgdb $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.1.5/samples readme_directory = /usr/share/doc/postfix-2.1.5/README_FILES smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination mynetworks = 127.0.0.0/8 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 |

Per impostazione predefinita, il demone dovecot di CentOS fornisce solo servizi IMAP e IMAPs. Poiché vogliamo anche POP3 e POP3s, dobbiamo configurare dovecot per farlo. Modifichiamo /etc/dovecot.conf e mettiamo la riga protocols = imap imaps pop3 pop3s al suo interno:

vi /etc/dovecot.conf

| [...]# Base directory where to store runtime data. #base_dir = /var/run/dovecot/ # Protocols we want to be serving: # imap imaps pop3 pop3s protocols = imap imaps pop3 pop3s # IP or host address where to listen in for connections. It's not currently # possible to specify multiple addresses. "*" listens in all IPv4 interfaces. [...] |

Ora avvia Postfix, saslauthd e 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 start

Per vedere se SMTP-AUTH e TLS funzionano correttamente, ora esegui il seguente comando:

telnet localhost 25

Dopo aver stabilito la connessione al tuo server di posta Postfix, digita

ehlo localhost

Se vedi le righe

250-STARTTLS

e

250-AUTH

tutto va bene.

Digita

quit

per tornare alla shell del sistema.

10.1 Maildir

dovecot utilizza il formato Maildir (non mbox), quindi se installi ISPConfig sul server, assicurati di abilitare Maildir sotto Gestione -> Server -> Impostazioni -> Email. ISPConfig eseguirà quindi la configurazione necessaria.

Se non desideri installare ISPConfig, allora devi configurare Postfix per consegnare le email alla Maildir di un utente:

postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restart

11 Apache2 Con PHP

Ora installiamo Apache con PHP (questo è PHP 4.3.9; CentOS non fornisce pacchetti PHP5):

yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel

Poi modifica /etc/httpd/conf/httpd.conf:

vi /etc/httpd/conf/httpd.conf

e cambia DirectoryIndex in

| DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl |

Ora configura il tuo sistema per avviare Apache all’avvio:

chkconfig --levels 235 httpd on

Avvia Apache:

/etc/init.d/httpd start

11.1 Disabilitare PHP Globalmente

(Se non prevedi di installare ISPConfig su questo server, salta questa sezione!)

In ISPConfig configurerai PHP su base per-sito, cioè puoi specificare quale sito può eseguire script PHP e quale no. Questo può funzionare solo se PHP è disabilitato globalmente, altrimenti tutti i siti sarebbero in grado di eseguire script PHP, indipendentemente da ciò che specifichi in ISPConfig.

Per disabilitare PHP globalmente, modifichiamo /etc/httpd/conf.d/php.conf e commentiamo la riga AddType:

vi /etc/httpd/conf.d/php.conf

| # # PHP è un linguaggio di scripting incorporato in HTML che cerca di rendere facile per gli sviluppatori scrivere pagine web generate dinamicamente. # LoadModule php4_module modules/libphp4.so # # Causa l'interprete PHP a gestire file con un'estensione .php. # #AddType application/x-httpd-php .php # AddType application/x-httpd-php-source .phps # # Aggiungi index.php alla lista di file che saranno serviti come indici di directory. # DirectoryIndex index.php |

Dopo di che riavviamo Apache:

/etc/init.d/httpd restart
Share: X/Twitter LinkedIn

Ricevi i nuovi post nella tua casella di posta.

Nessuno spam. Disiscriviti in qualsiasi momento.