Postiserveri paigaldamist CentOS 7-le saab teha mitmel viisil, kuid üks levinumaid on Postfixi ja Dovecot'i kombinatsiooni kasutamine.
Postfix on saatjatarkvara ja on üks populaarsemaid mailiservereid maailmas. Dovecot seevastu on postiserver, mida kasutatakse IMAP- või POP-protokolliga e-posti vastuvõtmiseks.
Exim on postiülekandeagent (MTA), mida kasutatakse tavaliselt Unix-taolistes operatsioonisüsteemides. Exim on tasuta tarkvara, mida levitatakse GNU (General Public Licence) tingimustel ja see on mitmekülgne ja paindlik e-posti vahend, millel on ulatuslikud funktsioonid sissetuleva e-posti kontrollimiseks.
Dovecot on avatud lähtekoodiga IMAP- ja POP3-posti server Linux/UNIX-taolistele süsteemidele. Turvalisus on olnud selle toote nurgakiviks, mis on keskendunud paindlikkusele ja kiirusele.
Roundcube on veebipõhine e-posti kasutajaliides, mis pakub võimalust töötada oma postkastidega, kasutades IMAPi ja SMTP-d. Rakendusel on võimas funktsionaalsus ja see on oma võimaluste poolest võrreldav töölaua e-posti klientidega nagu Outlook Express või Mozilla Thunderbird.
Logige SSH kaudu oma virtuaalsesse serverisse sisse.
Järgmisena peate süsteemi uuendama, sisestage käsk:
# sudo yum update -y
Pärast süsteemi uuendamist ilmub selline teade.
Apache'i paigaldamiseks oma virtuaalsesse serverisse sisesta käsk:
# sudo yum install httpd -y
Pärast paigaldamist käivitage Apache:
# sudo systemctl start httpd.service
Pärast seda minge aadressile - http://ServerIP/
ja kontrollige, kas Apache töötab korralikult.
Kui kõik toimib korrektselt, sisestage käsk Apache'i automaatseks käivitamiseks virtuaalserveris:
# sudo systemctl enable httpd.service
Allalaadimiseks kasutage käsku:
# sudo yum install mariadb-server mariadb -y
Pärast allalaadimist ja paigaldamist tuleb käivitada MariaDB:
# sudo systemctl start mariadb
Käivita turvaline paigaldusskript, mis eemaldab ebaturvalised seaded:
# sudo mysql_secure_installation
Sisestage root parool, kuna te just lõite andmebaasi, on see vaikimisi tühi. Seejärel nõustuge seadistustega, sisestage igal pool"Y
". Sisestage uus parool, kinnitage see ja nõustuge taas muudatustega"Y
".
MariaDB on nüüd paigaldatud.
PHP installimiseks sisesta käsk:
# sudo yum install php php-mysql -y
Järgmisena taaskäivitage Apache, et ta saaks PHP-d käivitada:
# sudo systemctl restart httpd.service
Et testida, kuidas PHP töötab, sisestage peate tegema faili, näiteks index.php, kasutades seda käsku:
# echo "<?php phpinfo(); ?>" > /var/www/html/index.php
Nüüd avage link oma brauseris - http://ServerIP/index.php
Te peaksite nägema lehekülge PHP parameetritega.
Järgmisena peate installima paketi, et toetada MariaDB-d PHP-s:
# sudo yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
Pärast seda te taaskäivitate Apache:
# sudo systemctl restart httpd.service
Valmis. Te olete paigaldanud Apache, MySQL ja PHP virtuaalsesse serverisse.
Täiendavate repositooriumide ühendamine
Kõigi komponentide paigaldamiseks peate ühendama täiendava repositooriumi.
# sudo yum install epel-release
Selleks, et luua ühendus kõigi ahela komponentide vahel, on vaja kasutada ühte andmebaasi. Ühendage MySQL serveriga:
# mysql -u root -p
Looge andmebaas, peate määrama oma parooli:
CREATE DATABASE vexim;
GRANT ALL ON vexim.* to vexim@localhost identified by 'password';
quit
Juhul, kui kõik PHP-moodulid ei ole paigaldatud, on vajalik täiendav installeerimine.
# yum -y install php-imap php-mbstring php-pdo php-mysql php-cli
Laadige alla Postfixadmin ja installige see kausta /var/www/html/postfixadmin
.
# wget http://sourceforge.net/projects/postfixadmin/files/postfixadmin/postfixadmin-3.0/postfixadmin-3.0.tar.gz
# tar xpf postfixadmin-3.0.tar.gz
# mv postfixadmin-3.0 /var/www/html/postfixadmin
# chown -R apache:apache /var/www/html/postfixadmin
# rm postfixadmin-3.0.tar.gz
# cd /var/www/html/postfixadmin > # vi config.inc.php
Redigeerige konfiguratsioonifaili config .inc.php
:
# yum -y install dovecot dovecot-mysql
Nimetage vaikimisi konfig ümber, et saaksime vajadusel tagasi pöörduda:
# mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf-orig
# vi /etc/dovecot/dovecot.conf
Salvestage konfiguratsioonifaili dovecot.conf
järgmised kanded:
## Dovecot configuration file
base_dir = /var/run/dovecot/
auth_default_realm = site.com
auth_mechanisms = plain login cram-md5
protocols = imap pop3
listen = *
disable_plaintext_auth = no
dotlock_use_excl = yes
first_valid_gid = 5
first_valid_uid = 25
mail_location = maildir:/var/vmail/%d/%u
mail_privileged_group = mail
passdb {
args = /etc/dovecot/dovecot-mysql.conf
driver = sql
}
service auth {
unix_listener auth-client {
group = exim
mode = 0660
user = exim
}
unix_listener auth-master {
group = exim
mode = 0600
user = exim
}
user = root
}
ssl = no
userdb {
args = /etc/dovecot/dovecot-mysql.conf
driver = sql
}
verbose_proctitle = yes
protocol imap {
imap_client_workarounds = delay-newmail tb-extra-mailbox-sep
}
protocol pop3 {
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
pop3_uidl_format = %08Xu%08Xv
}
protocol lda {
auth_socket_path = /var/run/dovecot/auth-master
postmaster_address = info@site.com
}
Andmebaasile juurdepääsu konfigureerimiseks looge eraldi konfigfail dovecot-mysql.conf
# vi /etc/dovecot/dovecot-mysql.conf
ja sisestage sinna järgmised seaded:
## Dovecot database configuration
driver = mysql
connect = host=localhost dbname=vexim user=vexim password=password
default_pass_scheme = CRAM-MD5
password_query = SELECT `username` as `user`, `password` FROM `mailbox` WHERE `username` = '%n@%d' AND `active`='1'
user_query = SELECT 93 AS `uid`, 93 AS `gid` FROM `mailbox` WHERE `username` = '%n@%d' AND `active`='1'
# yum -y install exim exim-mysql cyrus-sasl
# mv /etc/exim/exim.conf /etc/exim/exim.conf-orig
# vi /etc/exim/exim.conf
Muutke vaikimisi konfig, säilitades samal ajal varukoopia.
######################################################################
# MAIN CONFIGURATION SETTINGS #
######################################################################
primary_hostname = mail.site.com
hide mysql_servers = localhost/vexim/vexim/password
domainlist local_domains = ${lookup mysql{SELECT `domain`
FROM `domain` WHERE
`domain`='${quote_mysql:$domain}' AND
`active`='1'}}
domainlist relay_to_domains = ${lookup mysql{SELECT `domain`
FROM `domain` WHERE
`domain`='${quote_mysql:$domain}' AND
`active`='1'}}
hostlist relay_from_hosts = localhost:127.0.0.0/8:192.168.1.0/24
auth_advertise_hosts = *
acl_not_smtp = acl_not_smtp
acl_smtp_rcpt = acl_check_rcpt
acl_smtp_data = acl_check_data
qualify_domain = site.com
qualify_recipient = site.com
allow_domain_literals = true
exim_user = exim
exim_group = exim
never_users = root
rfc1413_query_timeout = 0s
sender_unqualified_hosts = +relay_from_hosts
recipient_unqualified_hosts = +relay_from_hosts
ignore_bounce_errors_after = 45m
timeout_frozen_after = 15d
helo_accept_junk_hosts = 192.168.1.0/24
auto_thaw = 1h
smtp_banner = "$primary_hostname, ESMTP EXIM $version_number"
smtp_accept_max = 50
smtp_accept_max_per_connection = 25
smtp_connect_backlog = 30
smtp_accept_max_per_host = 20
split_spool_directory = true
remote_max_parallel = 15
return_size_limit = 70k
message_size_limit = 64M
helo_allow_chars = _
smtp_enforce_sync = true
log_selector =
+all_parents
+connection_reject
+incoming_interface
+lost_incoming_connection
+received_sender
+received_recipients
+smtp_confirmation
+smtp_syntax_error
+smtp_protocol_error
-queue_run
syslog_timestamp = no
######################################################################
# ACL CONFIGURATION #
# Specifies access control lists for incoming SMTP mail #
######################################################################
begin acl
acl_not_smtp:
deny message = Sender rate overlimit - $sender_rate / $sender_rate_period
ratelimit = 50 / 1h / strict
accept
acl_check_rcpt:
deny message = "Lookup failed"
condition = ${if eq{$host_lookup_failed}{1}}
accept hosts = :
deny message = "incorrect symbol in address"
domains = +local_domains
local_parts = ^[.] : ^.*[@%!/|]
deny message = "incorrect symbol in address"
domains = !+local_domains
local_parts = ^[./|] : ^.*[@%!] : ^.*/\.\./
accept local_parts = postmaster
domains = +local_domains
deny message = "HELO/EHLO required by SMTP RFC"
condition = ${if eq{$sender_helo_name}{}{yes}{no}}
accept authenticated = *
deny condition = ${if eq{$sender_helo_name}
{$interface_address}{yes}{no}}
hosts = !127.0.0.1 : !localhost : *
message = "My IP in your HELO! Access denied!"
deny condition = ${if match{$sender_helo_name}
{N^d+$N}{yes}{no}}
hosts = !127.0.0.1 : !localhost : *
message = "Incorrect HELO string"
warn
set acl_m0 = 30s
warn
hosts = +relay_from_hosts:4.3.2.1/32:192.168.1.0/24 #disable waits for 'friendly' hosts
set acl_m0 = 0s
warn
logwrite = Delay $acl_m0 for $sender_host_name
[$sender_host_address] with HELO=$sender_helo_name. Mail
from $sender_address to $local_part@$domain.
delay = $acl_m0
accept domains = +local_domains
endpass
message = "No such user"
verify = recipient
accept domains = +relay_to_domains
endpass
message = "i don't know how to relay to this address"
verify = recipient
deny message = "you in blacklist - $dnslist_domain n $dnslist_text"
dnslists = opm.blitzed.org :
cbl.abuseat.org :
bl.csma.biz
accept hosts = +relay_from_hosts
deny message = "Homo hominus lupus est"
acl_check_dаta:
deny malware = */defer_ok
message = "Your message contains viruses: $malware_name"
accept
######################################################################
# ROUTERS CONFIGURATION #
# Specifies how addresses are handled #
######################################################################
# THE ORDER IN WHICH THE ROUTERS ARE DEFINED IS IMPORTANT! #
# An address is passed to each router in turn until it is accepted. #
######################################################################
begin routers
dnslookup:
driver = dnslookup
domains = ! +local_domains
transport = remote_smtp
ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
no_more
system_aliases:
driver = redirect
allow_fail
allow_defer
data = ${lookup mysql{SELECT `goto` FROM `alias` WHERE
`address`='${quote_mysql:$local_part@$domain}' OR
`address`='${quote_mysql:@$domain}'}}
dovecot_user:
driver = accept
condition = ${lookup mysql{SELECT `goto` FROM
`alias` WHERE
`address`='${quote_mysql:$local_part@$domain}' OR
`address`='${quote_mysql:@$domain}'}{yes}{no}}
transport = dovecot_delivery
######################################################################
# TRANSPORTS CONFIGURATION #
######################################################################
# ORDER DOES NOT MATTER #
# Only one appropriate transport is called for each delivery. #
######################################################################
begin transports
remote_smtp:
driver = smtp
dovecot_delivery:
driver = pipe
command = /usr/libexec/dovecot/deliver -d $local_part@$domain
message_prefix =
message_suffix =
delivery_date_add
envelope_to_add
return_path_add
log_output
user = exim
address_pipe:
driver = pipe
return_output
address_reply:
driver = autoreply
######################################################################
# RETRY CONFIGURATION #
######################################################################
begin retry
* * F,2h,15m; G,16h,1h,1.5; F,4d,6h
######################################################################
# REWRITE CONFIGURATION #
######################################################################
begin rewrite
######################################################################
# AUTHENTICATION CONFIGURATION #
######################################################################
begin authenticators
auth_plain:
driver = dovecot
public_name = PLAIN
server_socket = /var/run/dovecot/auth-client
server_set_id = $auth1
auth_login:
driver = dovecot
public_name = LOGIN
server_socket = /var/run/dovecot/auth-client
server_set_id = $auth1
auth_cram_md5:
driver = dovecot
public_name = CRAM-MD5
server_socket = /var/run/dovecot/auth-client
server_set_id = $auth1
Postfixi desinstalleerimine
# alternatives --config mta
# systemctl disable postfix
# systemctl stop postfix
# yum -y remove postfix
Mine aadressile http://server_ip/postfixadmin/setup.php
ja järgi paigaldusjuhiseid. Pärast superadmini loomist annab paigaldaja teile parooli hash-koodi:
See tuleb asendada failis config.inc.php
(postfixadmin kataloogi juurest) selle rea asemel:
Seejärel tuleb loodud andmete all sisse logida, lisada vajalikud domeenid ja postkastid.
Roundcube'i paigaldamine
# yum -y install roundcubemail
Pärast paigaldamist tuleb lisada config veebiserverisse, et skript avaneks aadressil http://server_ip/roundcubemail/.
# vi /etc/httpd/conf.d/roundcubemail.conf
Salvestage järgmised andmed:
#
# Round Cube Webmail is a browser-based multilingual IMAP client
#
Alias /roundcubemail /usr/share/roundcubemail
Alias /webmail /usr/share/roundcubemail
<Directory /usr/share/roundcubemail/>
Options none
AllowOverride Limit
Require all granted
</Directory>
<Directory /usr/share/roundcubemail/installer>
Options none
AllowOverride Limit
Require all granted
</Directory>
# Those directories should not be viewed by Web clients.
<Directory /usr/share/roundcubemail/bin/>
Order Allow,Deny
Deny from all
</Directory>
<Directory /usr/share/roundcubemail/plugins/enigma/home/>
Order Allow,Deny
Deny from all
</Directory>
Apache tuleb pärast kirjutamist taaskäivitada:
# systemctl restart httpd.service
Edasiseks paigaldamiseks luua andmebaas, selleks ühendada MySQL:
# mysql -u root -p
ja sooritage päringuid (määrake oma andmed):
CREATE DATABASE roundcubedb;
CREATE USER roundcubeuser@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES on roundcubedb.* to roundcubeuser@localhost ;
FLUSH PRIVILEGES;
quit
Järgmisena tuleb avada paigaldusprogramm http://server_ip/roundcubemail/installer
ja konfigureerida.
See lõpetab konfiguratsiooni, mine Roundcube http://server_ip/roundcubemail/,
logi sisse eelnevalt loodud (Postfixadminis) kasti, tee seaded ja kasuta.