<?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>[LINICKX].com &#187; apache</title>
	<atom:link href="http://www.linickx.com/tag/apache/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linickx.com</link>
	<description>Moments of Genius followed by Trash.</description>
	<lastBuildDate>Thu, 17 May 2012 10:23:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>CSS Styling Apache Directory Listings.</title>
		<link>http://www.linickx.com/343/css-styling-apache-directory-listings</link>
		<comments>http://www.linickx.com/343/css-styling-apache-directory-listings#comments</comments>
		<pubDate>Thu, 11 Oct 2007 08:44:54 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.linickx.com/archives/343/css-styling-apache-directory-listings</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div style="float:right">
<table <tr>
<td><a href='http://www.linickx.com/files/2008/05/apachedirlisting_before.png' rel="lightbox[343]"><img src="http://www.linickx.com/files/2008/05/apachedirlisting_before-150x150.png" alt="Before I change Apache" title="Default Apache Directory Listing " width="150" height="150" class="alignnone size-thumbnail wp-image-409" /></a></td>
<tr>
<td style="text-align:center"><strong>Before.</strong></td>
</tr>
</table>
</div>
<p>As part of <a href="http://www.linickx.com/archives/336/website-changes">my website overhaul</a>, I&#8217;ve finally gotten round to styling my <a href="http://www.linickx.com/files/">/files/</a> directory. I was surprised at how easy it was actually, and the benefits far out way the time taken to set it up, not only does this part of the site now &#8220;fit in&#8221;, but I can apply analytics tracking and adsense <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  I&#8217;m sure there probably is a wordpress plugin that can achieve the same thing&#8230; probably better, but I find my list of plugins ever growing and since I don&#8217;t <em>need</em> on for this I figure if Apache can do it, let Apache do it!</p>
<p>The work can be done in one of two ways either by pasting Apache directives into a .htaccess file (<em>in the directory you want to apply conf to</em>), or in your httpd.conf you can wrap it all up in a
<pre class="brush: plain; title: ; notranslate">&lt;Directory&gt; </pre>
<p> tag&#8230; something like
<pre class="brush: plain; title: ; notranslate">&lt;Directory &quot;/var/www/html/files/&quot;&gt; foobar&gt; &lt;/Directory&gt;</pre>
<p> below is an example of a .htaccess file as that will apply to most people:</p>
<pre class="brush: plain; title: ; notranslate">
        RewriteEngine Off
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
        Options Indexes Includes
        IndexOptions FancyIndexing SuppressHTMLPreamble XHTML IconsAreLinks FoldersFirst SuppressDescription
        HeaderName /files/HEADER.shtml
        ReadmeName /files/README.shtml
</pre>
<p>Since my site uses wordpress with &#8220;pretty permalinks&#8221; enabled, the 1st thing I needed to do is disable mod re-write for the directory where I wanted listing enabled. Now if you check my <a href="http://www.linickx.com/files/">/files/</a> page you&#8217;ll notice that the page title and tag line under &#8220;[LINICKX].com&#8221; change depending on what directory you are viewing, this is done with &#8220;Server Side Includes&#8221; (<em>SSI</em>), so the next two options in the above config set that up.</p>
<p>Now to take a look at the actual directory listing setup, it might be worth you taking a look at the <a href="http://httpd.apache.org/docs/2.2/mod/mod_autoindex.html">Apache documentation</a> for a full description, but the important ones to note are
<pre class="brush: plain; title: ; notranslate">Options Indexes Includes</pre>
<p> to enable directory listing and switch on SSI, then you need
<pre class="brush: plain; title: ; notranslate">IndexOptions SuppressHTMLPreamble XHTML</pre>
<p> to disable the default headers so that we can setup our style sheet and favour xHTML over HTML. Apache 2.2 users also have <a href="http://httpd.apache.org/docs/2.2/mod/mod_autoindex.html#indexstylesheet">IndexStyleSheet</a> available, but since I&#8217;m using CentOS4 we&#8217;ll do it this way. Finally you need the <b>HeaderName</b>, <b>ReadmeName</b> directives to tell Apache which file to look for (<em>by default Apache looks for README.html, but that won&#8217;t support SSI</em>)&#8230; note how my .shtml files are relative to my web root, these are not absolute paths on the file system, i.e. /files actually maps to /var/www/html/files. </p>
<p>You&#8217;re now good to go, HEADER.shtml should contain all the xHTML you want to appear before the directory listing, and README.html is everything after&#8230; make sure you include all the correct &lt;html&gt;, &lt;body&gt; and DOCTYPE tags.</p>
<p>Now you&#8217;ll want to get working is some dynamic content, for a simple &#8220;print current directory&#8221; you can use
<pre class="brush: plain; title: ; notranslate">&lt;!--#echo var=&quot;REQUEST_URI&quot;--&gt;</pre>
<p> in your html, further documentation on getting more magic is available <a href="http://webmaster.iu.edu/tool_guide_info/ssitutorial.shtml">here</a> &#038; <a href="http://www.georgedillon.com/web/ssivar.shtml">here</a>, I was able to knock up a simple line of code to print the current year at the bottom of the page&#8230;.</p>
<pre class="brush: plain; title: ; notranslate">
&lt;!--#config timefmt=&quot;%Y&quot;--&gt;
&lt;small&gt;Nick Bettison 2005 - &lt;!--#echo var=&quot;DATE_LOCAL&quot;--&gt; &amp;amp;copy; &lt;/small&gt;;
</pre>
<p>Cool eh! The trick to watch out for is spaces in the above code, there should be no white space between
<pre class="brush: plain; title: ; notranslate">&lt;--#echo</pre>
<p> or the trailing
<pre class="brush: plain; title: ; notranslate">--&gt;</pre>
<div style="float:right">
<table <tr>
<td><a href='http://www.linickx.com/files/2008/05/apachedirlisting_after.png' rel="lightbox[343]"><img src="http://www.linickx.com/files/2008/05/apachedirlisting_after-150x150.png" alt="Looking much better" title="Linickx.com V2 Styled Listing!" width="150" height="150" class="alignnone size-thumbnail wp-image-410" /></a></td>
<tr>
<td style="text-align:center"><strong>After.</strong></td>
</tr>
</table>
</div>
<p>The final thing you&#8217;ll want to look at is those horible default icons! You have a couple of options: You can either simply replace/over-write the default ones (<em>on my flavour of linux they are in /var/www/icons</em>), or you can add
<pre class="brush: plain; title: ; notranslate">AddIcon /icons/tar.png .tar</pre>
<p> to your htaccess file telling apache to look at tar.png rather than the default tar.gif, I found some <a href="https://gna.org/projects/apache-icons/">deb archives</a> which I extracted with file-roller (<em>rather than trying to install anything</em>) and simply changed the ones I was going to use&#8230;. I&#8217;m very please with the final result, I think it makes a big difference.</p>
<p>Happy Styling One &amp; All!</p>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/343/css-styling-apache-directory-listings/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Trouble-Shooting the WordPress Security White Paper.</title>
		<link>http://www.linickx.com/342/trouble-shooting-the-wordpress-security-white-paper</link>
		<comments>http://www.linickx.com/342/trouble-shooting-the-wordpress-security-white-paper#comments</comments>
		<pubDate>Mon, 08 Oct 2007 08:59:23 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[blogsecurity.net]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://www.linickx.com/archives/342/trouble-shooting-the-wordpress-security-white-paper</guid>
		<description><![CDATA[I&#8217;ve been following the activity over at blogsecurity, their activities are very interesting and quite commendable. After some shameless delay I decided to read though their WP Security White Paper and apply some of the steps&#8230; yes I did say &#8230; <a href="http://www.linickx.com/342/trouble-shooting-the-wordpress-security-white-paper">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been following the activity over at <a href="http://blogsecurity.net">blogsecurity</a>, their activities are very interesting and quite commendable. After some shameless delay I decided to read though their <a href="http://blogsecurity.net/wordpress/wordpress-security-whitepaper/">WP Security White Paper</a> and apply some of the steps&#8230; yes I did say some, harden security folk will insist that you should follow <strong>all</strong> of the whitepaper to be security, which is probably true, but one should never forget that security is about risk&#8230; and in basic terms accessibility vs security, for example I won&#8217;t ever lock my wp-admin down to a single IP as I&#8217;ve been know to blog at work, home, around my parents place and even moderate comments on the train! Thus my wp-admin isn&#8217;t as secure as someone who did lock it down, but this is a risk I&#8217;m willing to live with.</p>
<p>One of the area&#8217;s that I did like was the tightening up of wp-includes &#038; wp-content, but before you jump in and copy/paste what&#8217;s in the pdf into .htaccess, you should be prepared for some work. Basically </p>
<p><code><br />
	Order Allow,Deny<br />
	Deny from all<br />
	&lt;Files ~ ".(css|jpe?g|png|gif|js)$"&gt;<br />
	Allow from all<br />
	&lt;/Files&gt;<br />
</code></p>
<p>when applied stops any file except .css,.jpeg/jpg, .png, .gif &#038; .js from being accessible; now this is great for stopping zero-day remote file includes from php files but it will mean that any php file (<em>even those you may want access to</em>) will be restricted. What I&#8217;ve decided to do below is document what changes you need to make to the recommendation to get some popular plugins to work&#8230;. This approach will also have a long term impact on the &#8220;<a href="http://blogsecurity.net/wordpress/wordpress-hardening-project-update/">hardening plug-in</a>&#8221;   that the blogsecurity team are planning; basically the issue is &#8211; the default recommended .htaccess will break plugins, the number of plugins avilable for a wordpress install is unlimited thus they will need to provide a community driven configuration repository that the plugin can draw upon to open things up for specific plugins.</p>
<p>For the purpose of this documentation, I&#8217;m going to assume wordpress is installed in <code>/var/www/html</code> so please change appropriately.</p>
<p>For those who use the rich editor and need the spell checker, you&#8217;ll need to add this to your <code>/var/www/html/wp-includes/js/tinymce/plugins/spellchecker/.htaccess</code></p>
<p><code><br />
# Open up the spellchecker<br />
&lt;Files "tinyspell.php"&gt;<br />
        Allow from all<br />
&lt;/Files&gt;<br />
</code></p>
<p>To get the popular <strong>WP-Cache</strong> plugin to work changes are made to:<code>/var/www/html/wp-content/.htaccess</code><br />
<code><br />
	Order Allow,Deny<br />
	Deny from all<br />
        &lt;Files ~ ".(css|jpe?g|png|gif|js|html)$"&gt;<br />
        	Allow from all<br />
	&lt;/Files&gt;<br />
</code><br />
This will allow the static html files in the cache to be downloaded, now I didn&#8217;t get to the bottom of this, but I believe that the wp-cahe php files might be called directly, so if you are having problems see if this resolves it&#8230;<br />
<code><br />
&lt;Files ~ "wp-cache"&gt;<br />
		Allow from all<br />
&lt;/Files&gt;<br />
</code><br />
This will open up the wp-cache files as if you hadn&#8217;t installed the .htaccess in the 1st place &#8211; you have been warned, now you evaluate the risk <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you are using the <strong>google site map generator</strong>, then you can create a .htaccess file in<code>/var/www/html/wp-content/plugins/google-sitemap-generator</code> to allow the xml style sheet through:<br />
<code><br />
&lt;Files "sitemap.xsl"&gt;<br />
                Allow from all<br />
 &lt;/Files&gt;<br />
</code></p>
<p>The final one that might interest people is <strong>Share This</strong>, you&#8217;ll need at .htaccess in <code>/var/www/html/wp-content/plugins/share-this</code> with:<br />
<code><br />
&lt;Files "share-this.php"&gt;<br />
                Allow from all<br />
&lt;/Files&gt;<br />
</code></p>
<p>As you might have gathered this does involve creating a lot of .htaccess files, which is a bit of a pain, if you&#8217;re fortunate enough to run your own web server and have access to your httpd.conf you can actually keep these all in one file, keeping with the last <em>share this</em> example, instead of creating a .htaccess in <code>/var/www/html/wp-content/plugins/share-this</code> you can edit your httpd.conf and just wrap the code in <code>&lt;Directory&gt;</code>, so you could actually paste this:<br />
<code>&lt;Directory "/var/www/html/wp-content/plugins/share-this/"&gt;</code><br />
<code><br />
	&lt;Files "share-this.php"&gt;<br />
                Allow from all<br />
        &lt;/Files&gt;<br />
&lt;/Directory&gt;<br />
</code><br />
I hope this all makes sense, and is of some use to someone&#8230;good luck to the blogsecurity team, if you need any help feel free <a href="http://www.linickx.com/contact">to shout</a> <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/342/trouble-shooting-the-wordpress-security-white-paper/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>HTTP Compression on Redhat / CentOS / Fedora</title>
		<link>http://www.linickx.com/268/http-compression-on-redhat-centos-fedora</link>
		<comments>http://www.linickx.com/268/http-compression-on-redhat-centos-fedora#comments</comments>
		<pubDate>Thu, 21 Jun 2007 16:37:21 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[redhat]]></category>

		<guid isPermaLink="false">http://www.linickx.com/blog/archives/268/http-compression-on-redhat-centos-fedora/</guid>
		<description><![CDATA[I was doing some testing on my server the other day, and realised that http compression within apache (httpd) was not enabled by default. Further digging showed me that mod_defate was what I needed, and infact it was installed by &#8230; <a href="http://www.linickx.com/268/http-compression-on-redhat-centos-fedora">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was doing some <a href="http://www.port80software.com/products/zipenable/compresscheck">testing</a> on my server the other day, and realised that http compression within apache (httpd) was not enabled by default. Further digging showed me that <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">mod_defate</a> was what I needed, and infact it was installed by default on my CentOS box.</p>
<p>How to enable mod_default on Centos: Create <strong>/etc/httpd/conf.d/deflate.conf</strong> with the following contents</p>
<pre>
     # Insert filter
     SetOutputFilter DEFLATE

     # Netscape 4.x has some problems...
     BrowserMatch ^Mozilla/4 gzip-only-text/html

     # Netscape 4.06-4.08 have some more problems
     BrowserMatch ^Mozilla/4.0[678] no-gzip

     # MSIE masquerades as Netscape, but it is fine
     BrowserMatch bMSIE !no-gzip !gzip-only-text/html

     # Don't compress images
     SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary

        # Don't compress already compressed stuff !
        SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
        SetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary

     # Make sure proxies don't deliver the wrong content
     Header append Vary User-Agent env=!dont-vary

        # Log Stuff !
#        DeflateFilterNote Input input_info
#        DeflateFilterNote Output output_info
#        DeflateFilterNote Ratio ratio_info
#        LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
#        CustomLog /var/log/httpd/deflate_log deflate</pre>
<p>restart httpd (<strong>/etc/init.d/httpd restart</strong>) and your done <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>References:</p>
<ul>
<li> <a href="http://www.port80software.com/products/zipenable/compresscheck">port80software.com &#8211; compresscheck</a></li>
<li> <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">apache.org</a></li>
<li> <a href="http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch20_:_The_Apache_Web_Server">Linux Home Networking</a></li>
<li> <a href="http://www.howtoforge.org/apache2_mod_deflate">How To Forge</a></li>
</ul>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/268/http-compression-on-redhat-centos-fedora/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Service Recovery Scripts &amp; Error Page Tips.</title>
		<link>http://www.linickx.com/267/service-recovery-scripts-error-page-tips</link>
		<comments>http://www.linickx.com/267/service-recovery-scripts-error-page-tips#comments</comments>
		<pubDate>Tue, 06 Mar 2007 13:32:55 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Enterprise Linux]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[recovery]]></category>

		<guid isPermaLink="false">http://www.linickx.com/blog/archives/267/service-recovery-scripts-error-page-tips/</guid>
		<description><![CDATA[A couple of weeks ago, I was proper ill with flu; the problem with looking after your own server is that only you can fix it &#8211; it&#8217;s well and good having monitoring systems (nagios) telling you about faults, but &#8230; <a href="http://www.linickx.com/267/service-recovery-scripts-error-page-tips">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago, I was proper ill with flu; the problem with looking after your own server is that only you can fix it &#8211; it&#8217;s well and good having monitoring systems (<em>nagios</em>) telling you about faults, but if you can&#8217;t read or see the alerts the fault won&#8217;t get resolved.</p>
<p>During this time I was ill, for an unknown reason the mySQL process on my server died, as such my website (<em>and others I look after</em>) were down for 8 hours. The fix was simple, one command, restart the service and normal service was resumed (<em>excuse the pun</em>).</p>
<p>This led to me to the conclusion that there must be a way to get the server to fix it&#8217;s self. after all, why do a job when you can get a computer to do it for you !  Fortunately I had a <abbr title="short moment of genuis">light bulb moment</abbr> and realised that I could use the init scripts that are provided by redhat, the below code will restart apache (<em>httpd</em>) and mySQL on a redhat based system in the event that the service was not stopped cleanly. (<em>In-fact this config has only be tested on CentOS, your mileage may vary on anything else</em>)</p>
<pre>
#!/bin/bash

# taken from redhast default scripts - /etc/rc.d/init.d/functions

# Set up a default search path.
PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
export PATH

status() {
        local base=${1##*/}
        local pid

        # Test syntax.
        if [ "$#" = 0 ] ; then
                echo $"Usage: status {program}"
                return 1
        fi

        # First try "pidof"
        pid=`pidof -o $$ -o $PPID -o %PPID -x $1 ||
             pidof -o $$ -o $PPID -o %PPID -x ${base}`
        if [ -n "$pid" ]; then
# Uncomment this if you want OK messages
#               echo $"${base} (pid $pid) is running..."
                return 0
        fi

        # Next try "/var/run/*.pid" files
        if [ -f /var/run/${base}.pid ] ; then
                read pid &lt; /var/run/${base}.pid
                if [ -n "$pid" ]; then
                        echo $"${base} dead but pid file exists"
                        /etc/init.d/${base} restart
                        return 1
                fi
        fi
        # See if /var/lock/subsys/${base} exists
        if [ -f /var/lock/subsys/${base} ]; then
                echo $"${base} dead but subsys locked"
                /etc/init.d/${base} restart
                return 2
        fi
        echo $"${base} is stopped"
        return 3
}

# found in /etc/init.d/httpd
httpd=${HTTPD-/usr/sbin/httpd}

status mysqld
status $httpd</pre>
<p>If you save this, as <strong>/etc/cron.hourly/auto_recovery.sh</strong> , then do <strong>chmod +x /etc/cron.hourly/auto_recovery.sh</strong> , assuming you&#8217;ve not changed the default cron setup, every hour mySQL &amp; httpd will be checked, if they have died the&#8217;ll be restarted and root will get an e-mail about what happened.</p>
<p>Cool eh !</p>
<p><strong>A final finishing touch:</strong> I wanted to change the default &#8220;Database Down&#8221; error messages on my two most popular applications.</p>
<ul>
<li> <a href="http://allforces.com/2006/06/18/custom-wordpress-errors/">Melvin Rivera has written a tutorial on how to customize the wordpress error page</a>, note that it involves editing a file outside of wp-content, that means you&#8217;ll have to re-do this &#8220;hack&#8221; every time you upgrade wordpress.</li>
<li> PHPBB: Setting a custom error page on that is really easy, first create a php page displaying your message. Then at the bottom of /path/to/phpbb-install/includes/db.php you&#8217;ll see
<pre>
// Make the database connection.
$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false);
if(!$db-&gt;db_connect_id)
{
message_die(CRITICAL_ERROR, "Could not connect to the database");
}</pre>
<p>change it to</p>
<pre>
 // Make the database connection.
$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false);
if(!$db-&gt;db_connect_id)
{
 include("/path/to/my-custom-error-page.php");
        die();
}</pre>
</li>
</ul>
<p>Now if you database dies, for the time it&#8217;s down (<em>before cron fixes it</em>) wordpress &amp; phpbb sites would get a much prettier error message. Obviously there&#8217;s no solution for apache as there&#8217;s nothing to serve the pages, but hopefully this kind of thing doesn&#8217;t happen to often <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/267/service-recovery-scripts-error-page-tips/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

