Почтовый сервер в связке Postfix, Dovecot — различия между версиями

Материал из megapuper
Перейти к: навигация, поиск
Строка 158: Строка 158:
  
 
$CONF['configured'] = true;
 
$CONF['configured'] = true;
 +
  
 
// In order to setup Postfixadmin, you MUST specify a hashed password here.<br/>
 
// In order to setup Postfixadmin, you MUST specify a hashed password here.<br/>
Строка 163: Строка 164:
 
// on submission it will be echoed out to you as a hashed value.<br/>
 
// on submission it will be echoed out to you as a hashed value.<br/>
 
$CONF['setup_password'] = 'пароль установки';
 
$CONF['setup_password'] = 'пароль установки';
 +
  
 
// Language config<br/>
 
// Language config<br/>
 
// Language files are located in './languages', change as required..<br/>
 
// Language files are located in './languages', change as required..<br/>
 
$CONF['default_language'] = 'ru';
 
$CONF['default_language'] = 'ru';
 +
  
 
// Hook to override or add translations in $PALANG<br/>
 
// Hook to override or add translations in $PALANG<br/>
 
// Set to the function name you want to use as hook function (see language_hook example function below)<br/>
 
// Set to the function name you want to use as hook function (see language_hook example function below)<br/>
 
$CONF['language_hook'] = '';
 
$CONF['language_hook'] = '';
 +
  
 
// Database Config<br/>
 
// Database Config<br/>
Строка 181: Строка 185:
 
$CONF['database_password'] = 'q';<br/>
 
$CONF['database_password'] = 'q';<br/>
 
$CONF['database_name'] = 'postfix';<br/>
 
$CONF['database_name'] = 'postfix';<br/>
 +
  
 
// Here, if you need, you can customize table names.<br/>
 
// Here, if you need, you can customize table names.<br/>
Строка 199: Строка 204:
 
     'quota2' => 'quota2',
 
     'quota2' => 'quota2',
 
);
 
);
 +
  
 
// 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
Строка 223: Строка 232:
 
     '/([0-9].*){2}/'        => 'password_no_digits 2',      # must contain at least 2 digits
 
     '/([0-9].*){2}/'        => 'password_no_digits 2',      # must contain at least 2 digits
 
);
 
);
 +
  
 
// Generate Password
 
// Generate Password
 
$CONF['generate_password'] = 'NO';
 
$CONF['generate_password'] = 'NO';
 +
  
 
// Show Password
 
// Show Password
 
$CONF['show_password'] = 'NO';
 
$CONF['show_password'] = 'NO';
 +
  
 
// Page Size
 
// Page Size
Строка 234: Строка 246:
 
// in one page.
 
// in one page.
 
$CONF['page_size'] = '50';
 
$CONF['page_size'] = '50';
 +
  
 
// Default Aliases
 
// Default Aliases
Строка 242: Строка 255:
 
//    'webmaster' => 'webmaster@change-this-to-your.domain.tld'
 
//    'webmaster' => 'webmaster@change-this-to-your.domain.tld'
 
//);
 
//);
 +
  
 
// Mailboxes
 
// Mailboxes
Строка 271: Строка 285:
 
$CONF['maxquota'] = '1024';
 
$CONF['maxquota'] = '1024';
 
$CONF['domain_quota_default'] = '2048';
 
$CONF['domain_quota_default'] = '2048';
 +
  
 
// Quota
 
// Quota
Строка 279: Строка 294:
 
// You can either use '1024000' or '1048576'
 
// You can either use '1024000' or '1048576'
 
$CONF['quota_multiplier'] = '1048576';
 
$CONF['quota_multiplier'] = '1048576';
 +
  
 
// Transport
 
// Transport
Строка 299: Строка 315:
 
// NOTE: Make sure that you install the vacation module. (See VIRTUAL-VACATION/)
 
// NOTE: Make sure that you install the vacation module. (See VIRTUAL-VACATION/)
 
$CONF['vacation'] = 'NO';
 
$CONF['vacation'] = 'NO';
 +
  
 
// This is the autoreply domain that you will need to set in your Postfix
 
// This is the autoreply domain that you will need to set in your Postfix
Строка 305: Строка 322:
 
// This domain must exclusively be used for vacation. Do NOT use it for "normal" mail addresses.
 
// This domain must exclusively be used for vacation. Do NOT use it for "normal" mail addresses.
 
$CONF['vacation_domain'] = '';
 
$CONF['vacation_domain'] = '';
 +
  
 
// Vacation Control
 
// Vacation Control
 
// If you want users to take control of vacation set this to 'YES'.
 
// If you want users to take control of vacation set this to 'YES'.
 
$CONF['vacation_control'] ='NO';
 
$CONF['vacation_control'] ='NO';
 +
  
 
// Vacation Control for admins
 
// Vacation Control for admins
 
// Set to 'YES' if your domain admins should be able to edit user vacation.
 
// Set to 'YES' if your domain admins should be able to edit user vacation.
 
$CONF['vacation_control_admin'] = 'YES';
 
$CONF['vacation_control_admin'] = 'YES';
 +
  
 
// ReplyType options
 
// ReplyType options
Строка 339: Строка 359:
 
// Alias control for superadmins
 
// Alias control for superadmins
 
$CONF['alias_control'] = 'YES';
 
$CONF['alias_control'] = 'YES';
 +
  
 
// Alias Control for domain admins
 
// Alias Control for domain admins
 
$CONF['alias_control_admin'] = 'YES';
 
$CONF['alias_control_admin'] = 'YES';
 +
  
 
// Special Alias Control
 
// Special Alias Control
Строка 347: Строка 369:
 
// as defined in $CONF['default_aliases']
 
// as defined in $CONF['default_aliases']
 
$CONF['special_alias_control'] = 'NO';
 
$CONF['special_alias_control'] = 'NO';
 +
  
 
// Alias Goto Field Limit
 
// Alias Goto Field Limit
Строка 353: Строка 376:
 
// '0' means no limits.
 
// '0' means no limits.
 
$CONF['alias_goto_limit'] = '0';
 
$CONF['alias_goto_limit'] = '0';
 +
  
 
// Alias Domains
 
// Alias Domains
Строка 361: Строка 385:
 
// Set to 'NO' to disable alias domains.
 
// Set to 'NO' to disable alias domains.
 
$CONF['alias_domain'] = 'YES';
 
$CONF['alias_domain'] = 'YES';
 +
  
 
// Backup
 
// Backup
 
// If you don't want backup tab set this to 'NO';
 
// If you don't want backup tab set this to 'NO';
 
//$CONF['backup'] = 'YES';
 
//$CONF['backup'] = 'YES';
 +
  
 
// Send Mail
 
// Send Mail
 
// If you don't want sendmail tab set this to 'NO';
 
// If you don't want sendmail tab set this to 'NO';
 
$CONF['sendmail'] = 'YES';
 
$CONF['sendmail'] = 'YES';
 +
  
 
// Logging
 
// Logging
 
// If you don't want logging set this to 'NO';
 
// If you don't want logging set this to 'NO';
 
$CONF['logging'] = 'YES';
 
$CONF['logging'] = 'YES';
 +
  
 
// Fetchmail
 
// Fetchmail
 
// If you don't want fetchmail tab set this to 'NO';
 
// If you don't want fetchmail tab set this to 'NO';
 
//$CONF['fetchmail'] = 'YES';
 
//$CONF['fetchmail'] = 'YES';
 +
  
 
// fetchmail_extra_options allows users to specify any fetchmail options and any MDA
 
// fetchmail_extra_options allows users to specify any fetchmail options and any MDA
Строка 382: Строка 411:
 
// This should be set to NO, except if you *really* trust *all* your users.
 
// This should be set to NO, except if you *really* trust *all* your users.
 
$CONF['fetchmail_extra_options'] = 'YES';
 
$CONF['fetchmail_extra_options'] = 'YES';
 +
  
 
// Header
 
// Header
 
$CONF['show_header_text'] = 'YES';
 
$CONF['show_header_text'] = 'YES';
 
$CONF['header_text'] = ':: Postfix Admin ::';
 
$CONF['header_text'] = ':: Postfix Admin ::';
 +
  
 
// Footer
 
// Footer
Строка 391: Строка 422:
 
$CONF['footer_text'] = 'Return to postfix.megapuper.ru';
 
$CONF['footer_text'] = 'Return to postfix.megapuper.ru';
 
$CONF['footer_link'] = 'http://postfix.megapuper.ru/';
 
$CONF['footer_link'] = 'http://postfix.megapuper.ru/';
 +
  
 
// MOTD ("Motto of the day")
 
// MOTD ("Motto of the day")
Строка 398: Строка 430:
 
$CONF['motd_admin'] = '';
 
$CONF['motd_admin'] = '';
 
$CONF['motd_superadmin'] = '';
 
$CONF['motd_superadmin'] = '';
 +
  
 
// Welcome Message
 
// Welcome Message
Строка 407: Строка 440:
 
Welcome to your new account.
 
Welcome to your new account.
 
EOM;
 
EOM;
 +
  
 
// When creating mailboxes or aliases, check that the domain-part of the
 
// When creating mailboxes or aliases, check that the domain-part of the
Строка 439: Строка 473:
 
// Set to "" to disable this check.
 
// Set to "" to disable this check.
 
$CONF['recipient_delimiter'] = "+";
 
$CONF['recipient_delimiter'] = "+";
 +
  
 
// Optional:
 
// Optional:
 
// Script to run after creation of mailboxes.
 
// Script to run after creation of mailboxes.
 
$CONF['mailbox_postcreation_script'] = '/usr/local/www/postfix/scripts/addmail.sh';
 
$CONF['mailbox_postcreation_script'] = '/usr/local/www/postfix/scripts/addmail.sh';
 +
  
 
// Optional:
 
// Optional:
 
// Script to run after alteration of mailboxes.
 
// Script to run after alteration of mailboxes.
 
$CONF['mailbox_postedit_script'] = '/usr/local/www/postfix/scripts/editmail.sh';
 
$CONF['mailbox_postedit_script'] = '/usr/local/www/postfix/scripts/editmail.sh';
 +
  
 
// Optional:
 
// Optional:
 
// Script to run after deletion of mailboxes.
 
// Script to run after deletion of mailboxes.
 
$CONF['mailbox_postdeletion_script'] = '/usr/local/www/postfix/scripts/delmail.sh';
 
$CONF['mailbox_postdeletion_script'] = '/usr/local/www/postfix/scripts/delmail.sh';
 +
  
 
// Optional:
 
// Optional:
 
// Script to run after creation of domains.
 
// Script to run after creation of domains.
 
$CONF['domain_postcreation_script'] = '';
 
$CONF['domain_postcreation_script'] = '';
 +
  
 
// Optional:
 
// Optional:
 
// Script to run after deletion of domains.
 
// Script to run after deletion of domains.
 
$CONF['domain_postdeletion_script'] = '';
 
$CONF['domain_postdeletion_script'] = '';
 +
  
 
// Optional:
 
// Optional:
Строка 468: Строка 508:
 
// Specify '' for Dovecot and 'INBOX.' for Courier.
 
// Specify '' for Dovecot and 'INBOX.' for Courier.
 
$CONF['create_mailbox_subdirs_prefix']='';
 
$CONF['create_mailbox_subdirs_prefix']='';
 +
  
 
// Optional:
 
// Optional:
Строка 473: Строка 514:
 
// mailbox listing.
 
// mailbox listing.
 
$CONF['used_quotas'] = 'YES';
 
$CONF['used_quotas'] = 'YES';
 +
  
 
// if you use dovecot >= 1.2, set this to yes.
 
// if you use dovecot >= 1.2, set this to yes.
 
// Note about dovecot config: table "quota" is for 1.0 & 1.1, table "quota2" is for dovecot 1.2 and newer
 
// Note about dovecot config: table "quota" is for 1.0 & 1.1, table "quota2" is for dovecot 1.2 and newer
 
$CONF['new_quota_table'] = 'YES';
 
$CONF['new_quota_table'] = 'YES';
 +
  
 
// Normally, the TCP port number does not have to be specified.
 
// Normally, the TCP port number does not have to be specified.
Строка 484: Строка 527:
 
// are some examples to experiment with:
 
// are some examples to experiment with:
 
$CONF['create_mailbox_subdirs_hostoptions'] = array('novalidate-cert','norsh');
 
$CONF['create_mailbox_subdirs_hostoptions'] = array('novalidate-cert','norsh');
 +
  
 
// Theme Config
 
// Theme Config
Строка 492: Строка 536:
 
// you can add a custom CSS file. It will be included after $CONF['theme_css'].
 
// you can add a custom CSS file. It will be included after $CONF['theme_css'].
 
$CONF['theme_custom_css'] = '';
 
$CONF['theme_custom_css'] = '';
 +
  
 
// XMLRPC Interface.
 
// XMLRPC Interface.
Строка 498: Строка 543:
 
//  change to boolean true to enable xmlrpc
 
//  change to boolean true to enable xmlrpc
 
$CONF['xmlrpc_enabled'] = false;
 
$CONF['xmlrpc_enabled'] = false;
 +
  
 
// If you want to keep most settings at default values and/or want to ensure  
 
// If you want to keep most settings at default values and/or want to ensure  
Строка 506: Строка 552:
 
     include(dirname(__FILE__) . '/config.local.php');
 
     include(dirname(__FILE__) . '/config.local.php');
 
}
 
}
 +
  
 
//
 
//
Строка 511: Строка 558:
 
//
 
//
 
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
 
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
 
 
</spoiler>
 
</spoiler>
  

Версия 18:40, 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.