Почтовый сервер в связке Postfix, Dovecot — различия между версиями
Root (обсуждение | вклад) |
Root (обсуждение | вклад) |
||
Строка 156: | Строка 156: | ||
<spoiler> | <spoiler> | ||
<?php | <?php | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
$CONF['configured'] = true; | $CONF['configured'] = true; | ||
Строка 184: | Строка 162: | ||
// To create the hash, visit setup.php in a browser and type a password into the field, | // To create the hash, visit setup.php in a browser and type a password into the field, | ||
// on submission it will be echoed out to you as a hashed value. | // on submission it will be echoed out to you as a hashed value. | ||
− | $CONF['setup_password'] = ' | + | $CONF['setup_password'] = 'пароль установки'; |
// Language config | // Language config | ||
Строка 193: | Строка 171: | ||
// Set to the function name you want to use as hook function (see language_hook example function below) | // Set to the function name you want to use as hook function (see language_hook example function below) | ||
$CONF['language_hook'] = ''; | $CONF['language_hook'] = ''; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
// Database Config | // Database Config | ||
Строка 242: | Строка 181: | ||
$CONF['database_password'] = 'q'; | $CONF['database_password'] = 'q'; | ||
$CONF['database_name'] = 'postfix'; | $CONF['database_name'] = 'postfix'; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
// Here, if you need, you can customize table names. | // Here, if you need, you can customize table names. | ||
Строка 267: | Строка 201: | ||
// Site Admin | // Site Admin | ||
− | |||
− | |||
− | |||
− | |||
$CONF['admin_email'] = 'postmaster@megapuper.ru'; | $CONF['admin_email'] = 'postmaster@megapuper.ru'; | ||
// Mail Server | // Mail Server | ||
− | |||
− | |||
$CONF['smtp_server'] = '127.0.0.1'; | $CONF['smtp_server'] = '127.0.0.1'; | ||
$CONF['smtp_port'] = '25'; | $CONF['smtp_port'] = '25'; | ||
// Encrypt | // Encrypt | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
$CONF['encrypt'] = 'cleartext'; | $CONF['encrypt'] = 'cleartext'; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
// Password validation | // Password validation | ||
// New/changed passwords will be validated using all regular expressions in the array. | // New/changed passwords will be validated using all regular expressions in the array. | ||
// If a password doesn't match one of the regular expressions, the corresponding | // If a password doesn't match one of the regular expressions, the corresponding | ||
− | // | + | // error message from $PALANG (see languages/) will be displayed. |
// If you need custom error messages, you can add them using $CONF['language_hook']. | // If you need custom error messages, you can add them using $CONF['language_hook']. | ||
// If a $PALANG text contains a %s, you can add its value after the $PALANG key | // If a $PALANG text contains a %s, you can add its value after the $PALANG key | ||
Строка 319: | Строка 225: | ||
// Generate Password | // Generate Password | ||
− | |||
− | |||
$CONF['generate_password'] = 'NO'; | $CONF['generate_password'] = 'NO'; | ||
// Show Password | // Show Password | ||
− | |||
− | |||
$CONF['show_password'] = 'NO'; | $CONF['show_password'] = 'NO'; | ||
Строка 331: | Строка 233: | ||
// Set the number of entries that you would like to see | // Set the number of entries that you would like to see | ||
// in one page. | // in one page. | ||
− | $CONF['page_size'] = ' | + | $CONF['page_size'] = '50'; |
// Default Aliases | // Default Aliases | ||
− | |||
− | |||
− | |||
− | |||
//$CONF['default_aliases'] = array ( | //$CONF['default_aliases'] = array ( | ||
// 'abuse' => 'abuse@change-this-to-your.domain.tld', | // 'abuse' => 'abuse@change-this-to-your.domain.tld', | ||
Строка 346: | Строка 244: | ||
// Mailboxes | // Mailboxes | ||
− | |||
− | |||
// YES: /usr/local/virtual/domain.tld/username@domain.tld | // YES: /usr/local/virtual/domain.tld/username@domain.tld | ||
// NO: /usr/local/virtual/username@domain.tld | // NO: /usr/local/virtual/username@domain.tld | ||
$CONF['domain_path'] = 'YES'; | $CONF['domain_path'] = 'YES'; | ||
// If you don't want to have the domain in your mailbox set this to 'NO'. | // If you don't want to have the domain in your mailbox set this to 'NO'. | ||
− | |||
// YES: /usr/local/virtual/domain.tld/username@domain.tld | // YES: /usr/local/virtual/domain.tld/username@domain.tld | ||
// NO: /usr/local/virtual/domain.tld/username | // NO: /usr/local/virtual/domain.tld/username | ||
Строка 358: | Строка 253: | ||
$CONF['domain_in_mailbox'] = 'NO'; | $CONF['domain_in_mailbox'] = 'NO'; | ||
// If you want to define your own function to generate a maildir path set this to the name of the function. | // If you want to define your own function to generate a maildir path set this to the name of the function. | ||
− | |||
// - this configuration directive will override both domain_path and domain_in_mailbox | // - this configuration directive will override both domain_path and domain_in_mailbox | ||
// - the maildir_name_hook() function example is present below, commented out | // - the maildir_name_hook() function example is present below, commented out | ||
Строка 364: | Строка 258: | ||
$CONF['maildir_name_hook'] = 'NO'; | $CONF['maildir_name_hook'] = 'NO'; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
$CONF['admin_struct_hook'] = ''; | $CONF['admin_struct_hook'] = ''; | ||
$CONF['domain_struct_hook'] = ''; | $CONF['domain_struct_hook'] = ''; |
Версия 17:16, 22 апреля 2015
При установке будем ориентироваться на этот мануал: http://dummyluck.com/page/pochtovyi_server_nastroika_opisanie
Настройку будем производить для сервера с одним доменом. Система FreeBSD 10.1
1. Подготовка.
прописываем хостнейм /etc/rc.conf
hostname="mail.megapuper.ru"
делаем изменения в хостах /etc/hosts
127.0.0.1 localhost 109.172.52.114 megapuper.ru 109.172.52.114 mail.megapuper.ru
создаём пользователя и группу vmail
# pw groupadd vmail -g 5000 # pw useradd vmail -g vmail -s /sbin/nologin -u 5000
сразу отключаем sendmail
/etc/rc.conf
sendmail_enable="NO" sendmail_submit_enable="NO" sendmail_outbound_enable="NO" sendmail_msp_queue_enable="NO"
/etc/periodic.conf
daily_clean_hoststat_enable="NO" daily_status_mail_rejects_enable="NO" daily_status_include_submit_mailq="NO" daily_submit_queuerun="NO"
2. Ставим Nginx, MySQL, PHP, PHP-extension. Этот web-сервер будет использоваться для postfixadmin.
Здесь коротко, ибо уже тыщу раз ставилось)
Nginx cтавим из пакетов
# pkg install nginx
основной конфиг /usr/local/etc/nginx/nginx.conf
user www; worker_processes 2; pid /var/run/nginx.pid; events { worker_connections 1024; } http { access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; include /usr/local/etc/nginx/mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; client_max_body_size 5m; server_names_hash_bucket_size 64; types_hash_max_size 2048; types_hash_bucket_size 64; include /usr/local/etc/nginx/conf/*.conf; }
конфиг виртуального хоста /usr/local/etc/nginx/conf/postfix.conf
server { listen 80; server_name postfix.megapuper.ru; root /usr/local/www/postfix; index index.php index.html index.htm; access_log /var/log/nginx/postfix.access.log; error_log /var/log/nginx/postfix.error.log; location / { # try_files $uri $uri/ /index.php?$uri&$args; } location ~ \.php$ { fastcgi_pass 127.0.0.1:10000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; fastcgi_intercept_errors on; include fastcgi_params; } }
PHP и нужные PHP-extension тоже ставим из пакетов
# pkg install php55 # pkg install php55-* (пригодятся php55-ctype php55-dom php55-gd php55-hash php55-iconv php55-imap php55-json php55-mbstring php55-mcrypt php55-mysql php55-mysqli php55-session php55-xml)
конфиг php-fpm /usr/local/etc/php-fpm.conf
[global] error_log = /var/log/php/php-fpm.log pid = /var/run/php-fpm.pid log_level = notice include=/usr/local/etc/php/*.conf
конфиг для виртуального хоста /usr/local/etc/php/postfix.conf
[postfix] prefix = /usr/local/www/$pool listen = 127.0.0.1:10000 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0660 user = www group = www pm = dynamic pm.max_children = 4 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 pm.max_requests = 100 ;pm.status_path = /status/php-fpm/$pool request_terminate_timeout = 0 request_slowlog_timeout = 1m slowlog = /var/log/php/$pool.slow.log catch_workers_output = yes
MySQL тоже из пакетов
# pkg install mysql56-server
простенький конфиг /etc/my.cnf
[mysqld] bind-address=127.0.0.1
в конфигах. где используется подключение к базе указываем хост 127.0.0.1
После этого имеем готовый web-сервер можно переходить к установке postfixadmin
3. Установка PostfixAdmin
Скачиваем последнюю версию отсюда http://sourceforge.net/projects/postfixadmin/ и заливаем на web-сервер
создаём базу и даём права пользователю
> create database postfix character set utf8 collate utf8_general_ci; > grant all on postfix.* to postfix@127.0.0.1 identified by 'пароль';
Правим основной конфиг postfixadmin config.inc.php
Spoiler
6. Устанавливаем Postfix.
7. Устанавливаем Dovecot.