MySQL 5
Для установки MySQL, выполним это:
|
Затем мы создаем автозапуск для MySQL (так чтобы MySQL запускалась автоматически при загрузке системы) и запустить ее сервер MySQL:
|
Теперь проверим, что сеть включена. Выполнив:
|
Он должно отобразиться, что-то вроде этого:
[root@server1 ~]# netstat -tap | grep mysql tcp 0 0 *:mysql *:* LISTEN 1765/mysqld [root@server1 ~]#
Если этого не произойдет, редактировать /etc/my.cnf и закомментируйте опцию skip-networking:
|
[...] #skip-networking [...]
И перезапустим Ваш MySQL сервер:
|
Запустим:
|
Установите пароль для пользователя root (в противном случае любой желающий может получить доступ к MySQL базе данных!).
[root@server1 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): - ENTER
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] - ENTER
New password: - Ваш root пароль на SQL
Re-enter new password: - Ваш root пароль на SQL
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] - ENTER
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] - ENTER
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] - ENTER
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] - ENTER
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
[root@server1 ~]#
Postfix с SMTP-AUTH и TLS
Теперь мы установим Postfix и Dovecot (Dovecot будет нашим POP3/IMAP сервер):
|
Теперь настроить SMTP-AUTH и TLS:
|
Мы должны изменить /usr/lib64/sasl2/smtpd.conf так, чтобы Postfix разрешал PLAIN и LOGIN логинов (на 32-битных систем, этот файл находится в / usr/lib/sasl2/smtpd.conf). Он должен выглядеть следующим образом:
|
pwcheck_method: saslauthd mech_list: plain login
Затем мы создаем сертификаты для TLS:
|
Далее настраиваем Postfix для TLS:
|
Затем мы устанавливаем имя хоста в наших настройках Postfix (убедившись, что Вы заменили server1.example.com с вашим собственным именем хоста):
|
После этих шагов настройки, Вы должны иметь /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.7.1/samples
readme_directory = /usr/share/doc/postfix-2.7.1/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, мы должны позволить текстовую аутентификации. Откроем /etc/dovecot/conf.d/10-auth.conf ...
|
... и добавим строку disable_plaintext_auth = no:
[...]
# Disable LOGIN command and all other plaintext authentications unless
# SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
# matches the local IP (ie. you're connecting from the same computer), the
# connection is considered secure and plaintext authentication is allowed.
#disable_plaintext_auth = yes
disable_plaintext_auth = no
[...]
Запустим Dovecot:
|
Чтобы убедиться, что SMTP-AUTH и TLS работают запустим следующую команду:
|
После того как Вы установили соединение с Вашим Postfix почтовым сервером:
|
Если Вы видите строки 250-STARTTLS и 250-AUTH LOGIN PLAIN:
[root@server1 ssl]# telnet localhost 25 Trying 127.0.0.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]#
Значит все в порядке. Завершим проверку вернувшись в оболочку системы.:
|
Maildir
Dovecot использует Maildir формат (не Mbox), так что если Вы установите ISPConfig 2 на сервере, пожалуйста, не забудьте включить Maildir в Управление - Server - Настройка - Электронная почта. ISPConfig 2 выполнит необходимые настройки.
Если вы не хотите установить ISPConfig 2, то необходимо настроить Postfix для доставки писем на Maildir пользователя (Вы также можете сделать это, если Вы используете ISPConfig):
|


