Серверы · 3 min read · Dec 13, 2025

Идеальный сервер - Fedora 12 x86_64 [ISPConfig 2] - Страница 4

9 MySQL 5

Чтобы установить MySQL, мы делаем следующее:

yum install mysql mysql-devel mysql-server

Затем мы создаем системные ссылки для автозапуска MySQL (чтобы MySQL запускался автоматически при загрузке системы) и запускаем сервер MySQL:

chkconfig --levels 235 mysqld on  
/etc/init.d/mysqld start

Теперь проверьте, что сеть включена. Выполните

netstat -tap | grep mysql

Это должно показать что-то вроде этого:

[root@server1 ~]# netstat -tap | grep mysql  
tcp        0      0 *:mysql                     *:*                         LISTEN      1433/mysqld  
[root@server1 ~]#

Если этого не происходит, отредактируйте /etc/my.cnf и закомментируйте опцию skip-networking:

vi /etc/my.cnf

| [...] #skip-networking [...] |

и перезапустите сервер MySQL:

/etc/init.d/mysqld restart

Выполните

mysqladmin -u root password yourrootsqlpassword  
mysqladmin -h server1.example.com -u root password yourrootsqlpassword

чтобы установить пароль для пользователя root (в противном случае любой сможет получить доступ к вашей базе данных MySQL!).

10 Postfix с SMTP-AUTH и TLS

Теперь мы устанавливаем Postfix и Dovecot (Dovecot будет нашим POP3/IMAP сервером):

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

Теперь мы настраиваем SMTP-AUTH и 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'

Мы должны отредактировать /usr/lib64/sasl2/smtpd.conf, чтобы Postfix разрешал входы PLAIN и LOGIN (в 32-битных системах этот файл находится в /usr/lib/sasl2/smtpd.conf). Он должен выглядеть так:

vi /usr/lib64/sasl2/smtpd.conf

| pwcheck_method: saslauthd mech_list: plain login |

После этого мы создаем сертификаты для TLS:

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

Далее мы настраиваем Postfix для 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'

Затем мы устанавливаем имя хоста в нашей установке Postfix (убедитесь, что вы заменили server1.example.com на ваше собственное имя хоста):

postconf -e 'myhostname = server1.example.com'

После этих шагов конфигурации у вас должен быть /etc/postfix/main.cf, который выглядит так (я удалил из него все комментарии):

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 inet_protocols = 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.6.5/samples readme_directory = /usr/share/doc/postfix-2.6.5/README_FILES 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 |

Теперь запустите Postfix, saslauthd и 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

Чтобы проверить, работают ли SMTP-AUTH и TLS, выполните следующую команду:

telnet localhost 25

После того как вы установили соединение с вашим почтовым сервером Postfix, введите

ehlo localhost

Если вы видите строки

250-STARTTLS

и

250-AUTH PLAIN LOGIN

все в порядке.

[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 PLAIN LOGIN  
250-AUTH=PLAIN LOGIN  
250-ENHANCEDSTATUSCODES  
250-8BITMIME  
250 DSN  
quit  
221 2.0.0 Bye  
Connection closed by foreign host.  
[root@server1 ssl]#

Введите

quit

чтобы вернуться в оболочку системы.

10.1 Maildir

Dovecot использует формат Maildir (не mbox), поэтому если вы устанавливаете ISPConfig на сервер, пожалуйста, убедитесь, что вы включили Maildir в разделе Управление -> Сервер -> Настройки -> Электронная почта. ISPConfig затем выполнит необходимую конфигурацию.

Если вы не хотите устанавливать ISPConfig, то вам нужно настроить Postfix для доставки электронной почты в Maildir пользователя (вы также можете сделать это, если используете ISPConfig - это не повредит ;-)):

postconf -e 'home_mailbox = Maildir/'  
postconf -e 'mailbox_command ='  
/etc/init.d/postfix restart
Share: X/Twitter LinkedIn

Get new posts in your inbox

No spam. Unsubscribe anytime.