<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Narnio&#187; debian</title>
	<atom:link href="http://www.narnio.com/tag/debian/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.narnio.com</link>
	<description>A day in the life of a software engineer</description>
	<lastBuildDate>Sat, 28 Aug 2010 16:18:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Memory issues finally solved</title>
		<link>http://www.narnio.com/2009/10/24/memory-issues-finally-solved/</link>
		<comments>http://www.narnio.com/2009/10/24/memory-issues-finally-solved/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 11:13:11 +0000</pubDate>
		<dc:creator>Jongerius</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[dovecot]]></category>

		<guid isPermaLink="false">http://www.narnio.com/?p=394</guid>
		<description><![CDATA[As I posted before in &#8216;Mysterious problems with my VPS&#8217;, I recently got an increasingly unstable VPS system hosting a lot of my and my customers sites. After a lot of digging I initially presumed that Dovecot (the mail server) was responsible for the issues, as you can read in &#8216;Dovecot causing memory issues&#8217;.
Last week [...]]]></description>
			<content:encoded><![CDATA[<p>As I posted before in <a title="View the post" href="http://www.narnio.com/2009/10/15/mysterious-problems-with-my-vps/">&#8216;Mysterious problems with my VPS&#8217;</a>, I recently got an increasingly unstable VPS system hosting a lot of my and my customers sites. After a lot of digging I initially presumed that Dovecot (the mail server) was responsible for the issues, as you can read in <a title="View the post" href="http://www.narnio.com/2009/10/18/dovecot-causing-memory-issues/">&#8216;Dovecot causing memory issues&#8217;</a>.</p>
<p>Last week I did a lot of debugging on the Debian server to try and find out what was the issue. And initially it was Dovecots memory usage. After disabling this tool for a couple of days the server was still running fine. However the day after I posted the article on Dovecot the server crashed again. So I had to restart my investigation.</p>
<p>First off I had to had to get a better memory management tool, so I installed <em>Htop</em> on the server <em>(apt-get htop</em>)<em>. </em>This shows the current memory usage of each running application. After installing this I enabled all services and applications again and started running stress tests. And though Dovecot was causing some peeks in memory usage it did not keep the high memory usage after the requests where done.</p>
<p>As it turns out for some reason Apache 2.2 was using a lot of memory during peak loads. But even more frustrating it didn&#8217;t seem to release any memory any more. Which was causing issues for services that only spawn when they are being accessed like Dovecot and Postfix, which explained why both of these services crashed when the server halted.</p>
<p>After tweaking the maximum amount of servers Apache is allowed to start and the maximum amount of client threads to handle the memory usage dropped dramatically. And I am very happy to report that the server has been running again for more then a week, without any glitches.</p>
<p>Still it doesn&#8217;t explain why all of this only happened after updating my server with the latest versions and patches. But I&#8217;m glad it&#8217;s solved for now.</p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.narnio.com">Narnio</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@jong-soft.com so we can take legal action immediately.]]></content:encoded>
			<wfw:commentRss>http://www.narnio.com/2009/10/24/memory-issues-finally-solved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mysterious problems with my VPS</title>
		<link>http://www.narnio.com/2009/10/15/mysterious-problems-with-my-vps/</link>
		<comments>http://www.narnio.com/2009/10/15/mysterious-problems-with-my-vps/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 16:32:01 +0000</pubDate>
		<dc:creator>Jongerius</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General Rant]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[VPS]]></category>

		<guid isPermaLink="false">http://www.narnio.com/?p=390</guid>
		<description><![CDATA[I&#8217;ve heard a lot of people always say that you can&#8217;t crash/hang or break linux easily. Well then I guess I&#8217;m one of the lucky bastards that gets it done. Since a few days the VPS system I&#8217;m operating keeps hanging itself up.
Now off course it is not the fault of Linux  , but [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve heard a lot of people always say that you can&#8217;t <strong>crash/hang or break linux</strong> easily. Well then I guess I&#8217;m one of the lucky bastards that gets it done. Since a few days the VPS system I&#8217;m operating keeps hanging itself up.</p>
<p>Now off course it is not the fault of Linux <img src='http://www.narnio.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> , but with my very lacking skill. I recently did an <em>apt-get upgrade</em> command on the VPS. To my suprise it started updating with Lenny packages, whilst I could have sworn I have Etch installed. Mystery on its own, but worse yet the server now keeps hanging and breaking.</p>
<p>I figured it was a memory issue at first cause some weird service was installed that was eating it alive. So I de-installed that and it ran fine for a few days. But allas, after 3 days of running the VPS hangs itself up again. When I say hangs-up I mean that I cannot connect using SSH, the mailserver goes down. MySQL and Apache keep running though, as does postfix. So I&#8217;m still guessing it is memory, but I have no idea why my configuration is no longer working after running an <em>apt-get upgrade</em> command. Something is really wrong <img src='http://www.narnio.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> .</p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.narnio.com">Narnio</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@jong-soft.com so we can take legal action immediately.]]></content:encoded>
			<wfw:commentRss>http://www.narnio.com/2009/10/15/mysterious-problems-with-my-vps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Postfix, MySQL setup a blackhole</title>
		<link>http://www.narnio.com/2009/03/23/postfix-mysql-setup-a-blackhole/</link>
		<comments>http://www.narnio.com/2009/03/23/postfix-mysql-setup-a-blackhole/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 19:32:08 +0000</pubDate>
		<dc:creator>Jongerius</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General Rant]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[postfix]]></category>

		<guid isPermaLink="false">http://www.narnio.com/?p=323</guid>
		<description><![CDATA[In previous articles I got into how to setup Postfix and Dovecot using MySQL for management. Well this time round a question rose about creating a blackhole. Which is basically a catch all e-mail address that dumps all mail coming in.
Doing this in the MySql setup created before should be relatively easy. First of modify the [...]]]></description>
			<content:encoded><![CDATA[<p>In previous articles I got into how to setup Postfix and Dovecot using MySQL for management. Well this time round a question rose about creating a blackhole. Which is basically a catch all e-mail address that dumps all mail coming in.</p>
<p>Doing this in the MySql setup created before should be relatively easy. First of modify the &#8216;<em>/etc/aliasses</em>&#8216; file and add &#8216;<em>devnull: /dev/null</em>&#8216;. This will add a virtual debian user called devnull to the system. Keep in mind this alias is not yet active. To activate it run: <strong>newaliases</strong>. This will compile the file and load it into the memory.</p>
<p>Now open either PostfixAdmin or MySql and add an alias from &#8216;@domain.com&#8217; to &#8216;devnull&#8217;. Which will catch all e-mail sent to domain.com and store it into the file belonging to user devnull, which in our case is the blackhole <img src='http://www.narnio.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Please be carefull, as all mail sent to the domain will be dropped unless either an alias or a mailbox is defined for the domain.</p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.narnio.com">Narnio</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@jong-soft.com so we can take legal action immediately.]]></content:encoded>
			<wfw:commentRss>http://www.narnio.com/2009/03/23/postfix-mysql-setup-a-blackhole/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up a mailserver, continued</title>
		<link>http://www.narnio.com/2008/12/15/setting-up-a-mailserver-continued/</link>
		<comments>http://www.narnio.com/2008/12/15/setting-up-a-mailserver-continued/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 19:35:08 +0000</pubDate>
		<dc:creator>Jongerius</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[mailserver]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[spamassassin]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.narnio.com/?p=255</guid>
		<description><![CDATA[In my last article on how to setup a basic mail server in debian using postfix and dovecot, I am now continueing on how to setup some basic spam filters. The reason to split this up, well I was stupid and assumed I wouldn&#8217;t need a spam filter yet. But I forgot that I also [...]]]></description>
			<content:encoded><![CDATA[<p>In my last article on how to <a title="First article on setting up a basic Debian mail server" href="http://www.narnio.com/2008/12/08/debian-setting-up-a-postfix-and-dovecot-mail-server/">setup a basic mail server in debian using postfix and dovecot</a>, I am now continueing on how to setup some basic spam filters. The reason to split this up, well I was stupid and assumed I wouldn&#8217;t need a spam filter yet. But I forgot that I also moved one domain to my new mail server that got 200 spam messages a day.</p>
<p>So now to repair my mistake I am adding the following features to my already existing mail server. To find out how to setup the  mail server itself read my earlier article.</p>
<ul>
<li>Use spamassassin to mark spam in the header</li>
<li>Change the mail delivery to dovecot LDA, this is needed for step 3</li>
<li>Automatically move marked e-mails to the spam folder of the user</li>
</ul>
<p>Sounds easy right. Well it should be <img src='http://www.narnio.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p><span id="more-255"></span></p>
<h2>Install spamassassin and set it up in postfix</h2>
<p>The first step we will take is installing and setting up the spamassassin tool. First lets install it with the default options from Debian by running:</p>
<p><code><br />
apt-get install spamassassin<br />
useradd -g spamd -s /bin/false -m -d /home/spamassassin spamd</code></p>
<p>Next we setup the basics of spamassassin configuration, the file called /etc/spamassassin/local.cf</p>
<p><code>report_safe        0<br />
required_score     2.0</code><br />
<code>use_bayes          1<br />
bayes_auto_learn   1<br />
use_bayes_rules    1</code></p>
<p><code># Some basic configuration<br />
score DCC_CHECK 4.000<br />
score SPF_FAIL 10.000<br />
score SPF_HELO_FAIL 10.000<br />
score RAZOR2_CHECK 2.500<br />
score BAYES_99 4.300<br />
score BAYES_95 3.500<br />
score BAYES_80 3.000</code></p>
<p><code># Headers to be added for all scanned messages<br />
add_header all Status _YESNO_, score=_SCORE_ required=_REQD_ tests=_TESTS_ autolearn=_AUTOLEARN_ version=_VERSION_<br />
add_header all Level _STARS(*)_<br />
add_header all Checker-Version SpamAssassin _VERSION_ (_SUBVERSION_) on _HOSTNAME_</code></p>
<p>So what we&#8217;ve done so far is set spamassassin up to automatically learn from mail it receives and to mark anything with a bayes score over 2 as spam. But we still need to integrate it into postfix to get it to work. Add the following to the postfix configuration (/etc/postfix/master.cf):</p>
<p><code>spamassassin unix -     n       n       -       -       pipe<br />
 user=spamd argv=/usr/bin/spamc -f -e<br />
 /usr/sbin/sendmail -oi -f ${sender} ${recipient}</code></p>
<p>You will also need to change the smtp line in the same file to the following, this will set up spamassassin as a pre delivery filter:</p>
<p><code>smtp      inet  n     -     -     -     -     smtpd -o content_filter=spamassassin</code></p>
<p>This will add the spamassassin service as a unix service through a pipe connection. Sounds complicated but it&#8217;s really easy it basically uses a binary file to comunicate between postfix and spamassassin. Make sure the user <em>spamd</em> exists and create the folder <em>/usr/bin/spamc</em> with full access to the spamd user. Also edit the file spamassassin to the following:</p>
<p><code># /etc/default/spamassassin<br />
# Change to one to enable spamd<br />
ENABLED=1</code></p>
<p><code># SpamAssassin uses a preforking model, so be careful! You need to<br />
# make sure --max-children is not set to anything higher than 5,<br />
# unless you know what you're doing.<br />
SAHOME="/var/lib/spamassassin/"<br />
OPTIONS="--create-prefs --max-children 5 --username spamd --helper-home-dir ${SAHOME} -s ${SAHOME}spamd.log"<br />
PIDFILE="${SAHOME}spamd.pid"<br />
CRON=0</code></p>
<p>Make sure to create the directory <em>/var/lib/spamassassin</em> and give spamd full access right to it, otherwise the service might not run properly. Spamassassin is now setup and will start scanning your e-mail. So if all you are interested in is the header being changed to indicate if a message is spam then you are done. If you also wish yo move it to a different folder then continue reading.</p>
<h2>Settup Dovecot as LDA (Local Delivery Agent)</h2>
<p>Next step is setting up dovecot as the default LDA for postfix. This is needed to let dovecot filter messages into the proper locations. First setup the connection to the between postfix and dovecot by adding the following to the <em>/etc/postfix/master.cf</em>:</p>
<p><code>dovecot   unix  -       n       n       -       -       pipe<br />
 flags=DRhu user=dovecot:dovecot<br />
 argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}</code></p>
<p>Please note that we now need to keep track of the fact that dovecot will be the user that is running this part of the mail server. So every file needed, log or configuration and mailboxes related, need to be owned by dovecot:dovecot. I have had issues with files having the wrong owner so it is important! Before activating the postfix connection lets configure dovecot for LDA by editing the <em>/etc/dovecot/dovecot.conf</em> file. Add the following piece of code in the group auth default &gt;&gt; socket listen:</p>
<p><code>        master {<br />
          path = /var/run/dovecot/auth-master<br />
          user = dovecot<br />
          group= ssl-cert<br />
          mode = 0600<br />
        }<br />
</code></p>
<p>This will setup the authentication service that dovecot will use for delivering the e-mail to the correct user and authenticating users. Also add the following at the bottom of the file to configure the LDA of dovecot:</p>
<p><code>protocol lda {<br />
  mail_plugins = cmusieve<br />
  sieve_global_path = /etc/dovecot/globalsieverc/global.sieve<br />
  log_path = /var/log/dovecot-delivery_log<br />
  postmaster_address = <a href="mailto:noreply@domain.com">noreply@domain.com</a><br />
}</code></p>
<p><code>plugin {<br />
 sieve = /etc/dovecot/globalsieverc/global.sieve<br />
}</code></p>
<p>Again make sure that the user dovecot has full access to both the logfile and the global sieve directory (which you will need to make) <img src='http://www.narnio.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . The plugin group is just for safety. I don&#8217;t know if it is needed but it doesn&#8217;t break anything. Also check the dovecot-mysql.conf that you made earlier to make sure that the uid and gid are those of the dovecot user. You can find this out by running:</p>
<p><code>:&gt; id dovecot</code></p>
<p>If this is all setup in dovecot restart it by running:</p>
<p><code>:&gt;/etc/init.d/dovecot force-reload</code></p>
<p>Now it is time to wrap things up and activate dovecot as the LDA for postfix, edit the file /etc/postfix/main.cf and change the virtual_transport from virtual to dovecot. Last but not least is creating the globe.sieve file.</p>
<p><code>:&gt; vi /etc/dovecot/globalsieverc/global.sieve</code></p>
<p><code>require ["fileinto"];<br />
if anyof (<br />
    header :contains ["X-Spam-Flag"] "Yes"<br />
) {<br />
    fileinto "Spam"; stop;<br />
}</code></p>
<p>Now restart postfix and send yourself a test mail. If everything is setup correctly it should be delivered to your mailbox. If not then first check &#8216;/var/log/mail.info&#8217; to gather some information as to what is going on. If this indicates a delivery was attempted but it failed then check &#8216;/var/log/dovecot-delivery_log&#8217; to find out more.</p>
<p>I hope you have fun using your spam free mail server. If you have any issues let me know, but please include snippets from the log as this will help me help you <img src='http://www.narnio.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.narnio.com">Narnio</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@jong-soft.com so we can take legal action immediately.]]></content:encoded>
			<wfw:commentRss>http://www.narnio.com/2008/12/15/setting-up-a-mailserver-continued/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian Setting up a Postfix and Dovecot mail server</title>
		<link>http://www.narnio.com/2008/12/08/debian-setting-up-a-postfix-and-dovecot-mail-server/</link>
		<comments>http://www.narnio.com/2008/12/08/debian-setting-up-a-postfix-and-dovecot-mail-server/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 18:18:56 +0000</pubDate>
		<dc:creator>Jongerius</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[mailserver]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://www.narnio.com/?p=240</guid>
		<description><![CDATA[Ok over the weekend I spent some time to finally set up my personal mail server on the VPS system I have. I had been planning this for some time, and made several unsuccessful attempts. But this weekend after spending some hard time on it I finally got it working.
My setup is as follows:

Postfix as [...]]]></description>
			<content:encoded><![CDATA[<p>Ok over the weekend I spent some time to finally set up my personal mail server on the VPS system I have. I had been planning this for some time, and made several unsuccessful attempts. But this weekend after spending some hard time on it I finally got it working.</p>
<p>My setup is as follows:</p>
<ul>
<li>Postfix as a SMTP service</li>
<li>Dovecot as the IMAPS service and authentication service</li>
<li>MySQL as a storage location indicating the virtual email boxes and domains</li>
<li>PostfixAdmin as a package to manage the virtual domains and boxes</li>
</ul>
<p><span id="more-240"></span></p>
<h2>Installing the whole thing</h2>
<p>The first thing you might wanna do is install the needed services and applications on your Debian machine. You can install everything using:</p>
<p><code>apt-get install dovecot-common dovecot-imaps postfix postfix-mysql</code></p>
<p>At this point I am asuming you already have MySQL installed and configured. If not then you should do so, but I won&#8217;t include that in this tutorial. The PostfixAdmin needs to be downloaded from <a href="http://sourceforge.net/projects/postfixadmin/">http://sourceforge.net/projects/postfixadmin/</a>. You will need to setup this somewhere on the webserver site, either in an already configured apache directory or by configuring a new one.</p>
<h2>Setting up everything in MySQL</h2>
<p>After everything is installed you will need to prepare everything in MySQL. Connect to your machine and run the following code to generate a database and tables in that database:</p>
<p><code>create database postfix;<br />
</code><code>grant all on postfix.* to postfix identified by 'postfix';<br />
grant all on postfix.* to postfixadmin identified by 'postfixadmin';<br />
set password for postfixadmin = old_password('postfixadmin');</code></p>
<p>This will setup the basic stuff for postfix and postfix admin to work. Next step is setting up the data for postfix. First configure the postfixAdmin plugin by setting some of the settings in &#8216;config.inc.php&#8217;.</p>
<h2>Setup Postfix configuration</h2>
<p>The next step is configuring Postfix to enable it to sent mails, use the MySQL database and login using the Dovecot application. The latter you will setup in a later stage. First open the <em>&#8216;/etc/postfix/main.cf&#8217;</em> file and change the entire content to something like:<br />
<code><br />
queue_directory = /var/spool/postfix<br />
command_directory = /usr/sbin<br />
daemon_directory = /usr/lib/postfix<br />
mail_owner = postfix</code><code>## Host name given by ISP<br />
myhostname = &lt;isp hostname&gt;<br />
mydomain   = &lt;domainname&gt;<br />
unknown_local_recipient_reject_code = 550<br />
debug_peer_level = 1</code></p>
<p><code># Virtual domain administration MySQL<br />
virtual_alias_maps      = mysql:/etc/postfix/mysql_virtual_alias_maps.cf<br />
virtual_gid_maps        = static:104<br />
virtual_mailbox_base    = /usr/postfix/<br />
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf<br />
virtual_mailbox_limit   = 51200000<br />
virtual_mailbox_maps    = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf<br />
virtual_minimum_uid     = 104<br />
virtual_transport       = virtual<br />
virtual_uid_maps        = static:104</code></p>
<p><code># The settings for the SASQL authentication using the autdaemon.<br />
smtpd_recipient_restrictions =<br />
   permit_mynetworks,<br />
   permit_sasl_authenticated,<br />
   reject_unauth_destination,<br />
   reject_unauth_pipelining,<br />
   reject_invalid_hostname,<br />
   reject_rbl_client list.dsbl.org,<br />
   reject_rbl_client sbl-xbl.spamhaus.org<br />
smtpd_sasl_auth_enable           = yes<br />
broken_sasl_auth_clients         = yes</code></p>
<p><code># Setup authentication using Dovecot<br />
smtpd_sasl_type = dovecot<br />
smtpd_sasl_path = private/auth<br />
</code><br />
In the above configuration you need to manually change the domain name to your primary domain and the ISP domain to the name given by your ISP. Another thing you must change is the number <em>104</em> this should be the UID of the <em>postfix</em> user on your system. You can find out what the UID is by running: </p>
<p> <code>id postfix</code></p>
<h2>Setting up the Postfix SQL files</h2>
<p>The last step in the postfix configuration is setting up the SQL files that instruct postfix on how to load the data from the MySQL database. Run the commands as instructed below.</p>
<p><code><strong>:&gt; vi /etc/postfix/mysql_virtual_mailbox_maps.cf</strong></code></p>
<p><code>user     = postfix<br />
password = &lt;password&gt;<br />
hosts    = &lt;ipaddress&gt;<br />
dbname   = postfix<br />
query    = SELECT maildir FROM mailbox WHERE username='%s' AND active = 1</code></p>
<p><code><strong>:&gt; vi /etc/postfix/mysql_virtual_domains_maps.cf</strong></code></p>
<p><code>user     = postfix<br />
password = &lt;password&gt;<br />
hosts    = &lt;ipaddress&gt;<br />
dbname   = postfix<br />
query    = SELECT domain FROM domain WHERE domain='%s'</code></p>
<p><code><strong>:&gt; vi /etc/postfix/mysql_virtual_alias_maps.cf</strong></code></p>
<p><code>user     = postfix<br />
password = &lt;password&gt;<br />
hosts  = &lt;ipaddress&gt;<br />
dbname = postfix<br />
query  = SELECT goto FROM alias WHERE address='%s' AND active = 1</code> </p>
<p>Change the password and the host name to the ones as configured in your MySQL server. If everything went correct your postfix should be up and running by now. Please note that the logon when sending mail does not work yet as dovecot has not yet been configured.</p>
<h2>Configuring Dovecot</h2>
<p>Your last step should be easy. Edit the dovecot.conf file into the following.</p>
<p><code>protocols = imaps<br />
log_path  = /var/log/dovecot_log<br />
log_timestamp = "%Y-%m-%d %H:%M:%S "</code></p>
<p><code>default_mail_env      = maildir:/usr/postfix/%d/%n<br />
mail_privileged_group = mail<br />
first_valid_uid       = 100</code></p>
<p><code>protocol imap {<br />
  imap_client_workarounds = outlook-idle<br />
}</code></p>
<p><code>##<br />
## Authentication processes<br />
##<br />
auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@<br />
auth default {<br />
  mechanisms = plain login<br />
  userdb sql {<br />
    args=/etc/dovecot/dovecot-mysql.conf<br />
  }<br />
  passdb sql {<br />
    args=/etc/dovecot/dovecot-mysql.conf<br />
  }<br />
  socket listen {<br />
    client {<br />
      path = /var/spool/postfix/private/auth<br />
      mode = 0660<br />
      user = postfix<br />
      group = postfix<br />
    }<br />
  }<br />
}<br />
</code></p>
<p>This simple configuration will enable dovecot to use IMAPS (you could also add POP or IMAP). The <em>auth default</em> group defines how to authenticate the user. In our case this is using the MySQL database to locate passwords and the directory of the user. We also define a socket in this group that indicates a location where Dovecot should offer the authentication service for other application, being Postfix in our case.</p>
<p>The last step for the dovecot setup is creating the query to find the data. Run the following command and then paste the code below:</p>
<p><code><strong>:&gt; vi /etc/dovecot/dovecot-mysql.conf</strong></code></p>
<p><code>driver = mysql<br />
connect = host=&lt;host&gt; dbname=postfix user=postfix password=&lt;password&gt;<br />
default_pass_scheme = CRYPT<br />
password_query = SELECT password FROM mailbox WHERE username = '%u'<br />
user_query = SELECT maildir, &lt;uid&gt; AS uid, &lt;uid&gt; AS gid FROM mailbox WHERE username = '%u'</code></p>
<p>You should change the host, password and UID. The UID is the one you previously obtained for postfix.</p>
<p>If everything is done correctly you can start adding domains, mailboxes and aliasses using PostfixAdmin. As well as starting the Postfix and dovecot service. You can do this by running:</p>
<p><code><strong>:&gt; /etc/init.d/dovecot start<br />
:&gt; postfix start</strong></code></p>
<p>And you&#8217;re all done. Congratulations you now have a mail service running on you Debian machine. If you have any difficulties please let me know and please post a snippet of the <em>&#8216;/var/log/mail.info&#8217;</em> to help me understand what&#8217;s going on. Trust me that I&#8217;ve probably seen most of the errors that you can encounter come by.</p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.narnio.com">Narnio</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@jong-soft.com so we can take legal action immediately.]]></content:encoded>
			<wfw:commentRss>http://www.narnio.com/2008/12/08/debian-setting-up-a-postfix-and-dovecot-mail-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Upgrading my VPS to Debian Etch</title>
		<link>http://www.narnio.com/2008/10/12/upgrading-my-vps-to-debian-etch/</link>
		<comments>http://www.narnio.com/2008/10/12/upgrading-my-vps-to-debian-etch/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 15:25:02 +0000</pubDate>
		<dc:creator>Jongerius</dc:creator>
				<category><![CDATA[General Rant]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[awstats]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.narnio.com/?p=216</guid>
		<description><![CDATA[You might have noticed it yesterday, or not  . But my blog and several other websites hosted by me went offline yesterday for a couple of hours. Well this had to do with me upgrading the VPS to Debian Etch.
So far I ran every website on Debian Sarge, and though it&#8217;s stable they choose [...]]]></description>
			<content:encoded><![CDATA[<p>You might have noticed it yesterday, or not <img src='http://www.narnio.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . But my blog and several other websites hosted by me went offline yesterday for a couple of hours. Well this had to do with me upgrading the VPS to Debian Etch.</p>
<p>So far I ran every website on Debian Sarge, and though it&#8217;s stable they choose to no longer developer for it nor support it. So it was time to move to a newer version. Wich I did yesterday. Here&#8217;s some of the steps you should take before upgrading to the next version of Debian.</p>
<ul>
<li>Make a full backup of any website&#8217;s / databases / scripts running (don&#8217;t forget your crontab and logrotate files)</li>
<li>Copy the backup to a directory not affected by the upgrade. In my VPS the provider has one folder which will be left untouched, but also pull the backup to a local system (just in case <img src='http://www.narnio.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</li>
<li>Notify any other users also using your server, don&#8217;t want any suprises to potential paying customers.</li>
</ul>
<p>I was lucky that my hosting provider offers an easy way to upgrade or reinstall a Linux distro on the VPS. Just a couple of mouse clicks and they prepare the VPS for the installation. Please note that this will take up to an hour to complete. Once this base installation is complete you will want to perform the following steps:</p>
<ol>
<li>Un rar the backup of the websites / conf files and scripts (tar xf &lt;<em>tar name</em>&gt;) and move them to the right location.</li>
<li>Setup the proper user account /groups to have access to these files (or your users won&#8217;t be able to upload or change the website&#8217;s any more)</li>
<li>Install apache / PHP and mysql by running the following command:<br />
  apt-get install php5 mysql5-server apache2 mysqllib</li>
<li>Setup the apache conf file to load in your restored conf files (eg: <em>Include /export/conf/apache/*.conf</em>)</li>
<li>Replace the mysql <em>my.cnf</em> with the one you backed up previously</li>
<li>Enable the rewrite and ssl modules of apache (I forgot and got some upset calls <img src='http://www.narnio.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> )</li>
</ol>
<p>From this point on your ready to go. All of the websites should be running without any problems. You do need to configure any other tools you had installed, like <a title="Article on how to setup AWStats" href="http://www.narnio.com/2008/03/26/setting-up-logrotation-with-awstats/">AWStats </a>/ <a title="Article on how to setup a Subversion system" href="http://www.narnio.com/2006/12/10/setting-up-a-dedicated-svn-server/">Subversion </a>or anything else. Though these should not require to much configuration as all of the configuration files where included in your backup. At least if you followed a setup similar to <a href="http://www.narnio.com/2007/08/11/configuring-a-debian-sarge-server-part-1/">my first article on setting up linux</a>.</p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.narnio.com">Narnio</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@jong-soft.com so we can take legal action immediately.]]></content:encoded>
			<wfw:commentRss>http://www.narnio.com/2008/10/12/upgrading-my-vps-to-debian-etch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
