Thursday 5 April 2012

How to setup postfix + dovecot mail server based on CentOS 6.2

This have been taking me hours to configure it.

1. Stop the sendmail service and remove it
> service sendmail stop
> yum remove sendmail

2. Install Postfix and Dovecot
> yum install postfix dovecot

3. Edit you hosts file and Add 'mail.yourdomain.com' and 'mail' to 127.0.0.1
> vi /etc/hosts

4. Edit the programs configuration. Mostly about user, servername, etc...
(Will edit later for details)
> vi /etc/postfix/main.cf
> vi /etc/dovecot/dovecot.conf
> vi /etc/aliases

4A. postfix/main.cf sample, configs that added.
myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all 
inet_protocols = ipv4 # required for CentOS 7 ~ 
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydestination = $myhostname, $mydomain
mynetworks = 192.168.0.0/24, 127.0.0.0/8
#relay_domains =
home_mailbox = Maildir/
smtpd_recipient_restrictions=permit_mynetworks,reject_unauth_destination
#relayhost = your-hosting-site-mail-relay.yourhostingsite.com
FIGURE 4B. dovecot.conf sample, configs that added.
protocols = imap pop3
mail_location = maildir:~/Maildir
pop3_uidl_format = %08Xu%08Xv 
FIGURE 4C. /etc/aliases sample
# Person who should get root's mail
root:           kiddokenshin

5. Switch your MTA configuration and make sure is SMTP
> alternatives --config mta

6. Add mail user account (without SSH login)
> useradd -s /sbin/nologin youruser
> passwd youruser
> echo "youruserpasswd" | saslpasswd2 -p -u yourdomain.com -c youruser
> sasldblistusers2
> chgrp postfix /etc/sasldb2

7. Start your mail server
> service dovecot start
> service postfix start

8. Check your smtp port availability
> telnet localhost 25

Remember to add MX record and CNAME record on your domain manager. Most probably your mail server is working right now.

!! CAUTION !!
- If you cant send your mail out, most probably its the firewall's fault.
- Some rental server(or hosting site) required you to relay to their mail server to send mail.

If you like to use web browser to view and reply mail,
follow the optional instruction below to install the web based mailer, squirrelmail.

Installing squirrelmail (Optional)
A. Install EPEL Repository
> wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
> rpm -i epel-release-6-5.noarch.rpm

B. Install and Config SquirrelMail
(configure your squirrelmail, such as server name, smtp domain etc...)
> yum install squirrelmail
> /usr/share/squirrelmail/config/conf.pl

C. Edit httpd.conf and Restart httpd (assuming you have httpd)
> vi /etc/httpd/conf/httpd.conf
> service httpd restart

SAMPLE of httpd.conf
Alias /squirrelmail /usr/share/squirrelmail
<Directory /usr/share/squirrelmail>
    Options Indexes FollowSymLinks
    RewriteEngine On
    AllowOverride All
    DirectoryIndex index.php
    Order allow,deny
    Allow from all
</Directory>

Log into http://yourdomain.com/squirrelmail to access it.

Monday 2 April 2012

How to setup SVN server with httpd based on centos 6.2

Installing SVN server is quite a headache.
This is my installation steps based on centos 6.2

1. Install Httpd and Subversion
> yum install httpd mod_dav_svn subversion

2. Edit your httpd.conf (at least change your server name)
> vi /etc/httpd/conf/httpd.conf

3. Edit http's subversion.conf (path to svn repos, set auth type and password path)
> vi /etc/httpd/conf.d/subversion.conf

It should be something like this.
<Location /repos>
   DAV svn
   SVNParentPath /var/www/svn/repos
#
#   # Limit write permission to list of valid users.
#   <LimitExcept GET PROPFIND OPTIONS REPORT>
#      # Require SSL connection for password protection.
#      # SSLRequireSSL
#
### You can comment the lines here if you do not need auth
      AuthType Basic
      AuthName "Authorization Realm"
      AuthUserFile /etc/svn-auth-conf
#      AuthUserFile /path/to/passwdfile
      Require valid-user
#   </LimitExcept>
</Location>

4. Create user for svn (if you are using auth to commit / check out)
> htpasswd -cm /etc/svn-auth-conf yoursvnuser

5. Create svn a repo
> mkdir -p /var/www/svn
> svnadmin create /var/www/svn/repos
> chown -R apache.apache /var/www/svn/repos

6. Local commit to repo
> svn import /tmp/somefolder file:////var/www/svn/repos -m "Initial commit"

7. Start your httpd
> service httpd start

8. Try checking out from the newly created repo
> svn co http://yourdomain/repos

There, a workable new svn server.

Sunday 1 April 2012

KiddoKenshin Personal Research and Development

JA
東京に上京してから最早6年目です。

今までは、
仕事上では他人のブログやソースなどのおかげで、
大変助かりました。

そんでもって、転職したあとに考えたのは、
自分も今まで吸収した知識を共有したいと思って、
ブログを開きました。

近いうちになんかブラウザベースなオープンソースの何かを作る予定です。
つまり HTML + CSS + JavaScript /w jQuery です。
よろしくお願いいたします。

EN
It's been 6 years ever since I landed on Tokyo.

During my previous carrier,
I was able to solve lots of problem thanks to someone's blog/source/forum replies.

So what am I thinking lately after I switched my job, was.
I would like to contribute it back with my knowledge.
As a result, I made this blog.

Well, I will make an browser based open-source something in a near future.
Which means HTML + CSS + JavaScript /w jQuery in involve.