Instalasi Mail Server
Yang perlu diketahui Untuk Membuat Mail dan Webserver :
Freebsd, Operating System
Postfix, SMTP server
Dovecot, POP3(s) and IMAP(s) server
Postfixadmin, PHP tool untuk manage postfix
Squirrelmail, webmail system
Clamav, Antivirus
Membuat Mail Server
1. Install Apache
Locate Apache <-- untuk mengetahui letak Apache
#cd /usr/ports/www/apache22
# make
……………
[X]Mysql
...................
# make install
#ee etc/rc.conf
apache22_enable=”YES”
/usr/local/etc/rc.d/apache22 start <-- Menjalankan apache
2. Install PHP
cd /usr/ports/lang/php5
make
…………...
[X] Apache
[X] Multibyte
make install
cd /usr/ports/lang/php5
more pkg-message.mod
ee /usr/local/etc/apache22/httpd.conf
Tambahkan :
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
save
Untuk mengetahui PHP sudah aktif berada di dalam file index.php
cd /usr/local/www/apache22/data
ee index.php
/usr/local/etc/rc.d/apache22 restart
Test in your browser
it must works!
3. Install MySQL
cd /usr/ports/databases/mysql50-server
make
make install
#ee etc/rc.conf
mysql_enable=”YES”
/usr/local/etc/rc.d/mysql-server start
ps –aux <- melihat sudah jalan atau belum
4. Install Phpmyadmin
cd /usr/ports/databases/phpmyadmin
make
make install
5. Install Dovecot
cd /usr/ports/mail/dovecot
make
…….
[X] MySQL
Make install
6. Install Postfix
cd /usr/ports/mail/postfix
make
and select
[PCRE]
[SASL2]
[DOVECOT]
[TLS]
[MYSQL]
……………………….
[BDB]
[MySQL]
Perintah diatas akan mendownload and compile postfix dan dovecot,
#ee /etc/rc.conf
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
postfix_enable="YES"
6. Install postfixadmin :
# /usr/ports/mail/postfixadmin
# make
[MySQ]
# make install
# ee /usr/local/etc/apache22/httpd.conf
# Search for
Before :
DirectoryIndex index.html
After :
DirectoryIndex index.html index.php
Restart apache go to host/postfixadmin/
Setup
# mysqladmin -u root password xxxxxxx
Warning imap
# locate php5-imap
# cd /usr/ports/mail/php5-imap
# make
# make install
# /usr/local/etc/rc.d/apache22 restart
Warning magic quotes :
# cd /usr/local/etc/
# cp php.ini-dist php.ini
# ee php.ini
Before :
AllowOverride None
Order deny,allow
Deny from all
After :
AllowOverride Limit
Order deny,allow
Allow from all
Create the database. Then edit config.inc.php in the postfixadmin
# cd /usr/local/www/postfixadmin/
# ee config.inc.php
Before :
$CONF(‘configured’) = false;
After :
$CONF(‘configured’) = true;
- database_password to the password you changed in DATABASE_MYSQL.TXT
- replace change-this-to-your.domain.tld with your domain name
- domain_path' = YES
- domain_in_mailbox' = 'NO';
- ‘encrypt' = 'cleartext';
Now try to access your site using your servername (remember we’re using name based virtual hosting). You should see all OKs. If it is as expected, delete setup.php and click to Admin section. You’ll log in using admin/admin: change this using htpasswd against the .htpasswd file in the admin directory.
# mv setup.php setup.php.bak
# cd /usr/local/etc/postfix/
# ee main.cf
virtual_alias_maps = mysql:/usr/local/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:125
virtual_mailbox_base = /usr/local/virtual
virtual_mailbox_domains = mysql:/usr/local/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = mysql:/usr/local/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 125
virtual_transport = virtual
virtual_uid_maps = static:125
Replacing :
- /usr/local/virtual with your mailbox base path
- 125 with the userid of the postfix user
Limit local access to postfixadmin
# mkdir /usr/local/virtual
# chown postfix:postfix /usr/local/virtual/
Create a file named ‘mysql_virtual_alias_maps.cf’ in /usr/local/etc/postfix containing
# ee mysql_virtual_alias_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
query = SELECT goto FROM alias WHERE address='%s' AND active = 1
Here and in the files that follow, replace the password for user postfix with the one you changed in DATABASE_MYSQL.TXT.
Create mysql_virtual_domains_maps.cf with
user = postfix
password = postfix
hosts = localhost
dbname = postfix
query = SELECT domain FROM domain WHERE domain='%s'
Create mysql_virtual_mailbox_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
query = SELECT maildir FROM mailbox WHERE username='%s' AND active = 1
Now create the directory tree:
cd /usr/local/virtual
mkdir -p /usr/local/virtual/mydomain.com
chmod -R 770 /usr/local/virtual
chown -R postfix:postfix /usr/local/virtual
Now we need to configure dovecot.
cp /usr/local/etc/dovecot-example.conf /usr/local/etc/dovecot.conf, and edit dovecot.conf
changing :
- disable_plaintext_auth = no
- log_path = /var/log/dovecot.log
- ssl_disable = yes
- mail_location = maildir:/usr/local/virtual/%d/%n
- first_valid_uid = 125
- last_valid_uid = 125
Uncomment and complete this:
passdb sql {
args = /usr/local/etc/dovecot-mysql.conf
}
userdb sql {
args = /usr/local/etc/dovecot-mysql.conf
}
Create a file named ‘/usr/local/etc/dovecot-mysql.conf’ containing
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=postfix
user_query = SELECT concat('/usr/local/virtual/', maildir) as home, concat('maildir:/usr/local/virtual/', maildir) as mail, 125 AS uid, 125 AS gid, concat('maildir:storage=', quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1'
password_query = SELECT username as user, password, concat('/usr/local/virtual/', maildir) as userdb_home, concat('maildir:/usr/local/virtual/', maildir) as userdb_mail, 125 as userdb_uid, 125 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'
default_pass_scheme = PLAIN
# /usr/local/etc/rc.d/postfix start