<?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>Ru Servers Reference Blog &#187; Server</title>
	<atom:link href="http://blog.server.ruservers.com/category/server/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.server.ruservers.com</link>
	<description>Server Maintenance Guide</description>
	<lastBuildDate>Tue, 27 Jul 2010 12:14:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>.htaccess Configuring URL Rewriter For Zend</title>
		<link>http://blog.server.ruservers.com/2010/04/htaccess-configuring-url-rewriter-for-zend/</link>
		<comments>http://blog.server.ruservers.com/2010/04/htaccess-configuring-url-rewriter-for-zend/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 09:21:00 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2010/04/htaccess-configuring-url-rewriter-for-zend/</guid>
		<description><![CDATA[&#160; &#160; Rewriting with .htaccess Routing requests Again, these rules direct all requests to index.php, except specified file types: RewriteEngine on RewriteBase / RewriteRule !\.(js&#124;ico&#124;txt&#124;gif&#124;jpg&#124;png&#124;css)$ index.php Handling file and directory exceptions These rules (used immediately prior to the RewriteRule above) exclude real files and directories from the rewriting and lets them pass through unaffected: RewriteCond [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>&#160;</p>
<h5>Rewriting with .htaccess</h5>
<p><b>Routing requests</b></p>
<p>Again, these rules direct all requests to index.php, except specified file types:</p>
<pre>RewriteEngine on
RewriteBase /
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php</pre>
<p><b>Handling file and directory exceptions</b></p>
<p>These rules (used immediately prior to the RewriteRule above) exclude real files and directories from the rewriting and lets them pass through unaffected:</p>
<pre>RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d</pre>
<p>You can also simply allow a specified group of files to pass through unaffected by using this line:</p>
<pre>RewriteRule  ^(foo|bar).*  - [L]</pre>
<p>In this case, files foo.* and bar.* will be accessed normally.</p>
<p>For more information, see Jayson Minard&#8217;s <a href="http://devzone.zend.com/node/view/id/70">Blueprint for PHP Applications: Bootstrapping</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2010/04/htaccess-configuring-url-rewriter-for-zend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>URL Rewriting &#124; redirecting URLs with Apache&#8217;s mod_rewrite</title>
		<link>http://blog.server.ruservers.com/2010/04/url-rewriting-redirecting-urls-with-apaches-mod_rewrite/</link>
		<comments>http://blog.server.ruservers.com/2010/04/url-rewriting-redirecting-urls-with-apaches-mod_rewrite/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 17:36:00 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[apache mud_rewrite]]></category>
		<category><![CDATA[enable module]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2010/04/url-rewriting-redirecting-urls-with-apaches-mod_rewrite/</guid>
		<description><![CDATA[The Apache server’s mod_rewrite module gives you the ability to transparently redirect one URL to another, without the user’s knowledge. This opens up all sorts of possibilities, from simply redirecting old URLs to new addresses, to cleaning up the ‘dirty’ URLs coming from a poor publishing system — giving you URLs that are friendlier to both readers and search engines.]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>source: <a title="http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html" href="http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html">http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html</a></p>
<p>&#160;</p>
<h3>URL Rewriting</h3>
<hr />
<p>by <a href="http://www.yourhtmlsource.com/about/">Ross Shannon</a></p>
<p>The Apache server’s <code>mod_rewrite</code> module gives you the ability to transparently redirect one URL to another, without the user’s knowledge. This opens up all sorts of possibilities, from simply redirecting old URLs to new addresses, to cleaning up the ‘dirty’ URLs coming from a poor publishing system — giving you URLs that are friendlier to both readers and search engines.</p>
<h4>An Introduction to Rewriting</h4>
<p>Readable URLs are nice. A well designed website will have a logical file system layout, with smart folder and file names, and as many implementation details left out as possible. In the most well designed sites, readers can <strong>guess at filenames with a high level of success</strong>.</p>
<p>However, there are some cases when the best possible information design can’t stop your site’s URLs from being nigh-on impossible to use. For instance, you may be using a Content Management System that serves out URLs that look something like</p>
<p><samp><a href="http://www.example.com/viewcatalog.asp?category=hats&amp;prodID=53">http://www.example.com/viewcatalog.asp?category=hats&amp;prodID=53</a></samp></p>
<p>This is a horrible URL, but it and its brethren are becoming increasingly prevalent in these days of dynamically-generated pages. There are a number of problems with an URL of this kind:</p>
<ul>
<li>
<p>It <strong>exposes the underlying technology</strong> of the website (in this case <acronym>ASP</acronym>). This can give potential hackers clues as to what type of data they should send along with the query string to perform a ‘front-door’ attack on the site. Information like this shouldn’t be given away if you can help it.</p>
<p>Even if you’re not overly concerned with the security of your site, <strong>the technology you’re using is at best irrelevant</strong> — and at worst a source of confusion — to your readers, so it should be hidden from them if possible.</p>
<p>Also, if at some point in the future you decide to change the language that your site is based on (to <a href="http://php.net/">» PHP</a>, for instance); all your old URLs will stop working. This is a pretty serious problem, as anyone who has tackled a full-on site rewrite will attest.</p>
</li>
<li><strong>The URL is littered with awkward punctuation</strong>, like the question mark and ampersand. Those &amp; characters, in particular, are problematic because if another webmaster links to this page using that URL, the un-escaped ampersands will mess up their <a href="http://www.yourhtmlsource.com/accessibility/xhtmlexplained.html">XHTML</a> conformance. They will have to laboriously replace all the ampersands with <code>&amp;amp;</code> character entities, which is often forgotten. </li>
<li>Some <strong>search engines won’t index pages which they think are generated dynamically</strong>. They’ll see that question mark in the URL and just turn their asses around. </li>
</ul>
<p>Luckily, using rewriting, we can clean up this URL to something far more manageable. For example, we could map it to</p>
<p><samp><a href="http://www.example.com/catalog/hats/53/">http://www.example.com/catalog/hats/53/</a></samp></p>
<p>Much better. This URL is more logical, readable and memorable, and will be picked up by all search engines. The <i>faux</i>-directories are short and descriptive. Importantly, it looks more <em>permanent</em>.</p>
<p>To use <code>mod_rewrite</code>, you supply it with the link text you want the server to match, and the real URLs that these URLs will be redirected to. The URLs to be matched can be straight file addresses, which will match one file, or they can be <em>regular expressions</em>, which will match many files.</p>
<h4>Basic Rewriting</h4>
<p>Some servers will not have <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">» mod_rewrite</a> enabled by default. As long as the <a href="http://modules.apache.org/">» module</a> is present in the installation, you can enable it simply by starting a .htaccess file with the command</p>
<p><code><strong>RewriteEngine</strong> on</code></p>
<p>Put this .htaccess file in your root so that rewriting is enabled throughout your site. You only need to write this line once per .htaccess file.</p>
<h5>Basic Redirects</h5>
<p>We’ll start off with a straight redirect; as if you had moved a file to a new location and want all links to the old location to be forwarded to the new location. Though you shouldn’t really ever <a href="http://www.w3.org/Provider/Style/URI.html">» move a file</a> once it has been placed on the web; at least when you <em>simply have to</em>, you can do your best to stop any old links from breaking.</p>
<p><code><strong>RewriteEngine</strong> on      <br /><strong>RewriteRule</strong> <strong>^</strong>old\.html<strong>$</strong> new.html </code></p>
<p>Though this is the simplest example possible, it may throw a few people off. The structure of the ‘old’ URL is the only difficult part in this <code>RewriteRule</code>. There are three special characters in there.</p>
<ul>
<li>The caret, <code>^</code>, signifies the <strong>start of an URL</strong>, under the current directory. This directory is whatever directory the .htaccess file is in. You’ll start almost all matches with a caret. </li>
<li>The dollar sign, <code>$</code>, signifies the <strong>end of the string to be matched</strong>. You should add this in to stop your rules matching the first part of longer URLs. </li>
<li>The period or dot before the file extension is a special character in regular expressions, and would mean something special if we didn’t <strong>escape it with the backslash</strong>, which tells Apache to treat it as a normal character. </li>
</ul>
<p>So, this rule will make your server transparently redirect from <samp>old.html</samp> to the <samp>new.html</samp> page. Your reader will have no idea that it happened, and it’s pretty much instantaneous.</p>
<h5>Forcing New Requests</h5>
<p>Sometimes you <em>do</em> want your readers to know a redirect has occurred, and can do this by forcing a new <abbr>HTTP</abbr> request for the new page. This will make the browser load up the new page as if it was the page originally requested, and the location bar will change to show the URL of the new page. All you need to do is turn on the <code>[R]</code> flag, by appending it to the rule:</p>
<p><code><strong>RewriteRule</strong> <strong>^</strong>old\.html<strong>$</strong> new.html <strong>[R]</strong> </code></p>
<h4>Using Regular Expressions</h4>
<p>Now we get on to the <em>really</em> useful stuff. The power of <code>mod_rewrite</code> comes at the expense of complexity. If this is your first encounter with regular expressions, you may find them to be a tough nut to crack, but the options they afford you are well worth the slog. I’ll be providing plenty of examples to guide you through the basics here. </p>
<p>Using regular expressions you can have your rules matching a set of URLs at a time, and mass-redirect them to their actual pages. Take this rule;</p>
<p><code><strong>RewriteRule</strong> <strong>^</strong>products/([0-9][0-9])/<strong>$</strong> /productinfo.php?prodID=$1 </code></p>
<p>This will match any URLs that start with ‘products/’, followed by any two digits, followed by a forward slash. For example, this rule will match an URL like <samp>products/12/</samp> or <samp>products/99/</samp>, and redirect it to the PHP page.</p>
<p>The parts in square brackets are called <em>ranges</em>. In this case we’re allowing anything in the range 0-9, which is any digit. Other ranges would be <code>[A-Z]</code>, which is any uppercase letter; <code>[a-z]</code>, any lowercase letter; and <code>[A-Za-z]</code>, any letter in either case.</p>
<p>We have <strong>encased the regular expression part of the URL in parentheses</strong>, because we want to <strong>store whatever value was found here for later use</strong>. In this case we’re sending this value to a PHP page as an argument. Once we have a value in parentheses we can use it through what’s called a <em>back-reference</em>. <strong>Each of the parts you’ve placed in parentheses are given an index, starting with one</strong>. So, the first back-reference is <code>$1</code>, the third is <code>$3</code> etc.</p>
<p>Thus, once the redirect is done, the page loaded in the readers’ browser will be something like <samp>productinfo.php?prodID=12</samp> or something similar. Of course, we’re keeping this true URL secret from the reader, because it likely ain’t the prettiest thing they’ll see all day.</p>
<h5>Multiple Redirects</h5>
<p>If your site visitor had entered something like <samp>products/12</samp>, the rule above won’t do a redirect, as the slash at the end is missing. To promote good URL writing, we’ll take care of this by doing a direct redirect to the same URL with the slash appended.</p>
<p><code><strong>RewriteRule</strong> <strong>^</strong>products/([0-9][0-9])<strong>$</strong> /products/$1/ <strong>[R]</strong> </code></p>
<p><strong>Multiple redirects in the same .htaccess file can be applied in sequence</strong>, which is what we’re doing here. This rule is added before the one we did above, like so:</p>
<p><code><strong>RewriteRule</strong> <strong>^</strong>products/([0-9][0-9])<strong>$</strong> /products/$1/ <strong>[R]</strong>      <br /><strong>RewriteRule</strong> <strong>^</strong>products/([0-9][0-9])/<strong>$</strong> /productinfo.php?prodID=$1 </code></p>
<p>Thus, if the user types in the URL <samp>products/12</samp>, our first rule kicks in, rewriting the URL to include the trailing slash, and doing a new request for <samp>products/12/</samp> so the user can see that we likes our trailing slashes around here. Then the second rule has something to match, and transparently redirects this URL to <samp>productinfo.php?prodID=12</samp>. <em>Slick.</em></p>
<h5>Match Modifiers</h5>
<p>You can expand your regular expression patterns by adding some modifier characters, which allow you to match URLs with an indefinite number of characters. In our examples above, we were only allowing two numbers after products. This isn’t the most expandable solution, as if the shop ever grew beyond these initial confines of 99 products and created the URL productinfo.php?prodID=100, our rules would cease to match this URL.</p>
<p>So, instead of hard-coding a set number of digits to look for, we’ll work in some room to grow by allowing any number of characters to be entered. The rule below does just that:</p>
<p><code><strong>RewriteRule</strong> <strong>^</strong>products/([0-9]<strong>+</strong>)<strong>$</strong> /products/$1/ <strong>[R]</strong> </code></p>
<p>Note the plus sign (<code>+</code>) that has snuck in there. This modifier changes whatever comes directly before it, by saying ‘<strong>one or more of the preceding character or range</strong>.’ In this case it means that the rule will match any URL that starts with products/ and ends with at least one digit. So this’ll match both <samp>products/1</samp> and <samp>products/1000</samp>.</p>
<p>Other match modifiers that can be used in the same way are the asterisk, <code>*</code>, which means ‘zero or more of the preceding character or range’, and the question mark, <code>?</code>, which means ‘zero or only one of the preceding character or range.’</p>
<h5>Adding Guessable URLs</h5>
<p>Using these simple commands you can set up a slew of ‘shortcut URLs’ that you think visitors will likely try to enter to get to pages they know exist on your site. For example, I’d imagine a lot of visitors try jumping straight into our <a href="http://www.yourhtmlsource.com/stylesheets/">stylesheets</a> section by typing the URL <a href="http://www.yourhtmlsource.com/css/">http://www.yourhtmlsource.com/css/</a>. We can catch these cases, and hopefully alert the reader to the correct address by updating their location bar once the redirect is done with these lines:</p>
<p><code><strong>RewriteRule</strong> <strong>^</strong>css(/)?<strong>$</strong> /stylesheets/ <strong>[R]</strong> </code></p>
<p>The simple regular expression in this rule allows it to match the css URL with or without a trailing slash. The question mark means ‘zero or one of the preceding character or range’ — in other words either yourhtmlsource.com/css or yourhtmlsource.com/css/ will both be taken care of by this one rule.</p>
<p>This approach means less confusing <a href="http://www.yourhtmlsource.com/sitemanagement/custom404error.html">404 errors</a> for your readers, and a site that seems to run a whole lot smoother all ’round.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2010/04/url-rewriting-redirecting-urls-with-apaches-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>5 useful url rewriting examples using .htaccess</title>
		<link>http://blog.server.ruservers.com/2010/04/5-useful-url-rewriting-examples-using-htaccess/</link>
		<comments>http://blog.server.ruservers.com/2010/04/5-useful-url-rewriting-examples-using-htaccess/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 08:44:00 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[mod_rewrite]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2010/06/5-useful-url-rewriting-examples-using-htaccess/</guid>
		<description><![CDATA[&#160; Source: http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html &#160; If you are looking for the examples of URL rewriting then this post might be useful for you. In this post, I’ve given five useful examples of URL rewriting using .htacess. If you don’t know something about url rewriting then please check my older post about url rewriting using .htaccess. Now [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source: <a title="http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html" href="http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html">http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html</a></p>
<p>&#160;</p>
<p>If you are looking for the examples of URL rewriting then this post might be useful for you. In this post, I’ve given five useful examples of URL rewriting using .htacess. If you don’t know something about url rewriting then please check my older post about <a href="http://blog.server.ruservers.com/2010/04/url-rewriting-redirecting-urls-with-apaches-mod_rewrite/">url rewriting using .htaccess</a>.</p>
<p>Now let’s look at the examples</p>
<p><strong>1)Rewriting product.php?id=12 to product-12.html</strong></p>
<p>It is a simple redirection in which .php extension is hidden from the browser’s address bar and dynamic url (containing “?” character) is converted into a static URL.</p>
<p>RewriteEngine on    <br />RewriteRule ^product-([0-9]+)\.html$ product.php?id=$1</p>
<p><strong>2) Rewriting product.php?id=12 to product/ipod-nano/12.html</strong></p>
<p>SEO expert always suggest to display the main keyword in the URL. In the following URL rewriting technique you can display the name of the product in URL.</p>
<p>RewriteEngine on    <br />RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2</p>
<p><strong>3) Redirecting non www URL to www URL</strong></p>
<p>If you type yahoo.com in browser it will be redirected to <a href="http://www.yahoo.com">www.yahoo.com</a>. If you want to do same with your website then put the following code to .htaccess file. What is benefit of this kind of redirection?? Please check the post about <a href="http://roshanbh.com.np/2007/12/301-redirect-in-php-and-htaccess.html">SEO friendly redirect (301) redirect in php and .htaccess.</a></p>
<p>RewriteEngine On    <br />RewriteCond %{HTTP_HOST} ^optimaxwebsolutions\.com$     <br />RewriteRule (.*) <a href="http://www.optimaxwebsolutions.com/$1">http://www.optimaxwebsolutions.com/$1</a> [R=301,L]</p>
<p><strong>4) Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz</strong></p>
<p>Have you checked zorpia.com.If you type <a href="http://zorpia.com/roshanbh233">http://zorpia.com/roshanbh233</a> in browser you can see my profile over there. If you want to do the same kind of redirection i.e <a href="http://yoursite.com/xyz">http://yoursite.com/xyz</a> to <a href="http://yoursite.com/user.php?username=xyz">http://yoursite.com/user.php?username=xyz</a> then you can add the following code to the .htaccess file.</p>
<p>RewriteEngine On    <br />RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1     <br />RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1</p>
<p><strong>5) Redirecting the domain to a new subfolder of inside public_html.</strong></p>
<p>Suppose the you’ve redeveloped your site and all the new development reside inside the “new” folder of inside root folder.Then the new development of the website can be accessed like “test.com/new”. Now moving these files to the root folder can be a hectic process so you can create the following code inside the .htaccess file and place it under the root folder of the website. In result, <a href="http://www.test.com">www.test.com</a> point out to the files inside “new” folder.</p>
<p><strong></strong></p>
<p>RewriteEngine On    <br />RewriteCond %{HTTP_HOST} ^test\.com$ [OR]     <br />RewriteCond %{HTTP_HOST} ^www\.test\.com$     <br />RewriteCond %{REQUEST_URI} !^/new/     <br />RewriteRule (.*) /new/$1 </p>
<p>&#160;</p>
<p>&#160;</p>
<p>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2010/04/5-useful-url-rewriting-examples-using-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hide .php extension with url rewriting using .htaccess</title>
		<link>http://blog.server.ruservers.com/2010/04/hide-php-extension-with-url-rewriting-using-htaccess/</link>
		<comments>http://blog.server.ruservers.com/2010/04/hide-php-extension-with-url-rewriting-using-htaccess/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 08:41:00 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[mod_rewrite]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2010/04/hide-php-extension-with-url-rewriting-using-htaccess/</guid>
		<description><![CDATA[To rewrite the URL you must have the mod_rewrite module must be loaded in apache server. And furthermore, FollowSymLinks options also need to be enabled otherwise you may encounter 500 Internal Sever Error.]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source: <a title="http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html" href="http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html">http://roshanbh.com.np/2008/02/hide-php-url-rewriting-htaccess.html</a></p>
<p>&#160;</p>
<p>Last time I’ve written an article about <a href="http://roshanbh.com.np/2008/01/hiding-php-file-extension.html">hiding php file extension</a> where I’ve showed you how you can use .html or .asp extension of file instead of .php extension. But there was one flaw in that technique you have had to change the file extension explicitly but in this post I’m going to show you how to rewrite the URL instead of renaming the file extension Using this technique you will see product.html in the address bar of the browser but the actual file name remains product.php and you don’t need to rename the file extension. Furthermore you can rewrite the URL like product.php?id=5 to product-5.html.</p>
<h6>what is the benefits of rewriting URL?</h6>
<p>When a search engine visits the dynamic url like product.php?id=5 it does not give much importance to that URL as search engine sees “?” sign treat it as a url which keeps on changing. so we’re converting the dynamic URL like the product.php?id=5 to static url format like product-5.html. We’ll rewrite the url in such a way that in browser’s address bar it will display as a product-5.html but it actually calls the file product.php?id=5. So that why these kind of URL also named as SEO friendly URL.</p>
<h6>what is required for URL rewriting ??</h6>
<p>To rewrite the URL you must have the <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html">mod_rewrite</a> module must be loaded in apache server. And furthermore, FollowSymLinks options also need to be enabled otherwise you may encounter 500 Internal Sever Error. If you don’t know much about mod_rewrite module then please check this post to know <a href="http://roshanbh.com.np/2008/04/check-enable-mod_rewrite-apache.html">how to check and enable mod_rewrite module in apache?</a></p>
<h6>Examples of url rewriting for seo friendly URL</h6>
<p>For rewriting the URL, you should create a .htaccess file in the root folder of your web directory. And have to put the following codes as your requirement.</p>
<p>Options +FollowSymlinks   <br />RewriteEngine on    <br />RewriteRule ^(.*)\.htm$ $1.php [nc]</p>
<p>The following example will rewrite the test.php to test.html i.e when a URL like <a href="http://localhost/test.htm">http://localhost/test.htm</a> is called in address bar it calls the file test.php. As you can see the regular expression in first part of the RewriteRule command and $1 represents the first regular expression of the part of the RewriteRule and [nc] means not case sensitive.</p>
<p>Options +FollowSymlinks   <br />RewriteEngine on    <br />RewriteRule ^product-([0-9]+)\.html$ products.php?id=$1</p>
<p>The following example will rewrite the product.php?id=5 to porduct-5.html i.e when a URL like <a href="http://localhost/product-5.html">http://localhost/product-5.html</a> calls product.php?id=5 automatically.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2010/04/hide-php-extension-with-url-rewriting-using-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Host Access Control (block IP access) 1</title>
		<link>http://blog.server.ruservers.com/2009/02/host-access-control-block-ip-access-1/</link>
		<comments>http://blog.server.ruservers.com/2009/02/host-access-control-block-ip-access-1/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 19:24:42 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[Cpanel]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/02/host-access-control-block-ip-access-1/</guid>
		<description><![CDATA[twist ((shell_command) Replace the current process by an instance of the specified shell command, after performing the % expansions described in the hosts_access(5) manual page.) deny (Denys Service/Access) banners ((/some/directory) Look for a file in &#34;/some/directory&#34; with the same name as the daemon process (for example in.telnetd for the telnet service), and copy its contents [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>twist ((shell_command) Replace the current process by an instance of the specified      <br />shell command, after performing the % expansions described in the       <br />hosts_access(5) manual page.)</li>
<li>deny (Denys Service/Access)</li>
<li>banners ((/some/directory) Look for a file in &quot;/some/directory&quot; with the same      <br />name as the daemon process (for example in.telnetd for the telnet       <br />service), and copy its contents to the client. Newline characters are replaced       <br />by carriage-return newline, and % sequences are expanded (see the       <br />hosts_access(5) manual page).)</li>
<li>nice ([number] Change the nice value of the process (default 10). Specify a positive      <br />value to spend more CPU resources on other processes.)</li>
<li>rfc931 ([timeout_in_seconds] Look up the client user name with the RFC 931 (TAP, IDENT,      <br />RFC 1413) protocol. This option is silently ignored in case of services based       <br />on transports other than TCP. It requires that the client system runs an RFC       <br />931 (IDENT, etc.) -compliant daemon, and may cause noticeable delays with       <br />connections from non-UNIX clients. The timeout period is optional. If no       <br />timeout is specified a compile-time defined default value is taken.)</li>
<li>setenv ((name) (value) Place a (name, value) pair into the process environment. The      <br />value is subjected to % expansions and may contain whitespace (but       <br />leading and trailing blanks are stripped off).)</li>
<li>user ((user[.group]) Ammume the privleges of the user and group)</li>
<li>allow (Permits Service/Access)</li>
<li>umask ((umask) Like the umask command that is built into the shell. Should be octal)</li>
<li>keepalive (Causes the server to periodically send a message to the client. The connection      <br />is considered broken when the client does not respond. The keepalive option can       <br />be useful when users turn off their machine while it is still connected to a       <br />server. The keepalive option is not useful for datagram (UDP) services.)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/02/host-access-control-block-ip-access-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Install the Apache Web Server</title>
		<link>http://blog.server.ruservers.com/2009/01/how-to-install-the-apache-web-server/</link>
		<comments>http://blog.server.ruservers.com/2009/01/how-to-install-the-apache-web-server/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 18:11:59 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/how-to-install-the-apache-web-server/</guid>
		<description><![CDATA[&#160; Source: http://webdesign.about.com/cs/apache/a/aainstallapache.htm &#160; Before You Begin Apache is one of the most popular Web servers on the Web right now, and part of its charm is that it&#8217;s free. It also has a lot of features that make it very extensible and useful for many different types of Web sites. It is a server [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source: <a title="http://webdesign.about.com/cs/apache/a/aainstallapache.htm" href="http://webdesign.about.com/cs/apache/a/aainstallapache.htm" target="_blank">http://webdesign.about.com/cs/apache/a/aainstallapache.htm</a></p>
<p>&#160;</p>
<h5>Before You Begin</h5>
<p>Apache is one of the most popular Web servers on the Web right now, and part of its charm is that it&#8217;s free. It also has a lot of features that make it very extensible and useful for many different types of Web sites. It is a server that is used for personal Web pages up to enterprise level sites. </p>
<p>This article will discuss how to install Apache on a Linux system. Before we start you should be at least comfortable working in Linux &#8211; changing directories, using tar and gunzip, and compiling with make (I&#8217;ll discuss where to get binaries if you don&#8217;t want to mess with compiling your own). You should also have access to the root account on the server machine. </p>
<h5>Download Apache</h5>
<p>I recommend downloading the latest stable release. At the time of this writing, that was Apache 2.0. The best place to get Apache is from the <a href="http://httpd.apache.org/download.cgi">Apache HTTP Server download site</a>. Download the sources appropriate to your system. <a href="http://mirrors.midco.net/pub/apache.org/httpd/binaries/">Binary releases</a> are available as well. </p>
<h5>Extract the Files</h5>
<p>Once you&#8217;ve downloaded the files you need to uncompress them and untarring:   <br />&#160; gunzip -d httpd-2_0_NN.tar.gz    <br />&#160; tar xvf httpd-2_0_NN.tar    <br />This creates a new directory under the current directory with the source files. </p>
<h5>Configuring</h5>
<p>Once you&#8217;ve got the files, you need to tell your machine where to find everything by configuring the source files. The easiest way is to accept all the defaults and just type:   <br />&#160; ./configure </p>
<p>Of course, most people don&#8217;t want to accept just the default choices. The most important option is the prefix= option. This specifies the directory where the Apache files will be installed. You can also set specific environment variables and modules. Some of the <a href="http://httpd.apache.org/docs-2.0/mod/">modules</a> I like to have installed are: </p>
<ul>
<li>mod_alias &#8211; to map different parts of the URL tree </li>
<li>mod_include &#8211; to parse Server Side Includes </li>
<li>mod_mime &#8211; to associate file extensions with its MIME-type </li>
<li>mod_rewrite &#8211; to rewrite URLs on the fly </li>
<li>mod_speling (sic) &#8211; to help your readers who might misspell URLs </li>
<li>mod_ssl &#8211; to allow for strong cryptography using SSL </li>
<li>mod_userdir &#8211; to allow system users to have their own Web page directories</li>
</ul>
<p>Please keep in mind that these aren&#8217;t all the modules I might install on a given system. Read the <a href="http://httpd.apache.org/docs-2.0/mod/">details about the modules</a> to determine which ones you need. </p>
<h5>Build</h5>
<p>As with any source installation, you&#8217;ll then need to build the installation:   <br />&#160; make    <br />&#160; make install </p>
<h5>Customize</h5>
<p>Assuming that there were no problems, you are ready to customize your Apache configuration. This really just amounts to editing the httpd.conf file. This file is located in the PREFIX/conf directory. I generally edit it with <a href="http://webdesign.about.com/cs/vithetexteditor/index.htm">vi</a>:    <br />&#160; vi PREFIX/conf/httpd.conf    <br />Note: you&#8217;ll need to be root to edit this file. </p>
<p>Follow the instructions in this file to edit your configuration the way you want it. More help is available on the <a href="http://httpd.apache.org/docs-2.0/mod/quickreference.html">Apache Web site</a>. </p>
<h5>Test Your Server</h5>
<p>Open a Web browser on the same machine and type http://localhost/ in the address box. You should see a page similar to the one in the partial screen shot above. Specifically, it will say in big letters &quot;Seeing this instead of the website you expected?&quot; This is good news, as it means your server installed correctly. </p>
<h5>Start Editing/Uploading Pages</h5>
<p>Once your server is up and running you can start posting pages. Have fun building your Web site. </p>
<h6>Web Design Path</h6>
<p><a href="http://webdesign.about.com/library/bl_proprogrammers.htm">Professional Web Developers</a></p>
<h6>Suggested Reading</h6>
<p><a href="http://webdesign.about.com/library/weekly/aa092099.htm">How are You Being Served?</a>    <br /><a href="http://webdesign.about.com/library/weekly/aa092501a.htm">Time to Switch from IIS</a>    <br /><a href="http://webdesign.about.com/library/weekly/aa051301a.htm">Become a Hosting Provider</a></p>
<h6>More Apache Help</h6>
<p><a href="http://webdesign.about.com/cs/apache/a/aainstapachewin.htm">How to Install Apache on Windows</a>&#160; <br /><a href="http://webdesign.about.com/cs/apache/">More Apache Resources</a>    <br /><a href="http://webdesign.about.com/cs/webservers/">Other Web Servers</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/how-to-install-the-apache-web-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache HTTP Server Configuration (Red Hat Linux)</title>
		<link>http://blog.server.ruservers.com/2009/01/apache-http-server-configuration-red-hat-linux/</link>
		<comments>http://blog.server.ruservers.com/2009/01/apache-http-server-configuration-red-hat-linux/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 18:01:33 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/apache-http-server-configuration-red-hat-linux/</guid>
		<description><![CDATA[&#160; Source: http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-httpdconfig.html&#160; &#160; In Red Hat Linux 8.0, the Apache HTTP Server was updated to version 2.0, which uses different configuration options. Also starting with Red Hat Linux 8.0, the RPM package was renamed httpd. If you want to migrate an existing configuration file by hand, refer to the migration guide at /usr/share/doc/httpd-&#60;ver&#62;/migration.html or [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source: <a title="http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-httpdconfig.html" href="http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-httpdconfig.html" target="_blank">http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-httpdconfig.html</a>&#160;</p>
<p>&#160;</p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/docs-header.gif" target="_blank" rel="lightbox[103]"><img title="docs_header" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="60" alt="docs_header" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/docs-header-thumb.gif" width="150" border="0" /></a> </p>
<p>In Red Hat Linux 8.0, the Apache HTTP Server was updated to version 2.0, which uses different configuration options. Also starting with Red Hat Linux 8.0, the RPM package was renamed <tt>httpd</tt>. If you want to migrate an existing configuration file by hand, refer to the migration guide at <tt>/usr/share/doc/httpd-<tt><i>&lt;ver&gt;</i></tt>/migration.html</tt> or the <i>Red Hat Linux Reference Guide</i> for details. </p>
<p>If you configured the Apache HTTP Server with the <b>HTTP Configuration Tool</b> in previous versions of Red Hat Linux and then performed an upgrade, you can use the application to migrate the configuration file to the new format for version 2.0. Start the <b>HTTP Configuration Tool</b>, make any changes to the configuration, and save it. The configuration file saved will be compatible with version 2.0. </p>
<p>The <b>HTTP Configuration Tool</b> allows you to configure the <tt>/etc/httpd/conf/httpd.conf</tt> configuration file for the Apache HTTP Server. It does not use the old <tt>srm.conf</tt> or <tt>access.conf</tt> configuration files; leave them empty. Through the graphical interface, you can configure directives such as virtual hosts, logging attributes, and maximum number of connections. </p>
<p>Only modules that are shipped with Red Hat Linux can be configured with <b>HTTP Configuration Tool</b>. If additional modules are installed, they can not be configured using this tool. </p>
<p>The <tt>httpd</tt> and <tt>redhat-config-httpd</tt> RPM packages need to be installed to use the <b>HTTP Configuration Tool</b>. It also requires the X Window System and root access. To start the application, go to the <b>Main Menu Button</b> =&gt; <b>System Settings</b> =&gt; <b>Server Settings</b> =&gt; <b>HTTP Server</b> or type the command <tt>redhat-config-httpd</tt> at a shell prompt (for example, in an XTerm or GNOME Terminal).</p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/caution.png" target="_blank" rel="lightbox[103]"><img title="caution" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="34" alt="caution" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/caution-thumb.png" width="34" border="0" /></a>     <br /><b>Caution</b></p>
<p>Do not edit the <tt>/etc/httpd/conf/httpd.conf</tt> configuration file by hand if you wish to use this tool. The <b>HTTP Configuration Tool</b> generates this file after you save your changes and exit the program. If you want to add additional modules or configuration options that are not available in <b>HTTP Configuration Tool</b>, you cannot use this tool. </p>
<p>The general steps for configuring the Apache HTTP Server using the <b>HTTP Configuration Tool</b> are as following: </p>
<ol>
<li>
<p>Configure the basic settings under the <b>Main</b> tab.</p>
</li>
<li>
<p>Click on the <b>Virtual Hosts</b> tab and configure the default settings.</p>
</li>
<li>
<p>Under the <b>Virtual Hosts</b> tab, configure the Default Virtual Host.</p>
</li>
<li>
<p>If you want to serve more than one URL or virtual host, add the additional virtual hosts.</p>
</li>
<li>
<p>Configure the server settings under the <b>Server</b> tab.</p>
</li>
<li>
<p>Configure the connections settings under the <b>Performance Tuning</b> tab.</p>
</li>
<li>
<p>Copy all necessary files to the <tt>DocumentRoot</tt> and <tt>cgi-bin</tt> directories.</p>
</li>
<li>
<p>Exit the application and select to save your settings.</p>
</li>
</ol>
<h3><a name="S1-HTTPD-BASIC-SETTINGS"></a>Basic Settings</h3>
<p>Use the <b>Main</b> tab to configure the basic server settings. </p>
<p><a name="HTTPD-MAIN"></a></p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpdmain.png" target="_blank" rel="lightbox[103]"><img title="httpd-main" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="328" alt="httpd-main" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpdmain-thumb.png" width="409" border="0" /></a> </p>
<p><b>Figure Basic Settings</b></p>
<p>Enter a fully qualified domain name that you have the right to use in the <b>Server Name</b> text area. This option corresponds to the <a href="http://httpd.apache.org/docs-2.0/mod/core.html#servername"><tt>ServerName</tt></a> directive in <tt>httpd.conf</tt>. The <tt>ServerName</tt> directive sets the hostname of the Web server. It is used when creating redirection URLs. If you do not define a server name, the Web server attempts to resolve it from the IP address of the system. The server name does not have to be the domain name resolved from the IP address of the server. For example, you might want to set the server name to www.example.com when your server&#8217;s real DNS name is actually foo.example.com. </p>
<p>Enter the email address of the person who maintains the Web server in the <b>Webmaster email address</b> text area. This option corresponds to the <a href="http://httpd.apache.org/docs-2.0/mod/core.html#serveradmin"><tt>ServerAdmin</tt></a> directive in <tt>httpd.conf</tt>. If you configure the server&#8217;s error pages to contain an email address, this email address will be used so that users can report a problem by sending email to the server&#8217;s administrator. The default value is root@localhost. </p>
<p>Use the <b>Available Addresses</b> area to define the ports on which the server will accept incoming requests. This option corresponds to the <a href="http://httpd.apache.org/docs-2.0/mod/mpm_common.html#listen"><tt>Listen</tt></a> directive in <tt>httpd.conf</tt>. By default, Red Hat configures the Apache HTTP Server to listen to port 80 for non-secure Web communications. </p>
<p>Click the <b>Add</b> button to define additional ports on which to accept requests. A window as shown in <a href="http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-httpdconfig.html#HTTPD-LISTEN">Figure 19-2</a> will appear. Either choose the <b>Listen to all addresses</b> option to listen to all IP addresses on the defined port or specify a particular IP address over which the server will accept connections in the <b>Address</b> field. Only specify one IP address per port number. If you want to specify more than one IP address with the same port number, create an entry for each IP address. If at all possible, use an IP address instead of a domain name to prevent a DNS lookup failure. Refer to <a href="http://httpd.apache.org/docs-2.0/dns-caveats.html">http://httpd.apache.org/docs-2.0/dns-caveats.html</a> for more information about <i>Issues Regarding DNS and Apache</i>. </p>
<p>Entering an asterisk (*) in the <b>Address</b> field is the same as choosing <b>Listen to all addresses</b>. Clicking the <b>Edit</b> button in the <b>Available Addresses</b> frame shows the same window as the <b>Add</b> button except with the fields populated for the selected entry. To delete an entry, select it and click the <b>Delete</b> button. </p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/tip.png" target="_blank" rel="lightbox[103]"><img title="tip" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="34" alt="tip" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/tip-thumb.png" width="34" border="0" /></a>     <br /><b>Tip</b></p>
<p>If you set the server to listen to a port under 1024, you must be root to start it. For port 1024 and above, <tt>httpd</tt> can be started as a regular user. </p>
<p><a name="HTTPD-LISTEN"></a></p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpdlisten.png" target="_blank" rel="lightbox[103]"><img title="httpd-listen" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="144" alt="httpd-listen" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpdlisten-thumb.png" width="302" border="0" /></a> </p>
<p><b></b></p>
<h3>Default Settings</h3>
<p>After defining the <b>Server Name</b>, <b>Webmaster email address</b>, and <b>Available Addresses</b>, click the <b>Virtual Hosts</b> tab and click the <b>Edit Default Settings</b> button. The window shown in <a href="http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/s1-httpd-default-settings.html#HTTPD-SITE-CONFIG-SCREEN">Figure 19-3</a> will appear. Configure the default settings for your Web server in this window. If you add a virtual host, the settings you configure for the virtual host take precedence for that virtual host. For a directive not defined within the virtual host settings, the default value is used. </p>
<h4><a name="S2-HTTPD-SITE-CONFIG"></a>Site Configuration</h4>
<p>The default values for the <b>Directory Page Search List</b> and <b>Error Pages</b> will work for most servers. If you are unsure of these settings, do not modify them. </p>
<p><a name="HTTPD-SITE-CONFIG-SCREEN"></a></p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpdsiteconfig.png" target="_blank" rel="lightbox[103]"><img title="httpd-siteconfig" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="420" alt="httpd-siteconfig" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpdsiteconfig-thumb.png" width="623" border="0" /></a> </p>
<p><b>Figure Site Configuration</b></p>
<p>The entries listed in the <b>Directory Page Search List</b> define the <a href="http://httpd.apache.org/docs-2.0/mod/mod_dir.html#directoryindex"><tt>DirectoryIndex</tt></a> directive. The <tt>DirectoryIndex</tt> is the default page served by the server when a user requests an index of a directory by specifying a forward slash (/) at the end of the directory name. </p>
<p>For example, when a user requests the page http://<tt><i>www.example.com</i></tt>/<tt><i>this_directory</i></tt>/, they are going to get either the <tt>DirectoryIndex</tt> page if it exists, or a server-generated directory list. The server will try to find one of the files listed in the <tt>DirectoryIndex</tt> directive and will return the first one it finds. If it does not find any of these files and if <tt>Options Indexes</tt> is set for that directory, the server will generate and return a list, in HTML format, of the subdirectories and files in the directory. </p>
<p>Use the <b>Error Code</b> section to configure Apache HTTP Server to redirect the client to a local or external URL in the event of a problem or error. This option corresponds to the <a href="http://httpd.apache.org/docs-2.0/mod/core.html#errordocument"><tt>ErrorDocument</tt></a> directive. If a problem or error occurs when a client tries to connect to the Apache HTTP Server, the default action is to display the short error message shown in the <b>Error Code</b> column. To override this default configuration, select the error code and click the <b>Edit</b> button. Choose <b>Default</b> to display the default short error message. Choose <b>URL</b> to redirect the client to an external URL and enter a complete URL including the http:// in the <b>Location</b> field. Choose <b>File</b> to redirect the client to an internal URL and enter a file location under the document root for the Web server. The location must begin the a slash (/) and be relative to the Document Root. </p>
<p>For example, to redirect a 404 Not Found error code to a webpage that you created in a file called <tt>404.html</tt>, copy <tt>404.html</tt> to <tt><tt><i>DocumentRoot</i></tt>/../error/404.html</tt>. In this case, <tt><i>DocumentRoot</i></tt> is the Document Root directory that you have defined (the default is <tt>/var/www/html/</tt>). If the Document Root is left as the default location, the file should be copied to <tt>/var/www/error/404.html</tt>. Then, choose <b>File</b> as the Behavior for <b>404 &#8211; Not Found</b> error code and enter <tt>/error/404.html</tt> as the <b>Location</b>. </p>
<p>From the <b>Default Error Page Footer</b> menu, you can choose one of the following options: </p>
<ul>
<li>
<p><b>Show footer with email address</b> — Display the default footer at the bottom of all error pages along with the email address of the website maintainer specified by the <a href="http://httpd.apache.org/docs-2.0/mod/core.html#serveradmin"><tt>ServerAdmin</tt></a> directive. Refer to <a href="http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/s1-httpd-virtualhosts-settings.html#S3-HTTPD-VIRTUALHOSTS-ADD-GENERAL">Section 19.3.1.1 <i>General Options</i></a> for information about configuring the <tt>ServerAdmin</tt> directive.</p>
</li>
<li>
<p><b>Show footer</b> — Display just the default footer at the bottom of error pages.</p>
</li>
<li>
<p><b>No footer</b> — Do not display a footer at the bottom of error pages.</p>
</li>
</ul>
<h4><a name="S2-HTTPD-LOGGING"></a>Logging</h4>
<p>By default, the server writes the transfer log to the file <tt>/var/log/httpd/access_log</tt> and the error log to the <tt>/var/log/httpd/error_log</tt> file. </p>
<p>The transfer log contains a list of all attempts to access the Web server. It records the IP address of the client that is attempting to connect, the date and time of the attempt, and the file on the Web server that it is trying to retrieve. Enter the name of the path and file in which to store this information. If the path and filename does not start with a slash (/), the path is relative to the server root directory as configured. This option corresponds to the <a href="http://httpd.apache.org/docs-2.0/mod/mod_log_config.html#transferlog"><tt>TransferLog</tt></a> directive. </p>
<p><a name="HTTPD-LOGGING-SCREEN"></a></p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpdlogging.png" target="_blank" rel="lightbox[103]"><img title="httpd-logging" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="420" alt="httpd-logging" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpdlogging-thumb.png" width="623" border="0" /></a> </p>
<p><b>Figure Logging</b></p>
<p>You can configure a custom log format by checking <b>Use custom logging facilities</b> and entering a custom log string in the <b>Custom Log String</b> field. This configures the <a href="http://httpd.apache.org/docs-2.0/mod/mod_log_config.html#logformat"><tt>LogFormat</tt></a> directive. Refer to <a href="http://httpd.apache.org/docs-2.0/mod/mod_log_config.html#formats">http://httpd.apache.org/docs-2.0/mod/mod_log_config.html#formats</a> for details on the format of this directive. </p>
<p>The error log contains a list of any server errors that occur. Enter the name of the path and file in which to store this information. If the path and filename does not start with a slash (/), the path is relative to the server root directory as configured. This option corresponds to the <a href="http://httpd.apache.org/docs-2.0/mod/core.html#errorlog"><tt>ErrorLog</tt></a> directive. </p>
<p>Use the <b>Log Level</b> menu to set how verbose the error messages in the error logs will be. It can be set (from least verbose to most verbose) to emerg, alert, crit, error, warn, notice, info or debug. This option corresponds to the <a href="http://httpd.apache.org/docs-2.0/mod/core.html#loglevel"><tt>LogLevel</tt></a> directive. </p>
<p>The value chosen with the <b>Reverse DNS Lookup</b> menu defines the <a href="http://httpd.apache.org/docs-2.0/mod/core.html#hostnamelookups"><tt>HostnameLookups</tt></a> directive. Choosing <b>No Reverse Lookup</b> sets the value to off. Choosing <b>Reverse Lookup</b> sets the value to on. Choosing <b>Double Reverse Lookup</b> sets the value to double. </p>
<p>If you choose <b>Reverse Lookup</b>, your server will automatically resolve the IP address for each connection which requests a document from your Web server. Resolving the IP address means that your server will make one or more connections to the DNS in order to find out the hostname that corresponds to a particular IP address. </p>
<p>If you choose <b>Double Reverse Lookup</b>, your server will perform a double-reverse DNS. In other words, after a reverse lookup is performed, a forward lookup is performed on the result. At least one of the IP addresses in the forward lookup must match the address from the first reverse lookup. </p>
<p>Generally, you should leave this option set to <b>No Reverse Lookup</b>, because the DNS requests add a load to your server and may slow it down. If your server is busy, the effects of trying to perform these reverse lookups or double reverse lookups may be quite noticeable. </p>
<p>Reverse lookups and double reverse lookups are also an issue for the Internet as a whole. All of the individual connections made to look up each hostname add up. Therefore, for your own Web server&#8217;s benefit, as well as for the Internet&#8217;s benefit, you should leave this option set to <b>No Reverse Lookup</b>. </p>
<h4>Environment Variables</h4>
<p>Sometimes it is necessary to modify environment variables for CGI scripts or server-side include (SSI) pages. The Apache HTTP Server can use the <tt>mod_env</tt> module to configure the environment variables which are passed to CGI scripts and SSI pages. Use the <b>Environment Variables</b> page to configure the directives for this module. </p>
<p><a name="HTTPD-ENVIRONMENT-VARIABLES-SCREEN"></a></p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpdenvironment.png" target="_blank" rel="lightbox[103]"><img title="httpd-environment" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="420" alt="httpd-environment" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpdenvironment-thumb.png" width="623" border="0" /></a> </p>
<p><b>Figure Environment Variables</b></p>
<p>Use the <b>Set for CGI Scripts</b> section to set an environment variable that is passed to CGI scripts and SSI pages. For example, to set the environment variable <tt>MAXNUM</tt> to <tt>50</tt>, click the <b>Add</b> button inside the <b>Set for CGI Script</b> section as shown in <a href="http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/s1-httpd-default-settings.html#HTTPD-ENVIRONMENT-VARIABLES-SCREEN">Figure 19-5</a> and type <tt><b>MAXNUM</b></tt> in the <b>Environment Variable</b> text field and <tt><b>50</b></tt> in the <b>Value to set</b> text field. Click <b>OK</b> to add it to the list. The <b>Set for CGI Scripts</b> section configures the <a href="http://httpd.apache.org/docs-2.0/mod/mod_env.html#setenv"><tt>SetEnv</tt></a> directive. </p>
<p>Use the <b>Pass to CGI Scripts</b> section to pass the value of an environment variable when the server was first started to CGI scripts. To see this environment variable, type the command <tt>env</tt> at a shell prompt. Click the <b>Add</b> button inside the <b>Pass to CGI Scripts</b> section and enter the name of the environment variable in the resulting dialog box. Click <b>OK</b> to add it to the list. The <b>Pass to CGI Scripts</b> section configures the <a href="http://httpd.apache.org/docs-2.0/mod/mod_env.html#passenv"><tt>PassEnv</tt> </a>directive. </p>
<p>If you want to remove an environment variable so that the value is not passed to CGI scripts and SSI pages, use the <b>Unset for CGI Scripts</b> section. Click <b>Add</b> in the <b>Unset for CGI Scripts</b> section, and enter the name of the environment variable to unset. Click <b>OK</b> to add it to the list. This corresponds to the <a href="http://httpd.apache.org/docs-2.0/mod/mod_env.html#unsetenv"><tt>UnsetEnv</tt></a> directive. </p>
<p>To edit any of these environment values, select it from the list and click the corresponding <b>Edit</b> button. To delete any entry from the list, select it and click the cooresponding <b>Delete</b> button. </p>
<p>To learn more about environment variables in Apache HTTP Server, refer to the following: </p>
<pre><a href="http://httpd.apache.org/docs-2.0/env.html">http://httpd.apache.org/docs-2.0/env.html</a></pre>
<h4><a name="S2-HTTPD-DIRECTORIES"></a>Directories</h4>
<p>Use the <b>Directories</b> page to configure options for specific directories. This corresponds to the <a href="http://httpd.apache.org/docs-2.0/mod/core.html#directory"><tt>&lt;Directory&gt;</tt></a> directive. </p>
<p><a name="HTTPD-DIRECTORIES-SCREEN"></a></p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpddirectories.png" target="_blank" rel="lightbox[103]"><img title="httpd-directories" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="420" alt="httpd-directories" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpddirectories-thumb.png" width="623" border="0" /></a> </p>
<p><b>Figure Directories</b></p>
<p>Click the <b>Edit</b> button in the top right-hand corner to configure the <b>Default Directory Options</b> for all directories that are not specified in the <b>Directory</b> list below it. The options that you choose are listed as the <a href="http://httpd.apache.org/docs-2.0/mod/core.html#options">Options </a>directive within the <a href="http://httpd.apache.org/docs-2.0/mod/core.html#directory"><tt>&lt;Directory&gt;</tt></a> directive. You can configure the following options: </p>
<ul>
<li>
<p><b>ExecCGI</b> — Allow execution of CGI scripts. CGI scripts are not executed if this option is not chosen.</p>
</li>
<li>
<p><b>FollowSymLinks</b> — Allow symbolic links to be followed.</p>
</li>
<li>
<p><b>Includes</b> — Allow server-side includes.</p>
</li>
<li>
<p><b>IncludesNOEXEC</b> — Allow server-side includes, but disable the <tt>#exec</tt> and <tt>#include</tt> commands in CGI scripts.</p>
</li>
<li>
<p><b>Indexes</b> — Display a formatted list of the directory&#8217;s contents, if no <tt>DirectoryIndex</tt> (such as <tt>index.html</tt>) exists in the requested directory.</p>
</li>
<li>
<p><b>Multiview</b> — Support content-negotiated multiviews; this option is disabled by default.</p>
</li>
<li>
<p><b>SymLinksIfOwnerMatch</b> — Only follow symbolic links if the target file or directory has the same owner as the link.</p>
</li>
</ul>
<p>To specify options for specific directories, click the <b>Add</b> button beside the <b>Directory</b> list box. The window shown in <a href="http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/s1-httpd-default-settings.html#HTTPD-DIRECTORIES-ADD">Figure 19-7</a> appears. Enter the directory to configure in the <b>Directory</b> text field at the bottom of the window. Select the options in the right-hand list, and configure the <a href="http://httpd.apache.org/docs-2.0/mod/mod_access.html#order"><tt>Order</tt></a> directive with the left-hand side options. The <tt>Order</tt> directive controls the order in which allow and deny directives are evaluated. In the <b>Allow hosts from</b> and <b>Deny hosts from</b> text field, you can specify one of the following: </p>
<ul>
<li>
<p>Allow all hosts — Type <tt><b>all</b></tt> to allow access to all hosts.</p>
</li>
<li>
<p>Partial domain name — Allow all hosts whose names match or end with the specified string.</p>
</li>
<li>
<p>Full IP address — Allow access to a specific IP address.</p>
</li>
<li>
<p>A subnet — Such as <tt><b>192.168.1.0/255.255.255.0</b></tt></p>
</li>
<li>
<p>A network CIDR specification — such as <tt><b>10.3.0.0/16</b></tt></p>
</li>
</ul>
<p><a name="HTTPD-DIRECTORIES-ADD"></a></p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpddirectoriesadd.png" target="_blank" rel="lightbox[103]"><img title="httpd-directories-add" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="384" alt="httpd-directories-add" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/httpddirectoriesadd-thumb.png" width="606" border="0" /></a> </p>
<p><b>Figure Directory Settings</b></p>
<p>If you check the <b>Let .htaccess files override directory options</b>, the configuration directives in the <tt>.htaccess</tt> file take precedence. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/apache-http-server-configuration-red-hat-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Linux Mail Server</title>
		<link>http://blog.server.ruservers.com/2009/01/creating-a-linux-mail-server/</link>
		<comments>http://blog.server.ruservers.com/2009/01/creating-a-linux-mail-server/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 06:30:49 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[Mail server]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/creating-a-linux-mail-server/</guid>
		<description><![CDATA[&#160; Source: http://www.hypexr.org/linux_mail_server.php&#160; &#160; Creating a Linux Mail Server (Postfix, Procmail, Fetchmail, SpamBayes, Courier-imap, Mutt, SquirrelMail) What this Document is About Software Used Installing the Software Installing Postfix Installing Fetchmail Installing Procmail Installing SpamBayes Installing Mutt Installing courier-imap courier-authlib Installing SquirrelMail Installing pop-before-smtp Postfix Configuration main.cf Fetchmail Configuration Spambayes and Procmail Configuration Spam System Initial [...]]]></description>
			<content:encoded><![CDATA[<h3>&#160;</h3>
<p>Source: <a title="http://www.hypexr.org/linux_mail_server.php" href="http://www.hypexr.org/linux_mail_server.php">http://www.hypexr.org/linux_mail_server.php</a>&#160;</p>
<p>&#160;</p>
<h1>C<small>reating a</small> L<small>inux</small> M<small>ail</small> S<small>erver </small></h1>
<p> <small></small><br />
<h3><small>(Postfix, Procmail, Fetchmail, SpamBayes, Courier-imap, Mutt, SquirrelMail)</small></h3>
<h3><small></small></h3>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#whatis">What this Document is About</a></h5>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#software">Software Used</a></h5>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#install">Installing the Software</a></h5>
<ul>
<li><a href="http://www.hypexr.org/linux_mail_server.php#postfix_install">Installing Postfix</a></li>
<li><a href="http://www.hypexr.org/linux_mail_server.php#fetchmail_install">Installing Fetchmail</a></li>
<li><a href="http://www.hypexr.org/linux_mail_server.php#procmail_install">Installing Procmail</a></li>
<li><a href="http://www.hypexr.org/linux_mail_server.php#spambayes_install">Installing SpamBayes</a></li>
<li><a href="http://www.hypexr.org/linux_mail_server.php#mutt_install">Installing Mutt</a></li>
<li><a href="http://www.hypexr.org/linux_mail_server.php#courier_install">Installing courier-imap courier-authlib</a></li>
<li><a href="http://www.hypexr.org/linux_mail_server.php#squirrel_install">Installing SquirrelMail</a></li>
<li><a href="http://www.hypexr.org/linux_mail_server.php#popbs_install">Installing pop-before-smtp</a></li>
</ul>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#postfix">Postfix Configuration</a></h5>
<ul>
<li><a href="http://www.hypexr.org/linux_mail_server.php#main.cf">main.cf</a></li>
</ul>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#fetchmail">Fetchmail Configuration</a></h5>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#procmail">Spambayes and Procmail Configuration</a></h5>
<ul>
<li><a href="http://www.hypexr.org/linux_mail_server.php#sb_setup">Spam System Initial Setup</a></li>
<li><a href="http://www.hypexr.org/sb_proc">Procmail Configuration for Spambayes</a><a></a></li>
</ul>
<p> <a></a><br />
<h5><a href="http://www.hypexr.org/linux_mail_server.php#mutt">Mutt Configuration</a></h5>
<ul>
<li><a href="http://www.hypexr.org/linux_mail_server.php#muttrc">.muttrc Configuration</a></li>
<li><a href="http://www.hypexr.org/linux_mail_server.php#mutt_commands">New Mutt Commands</a></li>
</ul>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#squirrel">SquirrelMail Configuration</a></h5>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#courierauth">Courier Authentication</a></h5>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#pop-before-smtp">Pop-before-smtp Configuration</a></h5>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#additionalproc">Additional Simple Procmail Recipes and Mailbox Config</a></h5>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#conclusion">Conclusion</a></h5>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#resources">Resources</a></h5>
<ul>
<li><a href="http://www.hypexr.org/linux_mail_server.php#files">Example Files</a></li>
<li><a href="http://www.hypexr.org/linux_mail_server.php#links">Links</a></li>
</ul>
<h5><a href="http://www.hypexr.org/linux_mail_server.php#contributions">Contributions</a></h5>
<hr noshade="noshade" /><a name="whatis"></a><br />
<h5>What this Document is About</h5>
<p>This document covers how I have set up my Linux box to work as a Mail Server. The details will be specific to <a href="http://www.archlinux.org">Arch Linux</a>, but it will be be general enough for any *nix distribution if you have a knowledge of installing software packages, finding the location of configuration files, and starting/stoping services..</p>
<p>My goals in creating this mail system are to have all of my mail, from various email accounts, stored locally on my machine so I can access it anytime via SSH, the web, or imap. I wanted all of my mail delivered to my local user account and I wanted the spam to be sucked out and launched into space.</p>
<p>The backbone of the mail system is the Mail Transport Agent (MTA). It will handle receiving mail addressed directly to your machine, sending it to the correct users mail box, and sending mail out from the machine. I determined Postfix to be the best choice for my MTA and after some reading found Procmail for sorting mail, SpamBayes for detecting spam, and Fetchmail for grabbing mail from my pop mailboxes.</p>
<p>Bellow is a flow diagram for mail moving through the system:</p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/mail-system-flow.png" target="_blank" rel="lightbox[28]"><img title="mail_system_flow" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="407" alt="mail_system_flow" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/mail-system-flow-thumb.png" width="532" border="0" /></a> </p>
<p>The SpamAssassin and sa-learn can be ignored. I will describe how to use it with SpamBayes since I was not happy with Spam Assassin&#8217;s performance and had made the diagram when I was still using it.</p>
<p><a name="software"></a></p>
<h5>Software Used</h5>
<ul>
<li><a href="http://www.archlinux.org">Arch Linux</a></li>
<li><a href="http://www.postfix.org/">Postfix 2.1.5</a>
<ul>Secure, fast, easy to administer drop in replacement for Sendmail. (MTA) Provides smtp-server.        <br />(Requires sasl installed and support for sasl compiled into Postfix if sending mail through an intermediary as you may need to do if you have a domain name pointing to a dynamic IP address.)</ul>
</li>
<li><a href="http://asg.web.cmu.edu/sasl/">Cyrus SASL 2.1.21</a>
<ul>SASL authentication daemon.</ul>
</li>
<li><a href="http://www.procmail.org/">Procmail 3.22</a>
<ul>Highly configurable auto mail processing.</ul>
</li>
<li><a href="http://www.catb.org/%7Eesr/fetchmail/">Fetchmail 6.25</a>
<ul>A remote-mail retrieval utility.</ul>
</li>
<li><a href="http://spambayes.sourceforge.net/">SpamBayes 1.1a1</a>
<ul>a Bayesian anti-spam filter, initially based on the work of Paul Graham. The major difference between this and other, similar projects is the emphasis on testing newer approaches to scoring messages.</ul>
</li>
<li><a href="http://www.mutt.org/">Mutt 1.4.2.1</a>
<ul>A small but very powerful text-based mail client</ul>
</li>
<li><a href="http://www.courier-mta.org/imap/">Courier-imap 4.0.4</a>
<ul>IMAP / POP3 Server</ul>
</li>
<li><a href="http://www.courier-mta.org/authlib/">Courier-authlib 0.57</a>
<ul>Authentication library for the courier mailserver.</ul>
</li>
<li><a href="http://www.squirrelmail.org/">SquirrelMail cvs 1.5.1</a>
<ul>For checking mail via the web.        <br />(requires imap-server, perl, and php)</ul>
</li>
<li><a href="http://popbsmtp.sourceforge.net/">Pop-before-smtp 1.38</a>
<ul>A simple daemon written in Perl, to allow email relay control based on successful POP or IMAP logins.</ul>
</li>
</ul>
<p><a name="install"></a><br />
<h5>Installing the Software</h5>
<ul><a name="postfix_install"></a><br />
<h6>Installing Postfix</h6>
<p><b>A note for those with dynamic IP addresses:</b> Before installing Postfix we must first consider if it will need to make use of Simple Authentication and Security Layer (SASL). If you have a dynamic IP address and are using a service like <a href="http://www.dyndns.org">dyndns.org</a> you will need to have Postfix send your mail through your ISP&#8217;s mail server (with authentication) making use of SASL for the connection. This is because many domains that you will send email to will recognize your hostname as pointing to a dynamic IP address and send the mail back. Check if your distributions Postfix package was built with SASL support or if you are compiling Postfix from scratch add SASL with a ./configure option.</p>
<p>If you&#8217;ve determined you do not need SASL support in postfix:</p>
<ul>
<p>$ pacman -Sy postfix </p>
</ul>
<p>If you do need SASL support we need to install cyrus-sasl and use the <a href="http://wiki2.archlinux.org/index.php/ABS%20-%20the%20Arch%20Build%20System">Arch Build System (abs)</a> utility for building Postfix. Follow the instructions bellow or follow these Arch Wiki instructions: <a href="http://wiki.archlinux.org/index.php/PostFix_Howto_With_SASL">http://wiki.archlinux.org/index.php/PostFix_Howto_With_SASL</a></p>
<ul>
<p>$ pacman -Sy cyrus-sasl       <br />$ abs        <br />$ cd /var/abs        <br />$ mkdir -p local/postfix        <br />$ cp -v extra/daemons/postfix/* local/postfix </p>
</ul>
<p>Now edit /var/abs/local/postfix/PKGBUILD. Under the build() section change:</p>
<ul>
<p>make OPT=&quot;${CFLAGS}&quot; || return 1 </p>
</ul>
<p>to:</p>
<ul>
<pre>make OPT=&quot;${CFLAGS}&quot; \
CCARGS=&quot;-DUSE_SASL_AUTH -I/usr/include/sasl/&quot; \
AUXLIBS=&quot;-L/usr/lib/sasl2 -lsasl2&quot; || return 1</pre>
</ul>
<p>Now run:</p>
<ul>
<p>$ makepkg<br />
      <br />$ pacman -A postfix-*.pkg.tar.gz </p>
</ul>
<p>I like to then copy the package into a directory under /var/lib/pacman so I have access to all of my abs built packages later:</p>
<ul>
<p>$ mkdir /var/lib/pacman/abs_built<br />
      <br />$ cp postfix-*.pkg.tar.gz /var/lib/pacman/abs_built </p>
</ul>
<p>  <a name="fetchmail_install"></a></p>
<h6>Installing Fetchmail</h6>
<ul>
<p>$ pacman -S fetchmail </p>
</ul>
<p>  <a name="procmail_install"></a></p>
<h6>Installing Procmail</h6>
<ul>
<p>$ pacman -S procmail </p>
</ul>
<p>  <a name="spambayes_install"></a></p>
<h6>Installing SpamBayes</h6>
<p>SpamBayes is not yet in the pacman repository. Download it, extract, and install (substitute version numbers with most current):</p>
<ul>
<pre>$ wget http://dl.sourceforge.net/sourceforge\
/spambayes/spambayes-1.1a1.tar.gz
$ tar zxvf spambayes-1.1a1.tar.gz
$ cd spambayes-1.1a1
$ python setup.py install</pre>
</ul>
<p>  <a name="mutt_install"></a></p>
<h6>Installing Mutt</h6>
<ul>
<p>$ pacman -S mutt </p>
</ul>
<p>  <a name="courier_install"></a></p>
<h6>Installing courier-imap and courier-authlib</h6>
<p>SquirrelMail as well as other mail clients (evolution, outlook, cell phone, etc.) will use this to connect to the mail box. Courier-imap also depends on courier-authlib, so this command will install that as well.</p>
<ul>
<p>$ pacman -S courier-imap </p>
</ul>
<p>  <a name="squirrelmail_install"></a></p>
<h6>Installing SquirrelMail</h6>
<ul>
<p>$ pacman -S squirrelmail </p>
</ul>
<p>  <a name="popbs_install"></a></p>
<h6>Installing pop-before-smtp</h6>
<p>You are going to want to consider using <a href="http://www.aet.tu-cottbus.de/personen/jaenicke/pfixtls/">Postfix/TLS</a> or <a href="http://popbsmtp.sourceforge.net/">pop-before-smtp</a> if you are interested in users connected via IMAP being able to send mail (using your mail server as a SMTP relay). I recommend using Postfix/TLS but will not cover how to install/configure it in this document.</p>
<p>Pop-before-smtp is not in pacman repositories. Substitute version numbers with the most current.</p>
<ul>
<p>$ wget http://dl.sourceforge.net/sourceforge/popbsmtp/pop-before-smtp-1.38.tar.gz<br />
      <br />$ tar zxvf pop-before-smtp-*.tar.gz</p>
<p>$ cd pop-before-smtp-*</p>
</ul>
<p>Read the README in this directory and then read README.QUICKSTART in the contrib directory for where to copy the necessary files to.</p>
</ul>
<p><a name="postfix"></a></p>
<h5>Postfix Configuration</h5>
<p><a name="main.cf"></a></p>
<ul>
<h6>main.cf</h6>
<p>Now change to the <b>&#8216;/etc/postfix&#8217;</b> directory and open up main.cf for editing.</p>
<p>The domain name for my machine is through dyndns.org. Set your myhostname and my domain to something like this:</p>
<ul>
<p>myhostname = example.com mydomain = example.com </p>
</ul>
<p>Next we are going to want to set Postfix up for using qmail-style delivery with Maildir (where each email is stored in its own file). This is for courier-imap which SquirrelMail will be using to access the mail and will have other advantages. Don&#8217;t forget the ending forward slash.</p>
<ul>
<p>home_mailbox = Maildir/ </p>
</ul>
<p>Set it up so that incoming mail is sent through procmail and so we can alias names/users to mailboxes.</p>
<ul>
<p>mailbox_command = /usr/bin/procmail -a &quot;$DOMAIN&quot;<br />
      <br />alias_maps = hash:/etc/postfix/aliases </p>
</ul>
<p>If you have a dynamic IP or have trouble with mail being returned from large ISP&#8217;s or mail systems you are going to have to take a few extra steps. We will set it up so that mail will go through a relay host. In this example I will use my ISP&#8217;s (SBC) smtp server as an example. Make these additional changes to main.cf</p>
<ul>
<p>relayhost = [smtp.sbcglobal.yahoo.com]<br />
      <br /># authentication for sbc yahoo</p>
<p>smtp_sasl_auth_enable = yes</p>
<p>smtp_sasl_security_options = noanonymous</p>
<p>smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd </p>
</ul>
</ul>
<p>That wraps up our changes to main.cf. We just need to create the hash aliases databases that we defined above. Add these lines to the top of <b>/etc/postfix/aliases</b> (replacing hypexr with your user account of course):</p>
<ul>
<pre>root: hypexr

spam: hypexr
ham:  hypexr</pre>
</ul>
<p>Generate the database. From <b>/etc/postfix</b> dir:</p>
<ul>
<p>$ postalias aliases </p>
</ul>
<p>Set up smtp server and authentication for SBC mail relay. <b>sasl_passwd</b>:</p>
<ul>
<pre>smtp.sbc.mail.yahoo4.akadns.net    my_username@sbcglobal.net:my_passw</pre>
</ul>
<p><b><i>Note:</i> </b>Server name can change from time to time. There is a CNAME that points to this name but CNAMEs do not work here.</p>
<p>Generate the database:</p>
<ul>
<p>$ ./postmap sasl_passwd </p>
</ul>
<p>Start the postfix server and we are done with postfix!!!!</p>
<ul>
<p>$ /etc/rc.d/postfix start </p>
</ul>
<p>Having problems getting it to start? Check out the Postfix log file usually in <b>/var/log/mail</b> or <b>/var/log/maillog</b>.</p>
<p><a name="fetchmail"></a></p>
<h5>Fetchmail Configuration</h5>
<p>We are going to run our fetchmail daemon from user root. So create the file <b>/root/.fetchmailrc</b>:</p>
<ul>
<p>set postmaster &quot;postmaster&quot;<br />
    <br />set bouncemail</p>
<p>set no spambounce</p>
<p>set properties &quot;&quot;</p>
<p>set daemon 60</p>
<p>poll pop.example.com with proto POP3</p>
<p>&#160;&#160;&#160;&#160;&#160; user &#8216;user_name&#8217; there with password &#8216;my_password&#8217; is &#8216;local_user_to_deliver_to&#8217; here options flush</p>
<p>poll pop.gmail.com with proto POP3 port 995</p>
<p>&#160;&#160;&#160;&#160;&#160; user &#8216;my_gmail_un@gmail.com&#8217; there with ssl with password &#8216;my_password&#8217; is &#8216;hypexr&#8217; here options keep </p>
</ul>
<p>This tells fetchmail to check every minute for mail at pop.mypop.com and also at my gmail account. The flush option at the end of the mypop entry tells it to remove the mail after it is downloaded. I do not want the mail removed from my Gmail account so I use the keep option. Google also uses ssl, hence the &quot;with ssl&quot;. Fetchmail comes with its configuration utility <b>fetchmailconf</b> which makes setting up your .fetchmailrc file easy.</p>
<p>I don&#8217;t believe that Arch Linux has a rc script for fetchmail. The one that I made (/etc/rc.d/fetchmail) looks like this (stat_busy, stat_fail, stat_done are specific to Arch Linux. You could take these out):</p>
<ul>
<pre>#!/bin/sh

. /etc/rc.conf
. /etc/rc.d/functions

DAEMON_NAME=&quot;fetchmail&quot;
DAEMON_CONF=&quot;/root/.fetchmailrc&quot;
DAEMON_PATH=&quot;/usr/bin/fetchmail&quot;

PID=`pidof -o %PPID ${DAEMON_NAME}`

case &quot;$1&quot; in
start)
   stat_busy &quot;Starting ${DAEMON_NAME}&quot;
   [ -z &quot;$PID&quot; ] &amp;&amp; ${DAEMON_PATH} -f ${DAEMON_CONF} -d 60 &amp;&gt; /dev/null
   if [ $? -gt 0 ]; then
      stat_fail
   else
      add_daemon ${DAEMON_NAME}
      stat_done
   fi
   ;;
stop)
   stat_busy &quot;Stopping ${DAEMON_NAME}&quot;
   [ ! -z &quot;$PID&quot; ]  &amp;&amp; kill &quot;$PID&quot; &amp;&gt; /dev/null
   if [ $? -gt 0 ]; then
      stat_fail
   else
      rm_daemon ${DAEMON_NAME}
      stat_done
   fi
   ;;
restart)
   # calling 'stop' and 'start' without the $0 fails...
   $0 stop
   sleep 3
   $0 start
   ;;
*)
   echo &quot;usage: $0 {start|stop|restart}&quot;
esac
exit 0</pre>
</ul>
<p>And start the fetchmail daemon:</p>
<ul>
<p>$ /etc/rc.d/fetchmail start </p>
</ul>
<p>Or if you don&#8217;t want to create/modify an rc script you can start the fetchmail daemon like:</p>
<ul>
<p>$ /usr/bin/fetchmail -d 60 </p>
</ul>
<p><a name="procmail"></a></p>
<h5>Spambayes and Procmail Configuration</h5>
<p>We are going to be using Spambayes to train and determine if mail is spam and Procmail to sort the mail into folders when they enter our mail system. These two go together as far as Procmail is going to use Spambayes to help sort the mail.</p>
<p>I had used <a href="http://spamassassin.apache.org/">SpamAssassin</a> for a year and had not been very happy with its performance. I have only been using Spambayes for a few weeks and have been pleasantly surprised by how well it has worked and how quickly it adapts. In fairness I had been training SpamAssassin on all of my spam, the spam it had caught and the spam it had missed as well. It was also an older version and I was not using all of the features. With that being said if you are curious give it a try. Many other excellent programs exist. A quick search on Google will turn them up.</p>
<p>When Spambayes is installed it is going to move several files that start with sb_ into your /usr/bin directory. We are going to be interested in sb_mboxtrain.py and sb_filter.py. The former trains the spam filter and the later classifies incoming spam. There are two methods I tried for the initial training:</p>
<ol>
<li>Since I already had thousand of spam and ham (non spam) messages saved up I first tried initially training on this older mail. The results were okay but it was miss sorting mail. These problems would have sorted them selves out with the continued training of the misclassified mail but it would have also took a little while because the database had already been trained so much. </li>
<li>The second method I used was extremely effective. I started out with no training on initial messages. I simply let Spambayes work with no information. I then sent the spam and ham messages that ended up in the wrong mailbox to a designated folder. I then run the Spambayes training program on these miss classified messages.</li>
</ol>
<p>The results from the second method have been amazing. Without even having to manually classify very many messages Spambayes has been performing at superior levels. Check out <a href="http://www.entrian.com/sbwiki/TrainingIdeas">Spambayes Wiki</a> for many other training methods. I will discuss easy methods of sorting miss classifications in the Mutt and Squirrel Mail sections.</p>
<ul><a name="sb_setup"></a></p>
<h6>Spam System Initial Setup</h6>
<p>We are going to want Maildir folders to hold our regular mail, mail classified as spam, mail classified as unsure, missed spam, and missed ham.</p>
<p>If the standard Maildir directory (~/Maildir) doesn&#8217;t already exist lets create it with the necessary sub directories to make it a mail box. Run these commands from your user account who will be receiving the mail.</p>
<ul>
<p>$ mkdir ~/Maildir<br />
      <br />$ mkdir ~/Maildir/{new,cur,tmp} </p>
</ul>
<p>And now the other 4 directories that we are going to use for dealing with spam (Making the directories hidden is going to be done for integration with Squirrelmail): </p>
<ul>
<p>$ mkdir ~/Maildir/{.MissedSpam,.MissedHam,.CaughtSpam,.Unsure}<br />
      <br />$ mkdir ~/Maildir/.MissedSpam/{new,cur,tmp}</p>
<p>$ mkdir ~/Maildir/.MissedHam/{new,cur,tmp}</p>
<p>$ mkdir ~/Maildir/.CaughtSpam/{new,cur,tmp}</p>
<p>$ mkdir ~/Maildir/.Unsure/{new,cur,tmp}</p>
</ul>
<p>The messages that we are going to be training as spam are going to be in ~/Maildir/.MissedSpam and ham will be in ~/Maildir/.MissedHam. Lets create the script and cron job that will take care of training the Spambayes db. Create a file ~/Maildir/train_spambayes and add this: </p>
<ul>
<pre>#!/bin/sh
# Script to copy mail missed spam and ham into correct folders
# and run sb_mboxtrain.py to train spambayes
# Training will be done only on missed spam and ham

# Files we saved or bounced may be in the new directory
# We want them in cur for training
mv /home/hypexr/Maildir/.MissedSpam/new/* \
	/home/hypexr/Maildir/.MissedSpam/cur 2&gt;/dev/null
mv /home/hypexr/Maildir/.MissedHam/new/* \
	/home/hypexr/Maildir/.MissedHam/cur 2&gt;/dev/null
/usr/bin/sb_mboxtrain.py -d /home/hypexr/.hammie.db \
	-g /home/hypexr/Maildir/.MissedHam \
	-s /home/hypexr/Maildir/.MissedSpam</pre>
</ul>
<p>Make the script executable:</p>
<ul>
<p>$ chmod +x ~/Maildir/train_spambayes </p>
</ul>
<p>Set up our database that will be consulted for new email and trained on new spam/ham:</p>
<ul>
<p>$ /usr/bin/sb_filter.py -d $HOME/.hammie.db -n </p>
</ul>
<p>You will want cron installed so that it can launch the script above, which trains Spambayes, every night at 3:21 am. Edit your cron jobs with the command <b>crontab -e</b> and add: </p>
<ul>
<p>21 3 * * * ~/Maildir/train_spambayes </p>
</ul>
<p>  <a name="sb_proc"></a></p>
<h6>Procmail Configuration for Spambayes</h6>
<p>These are basic procmail recipes that will sort the spam from ham. From <a href="http://spambayes.sourceforge.net/unix.html">Spambayes on Unix or Linux</a>. Add these lines to your mail recipient&#8217;s ~/.procmailrc:</p>
<ul>
<pre>SHELL=/bin/sh
MAILDIR=$HOME/Maildir
DEFAULT=$HOME/Maildir/
CAUGHT_SPAM=$MAILDIR/CaughtSpam/
UNSURE=$MAILDIR/Unsure/

#Spambayes process
:0fw:hamlock
| /usr/bin/sb_filter.py -d /home/hypexr/.hammie.db

:0
* ^X-Spambayes-Classification: spam
${CAUGHT_SPAM}

:0
* ^X-Spambayes-Classification: unsure
${UNSURE}

# Catches everything else.
# Anything left over goes into the DEFAULT folder
:0:
${DEFAULT}</pre>
</ul>
<p>So incoming mail is not filtered through procmail&#8217;s rules where Spambayes&#8217;s sb_filter decides whether it is spam or ham. The mail is now sitting in the correct directories and ready to be accessed by whatever reader/front-end you would like. Next I going to describe setting up Mutt and SquirrelMail for viewing your mail. Mutt will be the most powerful option combining speed and sleekness but SquirrelMail will be able to match functionality.</p>
</ul>
<p><a name="mutt"></a></p>
<h5>Mutt Configuration</h5>
<p>First we need to set the MAIL variable so that Mutt will know where to look for your mail. In your ~/.bashrc (create if does not exist) add the line:</p>
<ul>
<p>MAIL=&#8217;~/Maildir&#8217; </p>
</ul>
<p>Exit out of your shell and log back in so that the variable will be set or run <b>export MAIL=&#8217;~/Maildir&#8217;</b>. On some systems mutt will not use <b>$MAIL</b> to determine the location of your mail box. When trying to start mutt if it reports a message that no mail directory exists you can try setting the <b>MAILDIR</b> variable or just create the directory that it wants to use and make it a valid Maildir: <b>mkdir -p ~/.maildir/{cur,new,tmp}</b> where .maildir is the folder that mutt wants to use. If you use a directory other than <b>~/Maildir</b> remember to substitute that wherever I reference Maildir in this document.</p>
<p>Now for the fun part. Lets make everything look pretty and integrated in Mutt. If you start up Mutt right now you will see any mail that your system has received since you have completed the steps above. If no mail shows up in Mutt and there should be mail you need to first check if Spambayes has filtered it into your <b>.Unsure</b> or <b>.CaughtSpam</b> directories. Type &#8216;<b>c</b>&#8216; to change directories and enter <b>~/Maildir/Unsure</b> and check out the mail thats been classified as spam: &#8216;<b>c</b>&#8216; <b>~/Maildir/CaughtSpam</b>. If you still have not found the mail that you are expecting to have received make sure that you have configured Postfix, Fetchmail, and Procmail correctly. Also, try sending mail directly to your_user_accunt@example.com and see if it shows up in one of the directories above.</p>
<p>Now mail is flowing into your system and we can check how Spambayes has classified it by checking the different mail folders. The miss classified mail just needs to be moved into the correct folders for the training.<br />
  <br />To manually move the misclassified spam mail:</p>
<ol>
<li>From you Maildir inbox tag each message that has arrived that is spam. Do this by pressing &#8216;<b>t</b>&#8216; and an asterisk will appear by the messages. After all of the messages have been tagged, press &#8216;<b>; m</b>&#8216; and enter <b>~/Maildir/MissedSpam</b> and the spam messages in your inbox will be moved to the MissedSpam mailbox for training by spambayes. </li>
<li>When looking at the mail that it has classified as spam in &#8216;~/Maildir/CaughtSpam&#8217;, tag all of the messages it considered spam that were ham and press &#8216;<b>; C</b>&#8216; and enter <b>~/Maildir/MissedHam</b>. Now tag them again and press &#8216;<b>; m</b>&#8216; and enter <b>~/Maildir</b> to move them into your inbox, where they should have been placed in the first place. </li>
</ol>
<p>Of course all of this manual stuff is a huge pain so lets automate all of it in <b><a href="http://www.hypexr.org/files/.muttrc">.muttrc</a></b>.</p>
<ul><a name="muttrc"></a></p>
<h6>.muttrc Configuration</h6>
<p>This <a href="http://www.hypexr.org/files/.muttrc">.muttrc</a> file is going to save you a quazillion.. thats right a quiazalliona hours in productivity in dealing with our current setup. Here it is:</p>
<ul>
<pre># Emacs is my editor of choice.  I have mostly read that people like
#  using emacs-client here and using an emacs server so that the
#  editing opens up in an existing emacs session but I prefer
#  loading up a fresh instance. The default editor is some 'vi'
set editor=&quot;emacs&quot;

# Setting these macros is going to save us all of that time I was
#  talking about.  Now instead of having to type all of those
#  characters to move the mail around we will can just tag the messages
#  and, for the instance of spam in your inbox, hit 'S'.

# Move mail to correct directories
macro   index   S       &quot;;s~/Maildir/.MissedSpam\r\r$\r&quot;
macro   pager   S       &quot;;s~/Maildir/.MissedSpam\r\r$\r&quot;
macro   index   H       &quot;;C~/Maildir/.MissedHam\r\r;s~/Maildir\r\r$\r&quot;
macro   pager   H       &quot;;C~/Maildir/.MissedHam\r\r;s~/Maildir\r\r$\r&quot;
macro   index   M       &quot;;s~/Maildir/\r&quot;
macro   pager   M       &quot;;s~/Maildir/\r&quot;

# This one lets me quickly move job search related emails to the
#  correct directory.  Want to give me a job? :)
macro   index   B       &quot;;s~/Maildir/.Job\r\r$\r&quot;
macro   pager   B       &quot;;s~/Maildir/.Job\r\r$\r

# This is how we are going to move around to the different
#  mailboxes.  Hitting 'alt-1' will take us to our inbox
#  'alt-2' and we are looking at the mail Spambayes classified
#  as spam.  etc.
#  The extra mailboxes I have in here are for mailing lists I am on.
#  I will show the procmail recipe that automatically puts
#  the mailing list mail into its correct mailbox further down.

# Move to mailboxes quickly
macro   index   &lt;Esc&gt;1  &quot;c~/Maildir\r&quot;
macro   pager   &lt;Esc&gt;1  &quot;c~/Maildir\r&quot;
macro   index   &lt;Esc&gt;2  &quot;c~/Maildir/.CaughtSpam\r&quot;
macro   pager   &lt;Esc&gt;2  &quot;c~/Maildir/.CaughtSpam\r&quot;
macro   index   &lt;Esc&gt;3  &quot;c~/Maildir/.Unsure\r&quot;
macro   pager   &lt;Esc&gt;3  &quot;c~/Maildir/.Unsure\r&quot;
macro   index   &lt;Esc&gt;4  &quot;c~/Maildir/.Tur\r&quot;
macro   pager   &lt;Esc&gt;4  &quot;c~/Maildir/.Tur\r&quot;
macro   index   &lt;Esc&gt;5  &quot;c~/Maildir/.Sbayes\r&quot;
macro   pager   &lt;Esc&gt;5  &quot;c~/Maildir/.Sbayes\r&quot;
macro   index   &lt;Esc&gt;6  &quot;c~/Maildir/.Wikka\r&quot;
macro   pager   &lt;Esc&gt;6  &quot;c~/Maildir/.Wikka\r&quot;
# Training Maildirs for Spam and Ham
macro   index   &lt;Esc&gt;8  &quot;c~/Maildir/.MissedSpam\r&quot;
macro   pager   &lt;Esc&gt;8  &quot;c~/Maildir/.MissedSpam\r&quot;
macro   index   &lt;Esc&gt;9  &quot;c~/Maildir/.MissedHam\r&quot;
macro   pager   &lt;Esc&gt;9  &quot;c~/Maildir/.MissedHam\r&quot;
# Job E-mails
macro   index   &lt;Esc&gt;0  &quot;c~/Maildir/.Job\r&quot;
macro   pager   &lt;Esc&gt;0  &quot;c~/Maildir/.Job\r&quot;

# Setting these colors makes it easy to tell which emails
#  Spambayes has missed.
# Turn spam red and unsure green
color index red default &quot;~h '^X-Spambayes-Classification: spam'&quot;
color index green default &quot;~h '^X-Spambayes-Classification: unsure'&quot;
# Turn gmail mail brightblue
#  (My regular expression is not correct here.  I think that it
#   is looking anywhere in the header for my gmail address
#   instead of what I wanted..  Just in the 'To:'.
#   It still works for the most part)
color index brightblue default &quot;~h '(^)*my_name@gmail.com'

# Lets set more colors to make things look beautiful.  Judging by
#  my title for this section I must have had bad feelings towards
#  colors when I added this.
#Color crap
color index brightwhite default ~N       # color for new messages
color status black yellow
color attachment brightyellow default    # file attachments
color search brightred default           # search matches
color quoted brightyellow default        # quoted text in replies
color quoted1 magenta default            # quoted text in replies
color body cyan default &quot;((ftp|http|https)://|news:)[^ &gt;)\&quot;\t]+&quot;   # URLs
color body cyan default &quot;[-a-z_0-9.+]+@[-a-z_0-9.]+&quot;               # email

# The rest of this stuff is pretty important for functionality and
#  readability.

# Don't ask to move read message
set move=no

# My signature is in this file
set signature=&quot;~/.signature&quot;

# Change mail to look like from scott@hypexr.org
#  Stick your email address here.
my_hdr From: Scott Rippee &lt;scott@hypexr.org&gt;

# Header control   h displays header when in pager
# I want to only see the unignored by default
ignore *                                        # weed out all headers
unignored date from: to cc subject organization  # now show me these...

# Thanks to many people whom have written the documents and posts that I
#  have gotten these settings from.</pre>
</ul>
<p>  <a name="mutt_commands"></a></p>
<h6>New Mutt Commands</h6>
<p>Here are the most useful (as far as dealing with spam) commands that we can now use in mutt:</p>
<ul>
<pre>t       Tag messages to be manipulated
S       Send message/s to spam training folder
H       Send message/s to ham training folder and to inbox
alt-1   Change mailbox to Maildir/ (inbox)
alt-2   Change mailbox to .CaughtSpam
alt-3   Change mailbox to .Unsure
alt-8   Change mailbox to .MissedSpam
alt-9   Change mailbox to .MissedHam</pre>
</ul>
<p>So for example, if a couple of spam messages show up in your inbox you can now tag them and hit &#8216;<b>S</b>&#8216; (remember its uppercase s) and have them vanished into .MissedSpam for training. </p>
</ul>
<p><a name="squirrel"></a></p>
<h5>SquirrelMail Configuration</h5>
<p>To configure SquirrelMail go into your <b>html_base_directory/squirrelmail/config</b> and run <b>./conf.pl</b>. Edit the options to fit your needs. If you want to test your config cruise over to <b>http://localhost/squirrelmail/src/configtest.php</b>. </p>
<p>Now go to <b>http://localhost/squirrelmail/</b> and login using your user account. If you have any email in your in box you should see it after you log in. Now click on the <b>Folders</b> option that is along the top, select all of the mailbox folders that we created earlier (they are listed here because we prefixed them with a period), and click on subscribe. Hit refresh and the mailboxes should be listed in the side panel. Now you can use SquirrelMail for almost all of you mail needs including tagging messages and moving them to the correct folders for Spambayes training and checking on the mail that Spambayes has classified as spam and unsure. The only functionality from our mutt setup that can&#8217;t be duplicated in SquirrelMail is copying missed ham into its training folder and then moving it into your inbox. This is due to the lack of copying ability. So you will have to go into the ham training folder to see some of the mail that should be in your inbox.</p>
<p><b><i>!!! IMPORTANT SECURITY NOTE!!! &#8211; </i></b>Using SquirrelMail like this is not secure! Sending the plain text passwords that you use for your Unix account can be accessed by by a 3rd party, which would them access to your account. You should set up a secure server with SSL and have Courier-imap use passwords that differ from the users system password using Courier Authlib, which I will demonstrate in the next session. Excellent documents exist all over the net for setting up your web server with ssl.</p>
<p><a href="http://blog.server.ruservers.com/wp-content/uploads/2009/01/sqmss.png" target="_blank" rel="lightbox[28]"><img title="sqmss" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="315" alt="sqmss" src="http://blog.server.ruservers.com/wp-content/uploads/2009/01/sqmss-thumb.png" width="534" border="0" /></a> </p>
<p><a name="courierauth"></a></p>
<h5>Courier Authentication</h5>
<p>Now is a good time to address a bit of essential security. As of now when a user connects via the SquirrelMail or IMAP interface the passwords are being sent in plain text and if these are sniffed that users system account is compromised. Without adding secure connections we can minimize the threat by using alternate passwords for imap connections. The snoop would then have access to your mail, but not be able to log in to the system.</p>
<p>Edit your <b>authdaemonrc</b> file. If your on Arch Linux this will be in <b>/etc/authlib</b>. Under <b>authmodulelist</b> I commented out:</p>
<ul>
<p>authmodulelist=&quot;authpam authpwd authuserdb authshadow &#8230;&quot; </p>
</ul>
<p>And replaced it with:</p>
<ul>
<p>authmodulelist=&quot;authuserdb&quot; </p>
</ul>
<p>I believe that adding authuserdb to the front of the list may work, but I am only using this method of authentication so it is all I need in my list.</p>
<p>Lets create the user account entry:</p>
<ul>
<pre>$ userdb &quot;some_user_name&quot; set home=/home/user_dir \
  mail=/home/user_dir/Maildir \
  uid=users_userid gid=users_groupid
$ userdbpw | userdb &quot;some_user_name&quot; set systempw</pre>
</ul>
<p>You will now be prompted for this pseudo users new password. Next make sure that <b>/etc/authlib/userdb</b> has read/write/execute access for the owner. If not <b>chmod 700 /usr/authlib/userdb</b>. Now create the user database that courier is going to look to for authentication:</p>
<ul>
<p>$ makeuserdb </p>
</ul>
<p>Again look to using Postfix/TLS for a tunneling the connection through a secure connection.</p>
<p><a name="pop-before-smtp"></a></p>
<h5>Pop-before-smtp Configuration</h5>
<p>To successfully configure pop-before-smtp follow the straight forward instructions in contrib/README.QUICKINSTALL. When you are done and everything is working it is important to make sure that you have not some how made your mail server an open relay! This would cause your mail server to be flooded with traffic and be put on the open relay ban lists.</p>
<p><b><i>!!! IMPORTANT SECURITY NOTE!!! &#8211; </i></b>I will not use the pop-before-smtp method because it involves sending a password over an insecure connection. Use Postfix through a SSL connection, <a href="http://www.aet.tu-cottbus.de/personen/jaenicke/pfixtls/">Postfix/TLS</a>, to accomplish this. Since your local machines are likely already allowed to use your Postfix as a mail relay the only time that you would be using this method is from a non-trusted server where you password can be sniffed. If you still choose to use this method make sure that you have changed the users courier password as described in <a href="http://www.hypexr.org/linux_mail_server.php#courierauth">Courier Authentication</a>.</p>
<p><a name="additionalproc"></a></p>
<h5>Additional Simple Procmail Recipes and Mailbox Config</h5>
<p>If you are a member of any news letters/mailing lists you can have them automatically sorted to their own mailbox using Procmail. First create the new mail directory in your ~/Maildir directory. Lets call it .Sbayes and pretend that we are on the Spambayes mailing list. So exactly as before with the spam related mailboxes: </p>
<ul>
<p>mkdir -p ~/Maildir/.Sbayes/{cur,new,tmp} </p>
</ul>
<p>Now add this new rule to your ~/.procmailrc: </p>
<ul>
<p># spambayes-dev@python.org mailing list<br />
    <br />:0</p>
<p>* ^X-BeenThere: spambayes@python.org</p>
<p>${MAILDIR}/.Sbayes/ </p>
</ul>
<p>In the <b>.mutrc</b> example above it shows an example of setting <b>alt-5</b> as the macro to see your Spambayes emails.</p>
<p>A slightly different method can be used to send spam and ham for training. Adding the following lines will allow you to bounce spam messages to spam@localhost (localhost or your mail_domain.com) and ham messages to ham@localhost: </p>
<ul>
<pre># Mail has been bounced to spam@localhost
:0
* ^Resent-To:.*spam
${MAILDIR}/.MissedSpam

# Mail has been bounced to ham@localhost
:0
* ^Resent-To:.*ham
${MAILDIR}/.MissedHam</pre>
</ul>
<p>If you want to bounce messages to the spam and ham addresses like this, you will need to make sure that the headers stay intact. Do not try using this or a similar technique for forwarding mails to an address because the email&#8217;s headers would not be intact and this is a large part of the spam classification. This method works because above we specified spam and ham as aliases for hypexr in the Postfix aliases file.</p>
<p><a name="conclusion"></a></p>
<h5>Conclusion</h5>
<p>For Arch Linux users, Add <b>saslauthd authdaemond courier-imap postfix fetchmail</b> to <b>DAEMONS</b> in your <b>/etc/rc.conf</b> file and they will be started automatically when your machine boots. If you are running a web server have the httpd service listed after the services we are adding.</p>
<p>/etc/rc.conf</p>
<ul>
<p>DAEMONS=(&#8230; saslauthd authdaemond postfix courier-imap fetchmail &#8230;) </p>
</ul>
<p>Enjoy your new mail system and centralized mailbox. If you are handling a large number of users for you email system this is just the tip of the iceberg and you are going to mostly be interested in virtual users, security, and a system wide spam classifier. There are many good documents on various setups to accomplish this, see the links section. If you have any suggestions, questions, comments, or corrections send me an email or drop a note in the <a href="http://forums.hypexr.org/viewtopic.php?p=119">forum</a>. If this document has been of any use to you, cheers. :)</p>
<p><a name="resources"></a></p>
<h5>Resources</h5>
<ul><a name="files"></a></p>
<h6>Example Files</h6>
<ul>
<li><a href="http://www.hypexr.org/files/.fetchmailrc">.fetchmailrc</a></li>
<li><a href="http://www.hypexr.org/files/.procmailrc">.procmailrc</a></li>
<li><a href="http://www.hypexr.org/files/.muttrc">.muttrc</a></li>
<li><a href="http://www.hypexr.org/files/train_spambayes">train_spambayes</a></li>
</ul>
<p>  <a name="links"></a></p>
<h6>Links</h6>
<ul>
<li><a href="http://www.archlinux.org">Arch Linux</a></li>
<li><a href="http://www.postfix.org/">Postfix</a></li>
<li><a href="http://www.procmail.org/">Procmail</a></li>
<li><a href="http://www.catb.org/%7Eesr/fetchmail/">Fetchmail</a></li>
<li><a href="http://spambayes.sourceforge.net/">SpamBayes</a></li>
<li><a href="http://www.mutt.org/">Mutt</a></li>
<li><a href="http://www.squirrelmail.org/">SquirrelMail</a></li>
<li><a href="http://www.courier-mta.org/imap/">Courier-imap</a></li>
<li><a href="http://www.courier-mta.org/authlib/">Courier-authlib</a></li>
</ul>
<p>Virtual users and mailboxes using MySQL and setting up SSL for SquirrelMail</p>
<ul>
<li><a href="http://wiki.archlinux.org/index.php/PostFix_Howto#Step_10._.2Fetc.2Frc.conf">Arch Wiki &#8211; Postfix Howto</a></li>
<li><a href="http://www.gentoo.org/doc/en/virt-mail-howto.xml">Gentoo &#8211; Virtual Mailhosting System with Postfix Guide</a></li>
</ul>
<p>Other Useful links</p>
<ul>
<li><a href="http://wiki.archlinux.org/index.php/PostFix_Howto">Arch Linux Postfix HowTo</a></li>
<li><a href="http://www.larsen-b.com/Article/100.html">Jkx@Home&#8217;s Courier Authentication</a></li>
<li><a href="http://yocum.org/faqs/postfix-tls-sasl.html">Postfix with TLS and SASL &#8211; geared towards FreeBSD</a></li>
<li><a href="http://www.syntheticzero.com/howto/vmail.php">Setting up Postfix + MySQL + Courier-IMAP + Mailman + vmail + Procmail + SpamAssassin &#8211; geared towards Fedora/Red Hat</a></li>
<li><a href="http://www.postfix.org/docs.html">Postfix Howtos and FAQs</a></li>
<li><a href="http://www.mutt.org/doc/manual/">The Mutt E-Mail Client Manual</a></li>
<li><a href="http://www.uwasa.fi/%7Ets/info/proctips.html">Timo&#8217;s procmail tips and recipes</a></li>
</ul>
</ul>
<p><a name="contributions"></a></p>
<h5>Contributions</h5>
<p>Thanks to <b>Constantinos Laitsas</b> for reworking the fetchmail rc file so that it will start as a daemon correctly</p>
<p>Thanks to <b>Robert Schweikert</b> for corrections to the train_spambayes script and the path to sb_filter.py</p>
<p>Thanks to <b>Alex Satrapa</b> for tips on example domain naming conventions</p>
<p>Thanks to <b>Austin Duncan</b> for tips on postfix configuration and mutts workings on other distros</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/creating-a-linux-mail-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysqlcheck &#8212; A Table Maintenance and Repair Program</title>
		<link>http://blog.server.ruservers.com/2009/01/mysqlcheck-a-table-maintenance-and-repair-program/</link>
		<comments>http://blog.server.ruservers.com/2009/01/mysqlcheck-a-table-maintenance-and-repair-program/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 09:42:34 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[MYSQL]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/mysqlcheck-a-table-maintenance-and-repair-program/</guid>
		<description><![CDATA[&#160; Source:http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html &#160; The mysqlcheck client checks, repairs, optimizes, and analyzes tables. mysqlcheck is available as of MySQL 3.23.38. mysqlcheck is similar in function to myisamchk, but works differently. The main operational difference is that mysqlcheck must be used when the mysqld server is running, whereas myisamchk should be used when it is not. The [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source:<a title="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html" href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html">http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html</a></p>
<p>&#160;</p>
<h5>The <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> client checks, repairs, optimizes, and analyzes tables. <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> is available as of MySQL 3.23.38. </h5>
<p><a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> is similar in function to <a href="http://dev.mysql.com/doc/refman/4.1/en/myisamchk.html"><strong>myisamchk</strong></a>, but works differently. The main operational difference is that <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> must be used when the <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqld.html"><strong>mysqld</strong></a> server is running, whereas <a href="http://dev.mysql.com/doc/refman/4.1/en/myisamchk.html"><strong>myisamchk</strong></a> should be used when it is not. The benefit of using <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> is that you do not have to stop the server to check or repair your tables. </p>
<p><a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> uses the SQL statements <a href="http://dev.mysql.com/doc/refman/4.1/en/check-table.html"><code>CHECK TABLE</code></a>, <a href="http://dev.mysql.com/doc/refman/4.1/en/repair-table.html"><code>REPAIR TABLE</code></a>, <a href="http://dev.mysql.com/doc/refman/4.1/en/analyze-table.html"><code>ANALYZE TABLE</code></a>, and <a href="http://dev.mysql.com/doc/refman/4.1/en/optimize-table.html"><code>OPTIMIZE TABLE</code></a> in a convenient way for the user. It determines which statements to use for the operation you want to perform, and then sends the statements to the server to be executed. For details about which storage engines each statement works with, see the descriptions for those statements in <a href="http://dev.mysql.com/doc/refman/4.1/en/sql-syntax.html">Chapter 12, <i>SQL Statement Syntax</i></a>. </p>
<p>The <code>MyISAM</code> storage engine supports all four statements, so <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> can be used to perform all four operations on <code>MyISAM</code> tables. Other storage engines do not necessarily support all operations. In such cases, an error message is displayed. For example, if <code>test.t</code> is a <code>MEMORY</code> table, an attempt to check it produces this result: </p>
<pre>shell&gt; <strong><code>mysqlcheck test t</code></strong>
test.t
note     : The storage engine for the table doesn't support check</pre>
<h5>Caution</h5>
<p>It is best to make a backup of a table before performing a table repair operation; under some circumstances the operation might cause data loss. Possible causes include but are not limited to filesystem errors. </p>
<p>There are three general ways to invoke <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a>: </p>
<pre>shell&gt; <strong><code>mysqlcheck [<em><code>options</code></em>] <em><code>db_name</code></em> [<em><code>tables</code></em>]</code></strong>
shell&gt; <strong><code>mysqlcheck [<em><code>options</code></em>] --databases <em><code>db_name1</code></em> [<em><code>db_name2</code></em> <em><code>db_name3</code></em>...]</code></strong>
shell&gt; <strong><code>mysqlcheck [<em><code>options</code></em>] --all-databases</code></strong></pre>
<p>If you do not name any tables following <em><code>db_name</code></em> or if you use the <code>--databases</code> or <code>--all-databases</code> option, entire databases are checked. </p>
<p><a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> has a special feature compared to other client programs. The default behavior of checking tables (<code>--check</code>) can be changed by renaming the binary. If you want to have a tool that repairs tables by default, you should just make a copy of <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> named <strong>mysqlrepair</strong>, or make a symbolic link to <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> named <strong>mysqlrepair</strong>. If you invoke <strong>mysqlrepair</strong>, it repairs tables. </p>
<p>The following names can be used to change <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> default behavior: </p>
<p><strong>mysqlrepair</strong></p>
<p>The default option is <code>--repair</code></p>
<p><strong>mysqlanalyze</strong></p>
<p>The default option is <code>--analyze</code></p>
<p><strong>mysqloptimize</strong></p>
<p>The default option is <code>--optimize</code></p>
<p><a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> supports the following options: </p>
<ul>
<li>
<p><a name="option_mysqlcheck_help"></a><a name="id2561930"></a><a name="id2561943"></a><code>--help</code>, <code>-?</code></p>
<p>Display a help message and exit. </p>
</li>
<li>
<p><a name="option_mysqlcheck_all-databases"></a><a name="id2561975"></a><a name="id2561988"></a><code>--all-databases</code>, <code>-A</code></p>
<p>Check all tables in all databases. This is the same as using the <code>--databases</code> option and naming all the databases on the command line. </p>
</li>
<li>
<p><a name="option_mysqlcheck_all-in-1"></a><a name="id2562026"></a><a name="id2562039"></a><code>--all-in-1</code>, <code>-1</code></p>
<p>Instead of issuing a statement for each table, execute a single statement for each database that names all the tables from that database to be processed. </p>
</li>
<li>
<p><a name="option_mysqlcheck_analyze"></a><a name="id2562073"></a><a name="id2562086"></a><code>--analyze</code>, <code>-a</code></p>
<p>Analyze the tables. </p>
<p><b>MySQL Enterprise. </b> For expert advice on optimizing tables, subscribe to the MySQL Enterprise Monitor. For more information, see <a href="http://www.mysql.com/products/enterprise/advisors.html">http://www.mysql.com/products/enterprise/advisors.html</a>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_auto-repair"></a><a name="id2562139"></a><a name="id2562151"></a><code>--auto-repair</code></p>
<p>If a checked table is corrupted, automatically fix it. Any necessary repairs are done after all tables have been checked. </p>
</li>
<li>
<p><a name="option_mysqlcheck_character-sets-dir"></a><a name="id2562183"></a><a name="id2562195"></a><code>--character-sets-dir=<em><code>path</code></em></code></p>
<p>The directory where character sets are installed. See <a href="http://dev.mysql.com/doc/refman/4.1/en/charset-configuration.html">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_check"></a><a name="id2562233"></a><a name="id2562245"></a><code>--check</code>, <code>-c</code></p>
<p>Check the tables for errors. This is the default operation. </p>
</li>
<li>
<p><a name="option_mysqlcheck_check-only-changed"></a><a name="id2562278"></a><a name="id2562291"></a><code>--check-only-changed</code>, <code>-C</code></p>
<p>Check only tables that have changed since the last check or that have not been closed properly. </p>
</li>
<li>
<p><a name="option_mysqlcheck_compress"></a><a name="id2562325"></a><a name="id2562338"></a><code>--compress</code></p>
<p>Compress all information sent between the client and the server if both support compression. </p>
</li>
<li>
<p><a name="option_mysqlcheck_databases"></a><a name="id2562368"></a><a name="id2562381"></a><code>--databases</code>, <code>-B</code></p>
<p>Process all tables in the named databases. Normally, <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> treats the first name argument on the command line as a database name and following names as table names. With this option, it treats all name arguments as database names. </p>
</li>
<li>
<p><a name="option_mysqlcheck_debug"></a><a name="id2562424"></a><a name="id2562436"></a><code>--debug[=<em><code>debug_options</code></em>]</code>, <code>-# [<em><code>debug_options</code></em>]</code></p>
<p>Write a debugging log. A typical <em><code>debug_options</code></em> string is often <code>'d:t:o,<em><code>file_name</code></em>'</code>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_default-character-set"></a><a name="id2562491"></a><a name="id2562504"></a><code>--default-character-set=<em><code>charset_name</code></em></code></p>
<p>Use <em><code>charset_name</code></em> as the default character set. See <a href="http://dev.mysql.com/doc/refman/4.1/en/charset-configuration.html">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_extended"></a><a name="id2562545"></a><a name="id2562558"></a><code>--extended</code>, <code>-e</code></p>
<p>If you are using this option to check tables, it ensures that they are 100% consistent but takes a long time. </p>
<p>If you are using this option to repair tables, it runs an extended repair that may not only take a long time to execute, but may produce a lot of garbage rows also! </p>
</li>
<li>
<p><a name="option_mysqlcheck_fast"></a><a name="id2562598"></a><a name="id2562611"></a><code>--fast</code>, <code>-F</code></p>
<p>Check only tables that have not been closed properly. </p>
</li>
<li>
<p><a name="option_mysqlcheck_force"></a><a name="id2562643"></a><a name="id2562656"></a><code>--force</code>, <code>-f</code></p>
<p>Continue even if an SQL error occurs. </p>
</li>
<li>
<p><a name="option_mysqlcheck_host"></a><a name="id2562688"></a><a name="id2562701"></a><code>--host=<em><code>host_name</code></em></code>, <code>-h <em><code>host_name</code></em></code></p>
<p>Connect to the MySQL server on the given host. </p>
</li>
<li>
<p><a name="option_mysqlcheck_medium-check"></a><a name="id2562739"></a><a name="id2562751"></a><code>--medium-check</code>, <code>-m</code></p>
<p>Do a check that is faster than an <code>--extended</code> operation. This finds only 99.99% of all errors, which should be good enough in most cases. </p>
</li>
<li>
<p><a name="option_mysqlcheck_optimized"></a><a name="id2562790"></a><a name="id2562802"></a><code>--optimize</code>, <code>-o</code></p>
<p>Optimize the tables. </p>
</li>
<li>
<p><a name="option_mysqlcheck_password"></a><a name="id2562834"></a><a name="id2562847"></a><code>--password[=<em><code>password</code></em>]</code>, <code>-p[<em><code>password</code></em>]</code></p>
<p>The password to use when connecting to the server. If you use the short option form (<code>-p</code>), you <em>cannot</em> have a space between the option and the password. If you omit the <em><code>password</code></em> value following the <code>--password</code> or <code>-p</code> option on the command line, you are prompted for one. </p>
<p>Specifying a password on the command line should be considered insecure. See <a href="http://dev.mysql.com/doc/refman/4.1/en/password-security.html">Section 5.6.6, “Keeping Passwords Secure”</a>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_pipe"></a><a name="id2562919"></a><a name="id2562931"></a><code>--pipe</code>, <code>-W</code></p>
<p>On Windows, connect to the server via a named pipe. This option applies only for connections to a local server, and only if the server supports named-pipe connections. </p>
</li>
<li>
<p><a name="option_mysqlcheck_port"></a><a name="id2562966"></a><a name="id2562979"></a><code>--port=<em><code>port_num</code></em></code>, <code>-P <em><code>port_num</code></em></code></p>
<p>The TCP/IP port number to use for the connection. </p>
</li>
<li>
<p><a name="option_mysqlcheck_protocol"></a><a name="id2563016"></a><a name="id2563029"></a><code>--protocol={TCP|SOCKET|PIPE|MEMORY}</code></p>
<p>The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. For details on the allowable values, see <a href="http://dev.mysql.com/doc/refman/4.1/en/connecting.html">Section 4.2.2, “Connecting to the MySQL Server”</a>. This option was added in MySQL 4.1. </p>
</li>
<li>
<p><a name="option_mysqlcheck_quick"></a><a name="id2563068"></a><a name="id2563081"></a><code>--quick</code>, <code>-q</code></p>
<p>If you are using this option to check tables, it prevents the check from scanning the rows to check for incorrect links. This is the fastest check method. </p>
<p>If you are using this option to repair tables, it tries to repair only the index tree. This is the fastest repair method. </p>
</li>
<li>
<p><a name="option_mysqlcheck_repair"></a><a name="id2563122"></a><a name="id2563134"></a><code>--repair</code>, <code>-r</code></p>
<p>Perform a repair that can fix almost anything except unique keys that are not unique. </p>
</li>
<li>
<p><a name="option_mysqlcheck_silent"></a><a name="id2563168"></a><a name="id2563180"></a><code>--silent</code>, <code>-s</code></p>
<p>Silent mode. Print only error messages. </p>
</li>
<li>
<p><a name="option_mysqlcheck_socket"></a><a name="id2563213"></a><a name="id2563225"></a><code>--socket=<em><code>path</code></em></code>, <code>-S <em><code>path</code></em></code></p>
<p>For connections to <code>localhost</code>, the Unix socket file to use, or, on Windows, the name of the named pipe to use. </p>
</li>
<li>
<p><a name="option_mysqlcheck_ssl"></a><a name="id2563270"></a><a name="id2563283"></a><code>--ssl*</code></p>
<p>Options that begin with <code>--ssl</code> specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See <a href="http://dev.mysql.com/doc/refman/4.1/en/ssl-options.html">Section 5.6.7.3, “SSL Command Options”</a>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_tables"></a><a name="id2563322"></a><a name="id2563335"></a><code>--tables</code></p>
<p>Overrides the <code>--databases</code> or <code>-B</code> option. All name arguments following the option are regarded as table names. </p>
</li>
<li>
<p><a name="option_mysqlcheck_use-frm"></a><a name="id2563372"></a><a name="id2563385"></a><code>--use-frm</code></p>
<p>For repair operations on <code>MyISAM</code> tables, get the table structure from the <code>.frm</code> file so that the table can be repaired even if the <code>.MYI</code> header is corrupted. This option was added in MySQL 4.0.5. </p>
</li>
<li>
<p><a name="option_mysqlcheck_user"></a><a name="id2563435"></a><a name="id2563447"></a><code>--user=<em><code>user_name</code></em></code>, <code>-u <em><code>user_name</code></em></code></p>
<p>The MySQL user name to use when connecting to the server. </p>
</li>
<li>
<p><a name="option_mysqlcheck_verbose"></a><a name="id2563485"></a><a name="id2563498"></a><code>--verbose</code>, <code>-v</code></p>
<p>Verbose mode. Print information about the various stages of program operation. </p>
</li>
<li>
<p><a name="option_mysqlcheck_version"></a><a name="id2563531"></a><a name="id2563544"></a><code>--version</code>, <code>-V</code></p>
<p>Display version information and exit. </p>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/mysqlcheck-a-table-maintenance-and-repair-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forcing InnoDB Recovery</title>
		<link>http://blog.server.ruservers.com/2009/01/forcing-innodb-recovery/</link>
		<comments>http://blog.server.ruservers.com/2009/01/forcing-innodb-recovery/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 09:36:05 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[MYSQL]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/forcing-innodb-recovery/</guid>
		<description><![CDATA[&#160; Source: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html&#160; &#160; If there is database page corruption, you may want to dump your tables from the database with SELECT INTO ... OUTFILE. Usually, most of the data obtained in this way is intact. However, it is possible that the corruption might cause SELECT * FROM tbl_name statements or InnoDB background operations to [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source: <a title="http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html" href="http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html">http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html</a>&#160;</p>
<p>&#160;</p>
<p>If there is database page corruption, you may want to dump your tables from the database with <code>SELECT INTO ... OUTFILE</code>. Usually, most of the data obtained in this way is intact. However, it is possible that the corruption might cause <code>SELECT * FROM <em><code>tbl_name</code></em></code> statements or <code>InnoDB</code> background operations to crash or assert, or even cause <code>InnoDB</code> roll-forward recovery to crash. In such cases, you can use the <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a> option to force the <code>InnoDB</code> storage engine to start up while preventing background operations from running, so that you are able to dump your tables. For example, you can add the following line to the <code>[mysqld]</code> section of your option file before restarting the server: </p>
<pre>[mysqld]
innodb_force_recovery = 4</pre>
<p><a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a> is 0 by default (normal startup without forced recovery) The allowable non-zero values for <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a> follow. A larger number includes all precautions of smaller numbers. If you are able to dump your tables with an option value of at most 4, then you are relatively safe that only some data on corrupt individual pages is lost. A value of 6 is more drastic because database pages are left in an obsolete state, which in turn may introduce more corruption into B-trees and other database structures. </p>
<ul>
<li>
<p><code>1</code> (<code>SRV_FORCE_IGNORE_CORRUPT</code>) </p>
<p>Let the server run even if it detects a corrupt page. Try to make <code>SELECT * FROM <em><code>tbl_name</code></em></code> jump over corrupt index records and pages, which helps in dumping tables. </p>
</li>
<li>
<p><code>2</code> (<code>SRV_FORCE_NO_BACKGROUND</code>) </p>
<p>Prevent the main thread from running. If a crash would occur during the purge operation, this recovery value prevents it. </p>
</li>
<li>
<p><code>3</code> (<code>SRV_FORCE_NO_TRX_UNDO</code>) </p>
<p>Do not run transaction rollbacks after recovery. </p>
</li>
<li>
<p><code>4</code> (<code>SRV_FORCE_NO_IBUF_MERGE</code>) </p>
<p>Prevent insert buffer merge operations. If they would cause a crash, do not do them. Do not calculate table statistics. </p>
</li>
<li>
<p><code>5</code> (<code>SRV_FORCE_NO_UNDO_LOG_SCAN</code>) </p>
<p>Do not look at undo logs when starting the database: <code>InnoDB</code> treats even incomplete transactions as committed. </p>
</li>
<li>
<p><code>6</code> (<code>SRV_FORCE_NO_LOG_REDO</code>) </p>
<p>Do not do the log roll-forward in connection with recovery. </p>
</li>
</ul>
<p><em>The database must not otherwise be used with any non-zero value of <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a></em>. As a safety measure, <code>InnoDB</code> prevents users from performing <a href="http://dev.mysql.com/doc/refman/5.1/en/insert.html"><code>INSERT</code></a>, <a href="http://dev.mysql.com/doc/refman/5.1/en/update.html"><code>UPDATE</code></a>, or <a href="http://dev.mysql.com/doc/refman/5.1/en/delete.html"><code>DELETE</code></a> operations when <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a> is greater than 0. </p>
<p>You can <a href="http://dev.mysql.com/doc/refman/5.1/en/select.html"><code>SELECT</code></a> from tables to dump them, or <code>DROP</code> or <code>CREATE</code> tables even if forced recovery is used. If you know that a given table is causing a crash on rollback, you can drop it. You can also use this to stop a runaway rollback caused by a failing mass import or <a href="http://dev.mysql.com/doc/refman/5.1/en/alter-table.html"><code>ALTER TABLE</code></a>. You can kill the <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqld.html"><strong>mysqld</strong></a> process and set <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a> to <code>3</code> to bring the database up without the rollback, then <code>DROP</code> the table that is causing the runaway rollback. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/forcing-innodb-recovery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
