instalare postfix

of 29 /29
Instalez Ubuntu de pe CD. Versiune 10.10 Pun IP-ul pt serverul de Mail si WEB. = 86.127.86.2, etc… Instalez serverul de ssh (pt logare de pe alt pc) sudo apt-get openssh-server Instalez update-urile si upgradez sudo apt-get update sudo apt-get upgrade Instalarea se va face ca si root !!!! su = parola de root Instalez Aptitude apt-get install aptitude Este important sa creez un simlynk la /bin/bash dpkg-reconfigure dash Install dash as /bin/sh? No si se face stopare si dezinstalare la AppArmor: /etc/init.d/apparmor stop update-rc.d -f apparmor remove aptitude remove apparmor apparmor-utils Instalare Postfix, Courier, Saslauthd, MySQL, phpMyAdmin Pentru instalare rulam urmatoare cmanda – se vor instala si pachetele dependente: aptitude install postfix postfix-mysql postfix-doc mysql-client mysql-server courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl postfix-tls libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl phpmyadmin apache2 libapache2-mod-php5 php5 php5-mysql libpam-smbpass Instalarea o sa puna niste intrebari: New password for the MySQL "root" user: yourrootsqlpassword Repeat password for the MySQL "root" user: yourrootsqlpassword Create directories for web-based administration? No General type of mail configuration: Internet Site System mail name: server1.example.com SSL certificate required Ok Web server to reconfigure automatically: apache2 Configure database for phpmyadmin with dbconfig-common? No Aplicare Patch-uri la Postfix Trebuie sa aducem sursele de Postfix, pach-urile si sa cream un pachet nou postfix.deb si sa-l instalam: aptitude build-dep postfix cd /usr/src apt-get source postfix (ai grija sa folosesti versiunea corecta pt Postfix in urmatoarele comenzi. Versiunea se afla cu: postconf -d | grep mail_version - raspunsul la comada ar fi cam asa : [email protected]:/usr/src# postconf -d | grep mail_version mail_version = 2.6.5 milter_macro_v = $mail_name $mail_version [email protected]:/usr/src# wget http://vda.sourceforge.net/VDA/postfix-2.6.5-vda-ng.patch.gz ultima versiune ii [wget http://vda.sourceforge.net/VDA/postfix-vda-2.7.0.patch] gunzip postfix-2.6.5-vda-ng.patch.gz cd postfix-2.6.5 patch -p1 < ../postfix-2.6.5-vda-ng.patch

Author: tiberiutanase1682

Post on 28-Nov-2014

272 views

Category:

Documents


4 download

Embed Size (px)

TRANSCRIPT

Instalez Ubuntu de pe CD. Versiune 10.10 Pun IP-ul pt serverul de Mail si WEB. = 86.127.86.2, etc Instalez serverul de ssh (pt logare de pe alt pc) sudo apt-get openssh-server Instalez update-urile si upgradez sudo apt-get update sudo apt-get upgrade Instalarea se va face ca si root !!!! su = parola de root Instalez Aptitude apt-get install aptitude Este important sa creez un simlynk la /bin/bash dpkg-reconfigure dash Install dash as /bin/sh? No si se face stopare si dezinstalare la AppArmor: /etc/init.d/apparmor stop update-rc.d -f apparmor remove aptitude remove apparmor apparmor-utils Instalare Postfix, Courier, Saslauthd, MySQL, phpMyAdmin Pentru instalare rulam urmatoare cmanda se vor instala si pachetele dependente: aptitude install postfix postfix-mysql postfix-doc mysql-client mysql-server courierauthdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imapssl postfix-tls libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl phpmyadmin apache2 libapache2-mod-php5 php5 php5-mysql libpam-smbpass Instalarea o sa puna niste intrebari:New password for the MySQL "root" user: yourrootsqlpassword Repeat password for the MySQL "root" user: yourrootsqlpassword Create directories for web-based administration? No General type of mail configuration: Internet Site System mail name: server1.example.com SSL certificate required Ok Web server to reconfigure automatically: apache2 Configure database for phpmyadmin with dbconfig-common? No

Aplicare Patch-uri la Postfix Trebuie sa aducem sursele de Postfix, pach-urile si sa cream un pachet nou postfix.deb si sa-l instalam: aptitude build-dep postfix cd /usr/src apt-get source postfix (ai grija sa folosesti versiunea corecta pt Postfix in urmatoarele comenzi. Versiunea se afla cu: postconf -d | grep mail_version - raspunsul la comada ar fi cam asa :[email protected]:/usr/src# postconf -d | grep mail_version mail_version = 2.6.5 milter_macro_v = $mail_name $mail_version [email protected]:/usr/src#

wget http://vda.sourceforge.net/VDA/postfix-2.6.5-vda-ng.patch.gz ultima versiune ii [wget http://vda.sourceforge.net/VDA/postfix-vda-2.7.0.patch] gunzip postfix-2.6.5-vda-ng.patch.gz cd postfix-2.6.5 patch -p1 < ../postfix-2.6.5-vda-ng.patch [in cazul curent la versiunea ultima = patch -p1 < ../postfix-vda-2.7.0.patch] dpkg-buildpackage Iesim din acest folder la nievelul superior unde avem noua versiune de pachet .deb create de noi. cd .. ls -l ne arata versiunea de pachete disponibila:

[email protected]:/usr/src# ls -l total 6248 drwxr-xr-x 23 root root 4096 2009-10-29 15:29 linux-headers-2.6.31-14 drwxr-xr-x 7 root root 4096 2009-10-29 15:29 linux-headers-2.6.31-14-server drwxr-xr-x 19 root root 4096 2009-11-26 15:42 postfix-2.6.5 -rw-r--r-- 1 root src 3824 2009-11-26 15:43 postfix_2.6.5-3_amd64.changes -rw-r--r-- 1 root src 1392702 2009-11-26 15:43 postfix_2.6.5-3_amd64.deb -rw-r--r-- 1 root src 231126 2009-11-26 15:39 postfix_2.6.5-3.diff.gz -rw-r--r-- 1 root src 1191 2009-11-26 15:39 postfix_2.6.5-3.dsc -rw-r--r-- 1 root src 3325444 2009-09-01 16:08 postfix_2.6.5.orig.tar.gz -rw-r--r-- 1 root src 58389 2009-09-14 15:15 postfix-2.6.5-vda-ng.patch -rw-r--r-- 1 root src 41908 2009-11-26 15:43 postfix-cdb_2.6.5-3_amd64.deb -rw-r--r-- 1 root src 145016 2009-11-26 15:43 postfix-dev_2.6.5-3_all.deb -rw-r--r-- 1 root src 977806 2009-11-26 15:43 postfix-doc_2.6.5-3_all.deb -rw-r--r-- 1 root src 50252 2009-11-26 15:43 postfix-ldap_2.6.5-3_amd64.deb -rw-r--r-- 1 root src 43942 2009-11-26 15:43 postfix-mysql_2.6.5-3_amd64.deb -rw-r--r-- 1 root src 43956 2009-11-26 15:43 postfix-pcre_2.6.5-3_amd64.deb -rw-r--r-- 1 root src 43996 2009-11-26 15:43 postfix-pgsql_2.6.5-3_amd64.deb [email protected]:/usr/src# [drwxr-xr-x 24 root root 4096 2010-10-30 13:09 linux-headers-2.6.35-22 drwxr-xr-x 7 root root 4096 2010-10-30 13:10 linux-headers-2.6.35-22-generic drwxr-xr-x 4 root root 4096 2010-10-30 16:11 postfix-2.6.5 -rw-r--r-- 1 root src 12435 2009-09-14 16:15 postfix-2.6.5-vda-ng.patch.gz drwxr-xr-x 4 root root 4096 2010-10-30 16:11 postfix-2.7.0 drwxr-xr-x 19 root root 4096 2010-10-30 16:22 postfix-2.7.1 -rw-r--r-- 1 root src 230907 2010-10-30 16:18 postfix_2.7.1-1.diff.gz -rw-r--r-- 1 root src 1181 2010-10-30 16:18 postfix_2.7.1-1.dsc -rw-r--r-- 1 root src 3958 2010-10-30 16:23 postfix_2.7.1-1_i386.changes -rw-r--r-- 1 root src 1318666 2010-10-30 16:23 postfix_2.7.1-1_i386.deb -rw-r--r-- 1 root src 3418747 2010-06-22 12:05 postfix_2.7.1.orig.tar.gz -rw-r--r-- 1 root src 41674 2010-10-30 16:23 postfix-cdb_2.7.1-1_i386.deb -rw-r--r-- 1 root src 146898 2010-10-30 16:23 postfix-dev_2.7.1-1_all.deb -rw-r--r-- 1 root src 998610 2010-10-30 16:23 postfix-doc_2.7.1-1_all.deb -rw-r--r-- 1 root src 49442 2010-10-30 16:23 postfix-ldap_2.7.1-1_i386.deb -rw-r--r-- 1 root src 43834 2010-10-30 16:23 postfix-mysql_2.7.1-1_i386.deb -rw-r--r-- 1 root src 43480 2010-10-30 16:23 postfix-pcre_2.7.1-1_i386.deb -rw-r--r-- 1 root src 43868 2010-10-30 16:23 postfix-pgsql_2.7.1-1_i386.deb -rw-r--r-- 1 root src 59667 2010-03-03 10:32 postfix-vda-2.7.0.patch o sa iau pachetul postfix si mysql [cele ingrosate-prin analogie]

dpkg -i postfix_2.6.5-3_amd64.deb postfix-mysql_2.6.5-3_amd64.deb [dpkg -i postfix-cdb_2.7.1-1_i386.deb postfix-mysql_2.7.1-1_i386.deb] Creez baza de date MySQL pentru Postfix/Courier Creem o baxa de date numita mail: mysqladmin -u root -p create mail Apoi intram in nucleul MySQL: mysql -u root -p Aici vom creea user-ul mail_admin cu parola mail_admin_password (se inlocuieste cu ceea ce dorim) care are privilegii de SELECT,INSERT,UPDATE,DELETE in baza de date mail. Acest user va fi folosit de Postfix si Courier pentru a se conecta la baza de date mail: GRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO 'mail_admin'@'localhost' IDENTIFIED BY 'mail_admin_password'; GRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO 'mail_admin'@'localhost.localdomain' IDENTIFIED BY 'mail_admin_password'; FLUSH PRIVILEGES; Tot aici (in nucleul Mysql) vom crea tablele de care au nevoie Postfix si Courier: USE mail; CREATE TABLE domains (domain varchar(50) NOT NULL,PRIMARY KEY (domain)) TYPE=MyISAM; CREATE TABLE forwardings (source varchar(80) NOT NULL,destination TEXT NOT NULL,PRIMARY KEY (source)) TYPE=MyISAM; CREATE TABLE users (email varchar(80) NOT NULL,password varchar(20) NOT NULL,quota

INT(10) DEFAULT '10485760',PRIMARY KEY (email)) TYPE=MyISAM; CREATE TABLE transport (domain varchar(128) NOT NULL default '',transport varchar(128) NOT NULL default '',UNIQUE KEY domain (domain)) TYPE=MyISAM; quit; -- paraseste nucleul Mysql

Tabela domains va contine fiecare domeniu virtual pentru care Postfix va receptiona emailuri (ex: terainfo.ro). Domain terainfo.ro umcugir.ro popcons.ro Tabela forwardings table se utilizeaza pentru a redirectiona un email de la un user al domeniului la alt user al domeniului [da mai departe un email de la un user la alt user - [email protected] la [email protected] ] source [email protected] destination [email protected]

Tabela users contine toti userii virtuali (i.e. adresele de email, deoarece adresa de email si numele userului este acelasi lucru) si parolele (in forma encrypted!) si valaorea de cota [quota=capacitate??] pntru fiecare cutie postala (in acest examplu valaorea implicita este de 10485760 bytes care inseamna 10MB). email [email protected] [email protected] password No9.E4skNvGa. ("secret" in encrypted form) ("secret" in encrypted form) quota 10485760 10485760

Tabela transport este optionala, este pentru user-ii avansati. Permite sa faca forward la email-uri la un singur user, a unui intreg domeniu sau toatel email-urile la un alt server. De examplu, domain terainfo.ro transport smtp:[1.2.3.4]

Chestia asta va face forward la toate email-urile pentru terainfo.ro via protocolul smtp la serverul cu adresa IP 1.2.3.4 (parantezele drepte [] inseamna "nu te uita la MX DNS record" ). Daca se folsoete un domeniu calificat [ fully qualified domain name (FQDN)] nu se va folosi parantezele drepte [].).BTW, (I'm assuming that the IP address of your mail server system is 192.168.0.100) you can access phpMyAdmin over http://192.168.0.100/phpmyadmin/ in a browser and log in as mail_admin. Then you can have a look at the database. Later on you can use phpMyAdmin to administrate your mail server.

Configurare Postfix Acum trebuie sa ii zicem la Postfix unde gaseste toate informatiile in baza de date. Prin urmare trebuie sa creem 6 fisiere text. Vei observa c ii spun Postfix-ului sa se conecteze la MySQL pe adresa de IP 127.0.0.1 in loc de localhost. Acest lucru este din cauz ca Postfix ruleaza in cusca chroot [chroot jail] si nu are acces la socketul de MySQL la care ar incerca sa se conecteze daca i-as fi zis la Postfix sa foloseasca localhost. Daca utilizez 127.0.0.1 Postfix foloseste reteaua TCP pentru a se conecta la MySQL ceea ce nu ar fi nici o problema chiar si in cazul unui chroot jail (alternativa ar fi s se mute socketul MySQL socket in chroot jail care ar cauza oarecare probleme). Verificati ca fisiserul /etc/mysql/my.cnf sa contina urmatoarea linie:[...] # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. # bind-address = 127.0.0.1 [...]

Daca a trebuit sa modoficati /etc/mysql/my.cnf, restartati MySQL: /etc/init.d/mysql restart

Run netstat -tap | grep mysql pentru a ne asigura ca MySQL asculta la 127.0.0.1 (localhost.localdomain):[email protected]:/usr/src# netstat -tap | grep mysql tcp 0 0 *:mysql *:* LISTEN [email protected]:/usr/src# *************** 16459/mysqld

Sa creem cele 6 fisiere de tip text. vi /etc/postfix/mysql-virtual_domains.cf Asigura-te ca se inlocuieste "mail_admin_password" cu parola aleasa anterior pentru MySQL mail administrator user. user = mail_admin password = mail_admin_password dbname = mail query = SELECT domain AS virtual FROM domains WHERE domain='%s' hosts = 127.0.0.1 vi /etc/postfix/mysql-virtual_forwardings.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT destination FROM forwardings WHERE source='%s' hosts = 127.0.0.1 vi /etc/postfix/mysql-virtual_mailboxes.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM users WHERE email='%s' hosts = 127.0.0.1 vi /etc/postfix/mysql-virtual_email2email.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT email FROM users WHERE email='%s' hosts = 127.0.0.1 vi /etc/postfix/mysql-virtual_transports.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT transport FROM transport WHERE domain='%s' hosts = 127.0.0.1 vi /etc/postfix/mysql-virtual_mailbox_limit_maps.cf user = mail_admin password = mail_admin_password dbname = mail query = SELECT quota FROM users WHERE email='%s' hosts = 127.0.0.1 Acum se vor schimba permisiile si grupurile pentru fieisierele mysql-virtual*: chmod 640 /etc/postfix/mysql-virtual_*.cf chgrp postfix /etc/postfix/mysql-virtual_*.cf Acum vom creea un user si grup numit vmail cu directorul de Home in /home/vmail. Aici se vor stoca toate cutiile postale. groupadd -g 5000 vmail useradd -g vmail -u 5000 vmail -d /home/vmail -m Vom configura un pic Postfix. Asigurati-va ca inlocuiti server1.example.com cu un valid FQDN, altfel Postfix

s-ar putea sa nu functioneze corect! server1.example.com mail.terainfo.ro postconf -e 'myhostname = server1.example.com' postconf -e 'mydestination = server1.example.com, localhost, localhost.localdomain' postconf -e 'mynetworks = 127.0.0.0/8' postconf -e 'virtual_alias_domains =' postconf -e 'virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf' postconf -e 'virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf' postconf -e 'virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf' postconf -e 'virtual_mailbox_base = /home/vmail' postconf -e 'virtual_uid_maps = static:5000' postconf -e 'virtual_gid_maps = static:5000' postconf -e 'smtpd_sasl_auth_enable = yes' postconf -e 'broken_sasl_auth_clients = yes' postconf -e 'smtpd_sasl_authenticated_header = yes' postconf -e 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination' postconf -e 'smtpd_use_tls = yes' postconf -e 'smtpd_tls_cert_file = /etc/postfix/smtpd.cert' postconf -e 'smtpd_tls_key_file = /etc/postfix/smtpd.key' postconf -e 'transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf' postconf -e 'virtual_create_maildirsize = yes' postconf -e 'virtual_maildir_extended = yes' postconf -e 'virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysqlvirtual_mailbox_limit_maps.cf' postconf -e 'virtual_mailbox_limit_override = yes' postconf -e 'virtual_maildir_limit_message = "The user you are trying to reach is over quota."' postconf -e 'virtual_overquota_bounce = yes' postconf -e 'proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps' Dupa aceea vom creea certificatul SSL care ne trebuie pentru TLS: cd /etc/postfix openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509Country Name (2 letter code) [AU]: Plugin-ul de schimbare a parolei SQL depinde de asemenea de Compatibility plugin care il vom instala astfel: cd /us r/share/squirrelmail/plugins wget http://www.squirrelmail.org/countdl.php?fileurl=http%3A%2F%2Fwww.squirrelmail.org %2Fplugins%2Fcompatibility-2.0.15-1.0.tar.gz tar xvfz compatibility-2.0.15-1.0.tar.gz Acum trebuie sa mergem la configurarea SquirrelMail si sa-i spunem ca utilizam Courier ca si POP3 si IMAP server si sa validam Change SQL Password si Compatibility plugins: /usr/sbin/squirrelmail-configure Afisam meniul de configurare. Navigati pe unde indicam:SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------Main Menu -1. Organization Preferences 2. Server Settings 3. Folder Defaults 4. General Options 5. Themes 6. Address Books 7. Message of the Day (MOTD) 8. Plugins 9. Database 10. Languages D. Set pre-defined settings for specific IMAP servers C Turn color on S Save data Q Quit Command >> > > > S Data saved in config.php Press enter to continue... >