Servidor Perfeito · 4 min read · Dec 16, 2025
O Servidor Perfeito - Fedora 11 x86_64 [ISPConfig 2] - Página 4
9 MySQL (5.0)
Para instalar o MySQL, fazemos o seguinte:
yum install mysql mysql-devel mysql-serverEm seguida, criamos os links de inicialização do sistema para o MySQL (para que o MySQL inicie automaticamente sempre que o sistema for inicializado) e iniciamos o servidor MySQL:
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld startAgora verifique se a rede está habilitada. Execute
netstat -tap | grep mysqlDeve mostrar algo como isto:
[root@server1 named]# netstat -tap | grep mysql
tcp 0 0 *:mysql *:* LISTEN 1672/mysqld
[root@server1 named]#Se não mostrar, edite /etc/my.cnf e comente a opção skip-networking:
vi /etc/my.cnf| [...] #skip-networking [...] |
E reinicie seu servidor MySQL:
/etc/init.d/mysqld restartExecute
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpasswordpara definir uma senha para o usuário root (caso contrário, qualquer um pode acessar seu banco de dados MySQL!).
10 Postfix Com SMTP-AUTH E TLS
Agora instalamos o Postfix e o Dovecot (Dovecot será nosso servidor POP3/IMAP):
yum install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain postfix dovecotAgora configuramos 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_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'Devemos editar /usr/lib64/sasl2/smtpd.conf para que o Postfix permita logins PLAIN e LOGIN (em sistemas de 32 bits, este arquivo está em /usr/lib/sasl2/smtpd.conf). Deve ficar assim:
vi /usr/lib64/sasl2/smtpd.conf| pwcheck_method: saslauthd mech_list: plain login |
Depois, criamos os certificados para 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 3650Em seguida, configuramos o Postfix para 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'Depois, definimos o nome do host na nossa instalação do Postfix (certifique-se de substituir server1.example.com pelo seu próprio nome de host):
postconf -e 'myhostname = server1.example.com'Após essas etapas de configuração, você deve agora ter um /etc/postfix/main.cf que se pareça com isto (removi todos os comentários dele):
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 |
Agora inicie o 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 startPara ver se SMTP-AUTH e TLS funcionam corretamente, execute o seguinte comando:
telnet localhost 25Depois de estabelecer a conexão com seu servidor de email Postfix, digite
ehlo localhostSe você ver as linhas
250-STARTTLSe
250-AUTH LOGIN PLAINtudo está bem.
[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]#Digite
quitpara retornar ao shell do sistema.
10.1 Maildir
O Dovecot usa o formato Maildir (não mbox), então se você instalar o ISPConfig no servidor, certifique-se de habilitar o Maildir em Gerenciamento -> Servidor -> Configurações -> Email. O ISPConfig fará a configuração necessária.
Se você não quiser instalar o ISPConfig, então deve configurar o Postfix para entregar emails para o Maildir de um usuário (você também pode fazer isso se usar o ISPConfig - não faz mal ;-)):
postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restartReceba novas postagens na sua caixa de entrada
Sem spam. Cancele a assinatura a qualquer momento.