Configuración Servidor · 4 min read · Oct 16, 2025

La Configuración Perfecta - CentOS 4.4 (32-bit) - Página 5

10 Postfix Con SMTP-AUTH Y TLS

Ahora instalamos Postfix y dovecot (dovecot será nuestro servidor POP3/IMAP):

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

A continuación, configuramos SMTP-AUTH y 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'

Debemos editar /usr/lib/sasl2/smtpd.conf para que Postfix permita inicios de sesión PLAIN y LOGIN. En un Centos 4.4 de 64 bits, debes editar el archivo /usr/lib64/sasl2/smtpd.conf en su lugar. Debe verse así:

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'

Después de estos pasos de configuración, ahora deberías tener un /etc/postfix/main.cf que se vea así (he eliminado todos los comentarios):

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 |

Por defecto, el demonio dovecot de CentOS proporciona solo servicios IMAP e IMAPs. Debido a que también queremos POP3 y POP3s, debemos configurar dovecot para hacerlo. Editamos /etc/dovecot.conf y ponemos la línea protocols = imap imaps pop3 pop3s en él:

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. [...] |

Ahora inicia Postfix, saslauthd y 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

Para ver si SMTP-AUTH y TLS funcionan correctamente, ahora ejecuta el siguiente comando:

telnet localhost 25

Después de haber establecido la conexión con tu servidor de correo Postfix, escribe

ehlo localhost

Si ves las líneas

250-STARTTLS

y

250-AUTH

todo está bien.

Escribe

quit

para volver a la shell del sistema.

10.1 Maildir

dovecot utiliza el formato Maildir (no mbox), así que si instalas ISPConfig en el servidor, asegúrate de habilitar Maildir en Management -> Server -> Settings -> Email. ISPConfig hará la configuración necesaria.

Si no deseas instalar ISPConfig, entonces debes configurar Postfix para entregar correos electrónicos al Maildir de un usuario:

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

11 Apache2 Con PHP

Ahora instalamos Apache con PHP (este es PHP 4.3.9; CentOS no proporciona paquetes de 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

Luego edita /etc/httpd/conf/httpd.conf:

vi /etc/httpd/conf/httpd.conf

y cambia DirectoryIndex a

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

Ahora configura tu sistema para iniciar Apache al arrancar:

chkconfig --levels 235 httpd on

Inicia Apache:

/etc/init.d/httpd start

11.1 Desactivar PHP Globalmente

(Si no planeas instalar ISPConfig en este servidor, ¡por favor omite esta sección!)

En ISPConfig configurarás PHP en una base por sitio web, es decir, puedes especificar qué sitio web puede ejecutar scripts PHP y cuál no. Esto solo puede funcionar si PHP está desactivado globalmente porque de lo contrario todos los sitios web podrían ejecutar scripts PHP, sin importar lo que especifiques en ISPConfig.

Para desactivar PHP globalmente, editamos /etc/httpd/conf.d/php.conf y comentamos la línea AddType:

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

| # # PHP is an HTML-embedded scripting language which attempts to make it # easy for developers to write dynamically generated webpages. # LoadModule php4_module modules/libphp4.so # # Cause the PHP interpreter to handle files with a .php extension. # #AddType application/x-httpd-php .php # AddType application/x-httpd-php-source .phps # # Add index.php to the list of files that will be served as directory # indexes. # DirectoryIndex index.php |

Después reiniciamos Apache:

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

Recibe nuevas publicaciones en tu bandeja de entrada.

No spam. Cancela la suscripción en cualquier momento.