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

Материал из megapuper
Перейти к: навигация, поиск
Строка 282: Строка 282:
 
// Transport
 
// Transport
 
// If you want to define additional transport options for a domain set this to 'YES'.
 
// If you want to define additional transport options for a domain set this to 'YES'.
// Read the transport file of the Postfix documentation.
 
 
$CONF['transport'] = 'YES';
 
$CONF['transport'] = 'YES';
 
// Transport options
 
// Transport options
Строка 296: Строка 295:
  
  
//
 
//
 
 
// Virtual Vacation Stuff
 
// Virtual Vacation Stuff
//
 
//
 
 
 
// If you want to use virtual vacation for you mailbox users set this to 'YES'.
 
// If you want to use virtual vacation for you mailbox users set this to 'YES'.
 
// NOTE: Make sure that you install the vacation module. (See VIRTUAL-VACATION/)
 
// NOTE: Make sure that you install the vacation module. (See VIRTUAL-VACATION/)
Строка 332: Строка 326:
 
   60*60 *24*7 => 'reply_once_per_week'        // Reply if last autoreply was at least a week ago
 
   60*60 *24*7 => 'reply_once_per_week'        // Reply if last autoreply was at least a week ago
 
);
 
);
 +
// End Vacation Stuff.
  
//
 
// End Vacation Stuff.
 
//
 
  
 
// Users Control for Domain Admin
 
// Users Control for Domain Admin
Строка 345: Строка 337:
  
 
// Alias Control
 
// Alias Control
// Postfix Admin inserts an alias in the alias table for every mailbox it creates.
 
// The reason for this is that when you want catch-all and normal mailboxes
 
// to work you need to have the mailbox replicated in the alias table.
 
// If you want to take control of these aliases as well set this to 'YES'.
 
 
 
// Alias control for superadmins
 
// Alias control for superadmins
 
$CONF['alias_control'] = 'YES';
 
$CONF['alias_control'] = 'YES';
Строка 401: Строка 388:
  
 
// Footer
 
// Footer
// Below information will be on all pages.
 
// If you don't want the footer information to appear set this to 'NO'.
 
 
$CONF['show_footer_text'] = 'YES';
 
$CONF['show_footer_text'] = 'YES';
$CONF['footer_text'] = 'Return to adminko';
+
$CONF['footer_text'] = 'Return to postfix.megapuper.ru';
$CONF['footer_link'] = 'http://megapuper.ru/adm/';
+
$CONF['footer_link'] = 'http://postfix.megapuper.ru/';
  
 
// MOTD ("Motto of the day")
 
// MOTD ("Motto of the day")
Строка 429: Строка 414:
  
 
// Optional:
 
// Optional:
// Analyze alias gotos and display a colored block in the first column
 
// indicating if an alias or mailbox appears to deliver to a non-existent
 
// account.  Also, display indications, for POP/IMAP mailboxes and
 
// for custom destinations (such as mailboxes that forward to a UNIX shell
 
// account or mail that is sent to a MS exchange server, or any other
 
// domain or subdomain you use)
 
// See http://www.w3schools.com/html/html_colornames.asp for a list of
 
// color names available on most browsers
 
 
 
//set to YES to enable this feature
 
//set to YES to enable this feature
 
$CONF['show_status']='YES';
 
$CONF['show_status']='YES';
Строка 457: Строка 433:
 
// - add the domain to show_custom_domains
 
// - add the domain to show_custom_domains
 
// - add the corresponding color to show_custom_colors
 
// - add the corresponding color to show_custom_colors
$CONF['show_custom_domains']=array("servmp.megapuper.ru","localhost");
+
$CONF['show_custom_domains']=array("megapuper.ru","localhost");
 
$CONF['show_custom_colors']=array("lightgreen","lightblue");
 
$CONF['show_custom_colors']=array("lightgreen","lightblue");
 
// If you use a recipient_delimiter in your postfix config, you can also honor it when aliases are checked.
 
// If you use a recipient_delimiter in your postfix config, you can also honor it when aliases are checked.
Строка 466: Строка 442:
 
// Optional:
 
// Optional:
 
// Script to run after creation of mailboxes.
 
// Script to run after creation of mailboxes.
// Note that this may fail if PHP is run in "safe mode", or if
 
// operating system features (such as SELinux) or limitations
 
// prevent the web-server from executing external scripts.
 
// Parameters: (1) username (2) domain (3) maildir (4) quota
 
// $CONF['mailbox_postcreation_script']='sudo -u courier /usr/local/bin/postfixadmin-mailbox-postcreation.sh';
 
 
$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.
// Note that this may fail if PHP is run in "safe mode", or if
 
// operating system features (such as SELinux) or limitations
 
// prevent the web-server from executing external scripts.
 
// Parameters: (1) username (2) domain (3) maildir (4) quota
 
// $CONF['mailbox_postedit_script']='sudo -u courier /usr/local/bin/postfixadmin-mailbox-postedit.sh';
 
 
$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.
// Note that this may fail if PHP is run in "safe mode", or if
 
// operating system features (such as SELinux) or limitations
 
// prevent the web-server from executing external scripts.
 
// Parameters: (1) username (2) domain
 
// $CONF['mailbox_postdeletion_script']='sudo -u courier /usr/local/bin/postfixadmin-mailbox-postdeletion.sh';
 
 
$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.
// Note that this may fail if PHP is run in "safe mode", or if
 
// operating system features (such as SELinux) or limitations
 
// prevent the web-server from executing external scripts.
 
// Parameters: (1) domain
 
//$CONF['domain_postcreation_script']='sudo -u courier /usr/local/bin/postfixadmin-domain-postcreation.sh';
 
 
$CONF['domain_postcreation_script'] = '';
 
$CONF['domain_postcreation_script'] = '';
  
 
// Optional:
 
// Optional:
 
// Script to run after deletion of domains.
 
// Script to run after deletion of domains.
// Note that this may fail if PHP is run in "safe mode", or if
 
// operating system features (such as SELinux) or limitations
 
// prevent the web-server from executing external scripts.
 
// Parameters: (1) domain
 
// $CONF['domain_postdeletion_script']='sudo -u courier /usr/local/bin/postfixadmin-domain-postdeletion.sh';
 
 
$CONF['domain_postdeletion_script'] = '';
 
$CONF['domain_postdeletion_script'] = '';
  

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