<?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>Muffin Research Labs &#187; Hosting</title>
	<atom:link href="http://muffinresearch.co.uk/archives/category/hosting/feed/" rel="self" type="application/rss+xml" />
	<link>http://muffinresearch.co.uk</link>
	<description>the personal blog of Stuart Colville covering modern web development techniques and best practices</description>
	<lastBuildDate>Thu, 26 Jan 2012 00:14:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Avoiding the use of .htaccess for performance</title>
		<link>http://muffinresearch.co.uk/archives/2008/04/07/avoiding-the-use-of-htaccess-for-performance/</link>
		<comments>http://muffinresearch.co.uk/archives/2008/04/07/avoiding-the-use-of-htaccess-for-performance/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 14:16:39 +0000</pubDate>
		<dc:creator>Stuart Colville</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2008/04/07/avoiding-the-use-of-htaccess-for-performance/</guid>
		<description><![CDATA[.htaccess files are often used because they allow quick changes to the apache web server configuration and don&#8217;t require apache to be restarted. However with this flexibility comes a number of performance implications and as a result they should be avoided unless you have absolutely no other way to put configuration changes into effect e.g: [...]]]></description>
			<content:encoded><![CDATA[<p>.htaccess files are often used because they allow quick changes to the apache web server configuration and don&#8217;t require apache to be restarted. However with this flexibility comes a number of performance implications and as a result they should be avoided unless you have absolutely no other way to put configuration changes into effect e.g: shared hosting where you are unlikely to have access to httpd.conf.</p>
<h3>The .htaccess performance hit</h3>
<p>If .htaccess files <em>are</em> allowed (through the AllowOverride directive) then apache will look for .htaccess files on every request. In addition apache has to look up the directory tree to see if there are further .htaccess files in locations above the location the file is requested from so that it can tell which directives have precedence. For example: if you request a file from <code>/foo/bar</code>, apache has to look for <code>/foo/bar/.htaccess</code>, <code>/foo/.htaccess</code> and <code>/.htaccess</code> and that&#8217;s even if there are no .htaccess files present in any of those locations! Once a .htaccess file is found it has to be parsed and don&#8217;t forget all of this has to happen for every request!!</p>
<p>As there&#8217;s nothing in a .htaccess file that can&#8217;t be achieved in your httpd.conf (or files included by httpd.conf) it makes sense to move existing .htaccess rules into your apache conf using a Directory or Location directive as appropriate.</p>
<h3>Restarting apache without dropping users</h3>
<p>One other reason why .htaccess are seen as a convenience is that they don&#8217;t require apache to be restarted after configuration changes. However if you restart apache with &#8220;apachectl graceful&#8221; you only force the parent process to re-read the apache configuration files and the children to restart when they&#8217;re not doing anything and as a result no end users are suddenly dropped.</p>
<h3>Finding all of the .htaccess files on your system</h3>
<p>Simply drop on to your terminal and change directory to where you site files are located and run: <code>find . -name *.htaccess -print</code>. This should provide output that shows the location of all of the .htaccess files so you can go through one by one and move them to into httpd.conf or a file included by httpd.conf.</p>
]]></content:encoded>
			<wfw:commentRss>http://muffinresearch.co.uk/archives/2008/04/07/avoiding-the-use-of-htaccess-for-performance/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Moved server and fixed WordPress 2.1 Blogrolls</title>
		<link>http://muffinresearch.co.uk/archives/2007/02/06/moved-server-and-fixed-wordpress-21-blogrolls/</link>
		<comments>http://muffinresearch.co.uk/archives/2007/02/06/moved-server-and-fixed-wordpress-21-blogrolls/#comments</comments>
		<pubDate>Tue, 06 Feb 2007 15:11:55 +0000</pubDate>
		<dc:creator>Stuart Colville</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Muffin Research Labs]]></category>

		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2007/02/06/moved-server-and-fixed-wordpress-21-blogrolls/</guid>
		<description><![CDATA[If you&#8217;re reading this the DNS has successfully propagated. At the same time as updating the site I took the opportunity to upgrade to WordPress 2.1. Aside from needing to change the blogroll categories and update the function in the template all went fairly well. The blogroll has been merged with the other categories so [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re reading this the DNS has successfully propagated. </p>
<p>At the same time as updating the site I took the opportunity to upgrade to WordPress 2.1. Aside from needing to change the blogroll categories and update the function in the template all went fairly well.</p>
<p>The blogroll has been merged with the other categories so if you were referencing your blogrolls and link list via id it&#8217;s likely that your ids will have changed. The easiest way to find out what&#8217;s going on is to go and look at the blogroll maintainence screens and look at the category links have changed to.</p>
<p>The other issue for me is that the wp_get_links function seems to have changed causing the links to be output with a load of brs etc. To fix this I looked at the code and found that the function get_links() did what I wanted. Thus I changed from this:</p>
<pre><code>&lt;?php wp_get_links(4); ?&gt;</code></pre>
<p>to: </p>
<pre><code>&lt;?php get_links(37,'&lt;li&gt;','&lt;/li&gt;','',false,'name',false,false); ?></code></pre>
<p>The difference being I am now specifying the markup before and after the links and whether to display the descriptions or not.</p>
]]></content:encoded>
			<wfw:commentRss>http://muffinresearch.co.uk/archives/2007/02/06/moved-server-and-fixed-wordpress-21-blogrolls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Media Temple Grid Server</title>
		<link>http://muffinresearch.co.uk/archives/2007/01/30/media-temple-grid-server/</link>
		<comments>http://muffinresearch.co.uk/archives/2007/01/30/media-temple-grid-server/#comments</comments>
		<pubDate>Tue, 30 Jan 2007 09:00:11 +0000</pubDate>
		<dc:creator>Stuart Colville</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Muffin Research Labs]]></category>

		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2007/01/30/media-temple-grid-server/</guid>
		<description><![CDATA[I&#8217;ve been following with interest the progress of Media Temple Grid Server, as I am certainly interested in a hosting supplier that can give some level of redundancy and thus provide a seamless continuity of service should specific servers experience a hardware failure. Currently I&#8217;m on a dedicated server and the problem with that is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been following with interest the progress of <a href="http://www.mediatemple.net/webhosting/gs/">Media Temple Grid Server</a>, as I am certainly interested in a hosting supplier that can give some level of redundancy and thus provide a seamless continuity of service should specific servers experience a hardware failure. </p>
<p>Currently I&#8217;m on a dedicated server and the problem with that is that should the server experience some kind of major software or hardware failure then it&#8217;s up to me to either fix it or restore it which is fine but you will have inevitable downtime.</p>
<p>As my server is up for renewal very soon I am wondering, should I try the Grid Server or look at the <a href="http://www.mediatemple.net/webhosting/dv/">Virtual Dedicated service</a>. The specs of the Grid server are obviously tempting, but since launch it would seem they&#8217;ve had a few problems with their service. I&#8217;ve noticed at least two blogs that are hosted on the Grid Server but have been unavailable due to MySQL problems. </p>
<p>The only other issue I have is that I am seriously evaluating <a href="http://www.djangoproject.com/">Django</a> and as yet there is no support for Django on the Grid Server, though hopefully at some point this would be added. </p>
<p>So what are your views, is the Grid Server too good to be true or the best thing to ever happen to web hosting?</p>
]]></content:encoded>
			<wfw:commentRss>http://muffinresearch.co.uk/archives/2007/01/30/media-temple-grid-server/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Redirecting subdomains to directories in apache.</title>
		<link>http://muffinresearch.co.uk/archives/2006/08/20/redirecting-subdomains-to-directories-in-apache/</link>
		<comments>http://muffinresearch.co.uk/archives/2006/08/20/redirecting-subdomains-to-directories-in-apache/#comments</comments>
		<pubDate>Sun, 20 Aug 2006 01:26:56 +0000</pubDate>
		<dc:creator>Stuart Colville</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Linux/Unix]]></category>

		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/08/20/redirecting-subdomains-to-directories-in-apache/</guid>
		<description><![CDATA[Note: It is likely you will need root access to carry out apache config alterations 12-02-07: Fixed mistake in the directory comparison line. If you want to be able to redirect blah.domain.com to domain.com/blah/ so that blah.domain.com is shown in the address bar here&#8217;s a quick and dirty how to: First off if you want [...]]]></description>
			<content:encoded><![CDATA[<p class="update">Note: It is likely you will need root access to carry out apache config alterations</p>
<p class="update">12-02-07: Fixed mistake in the directory comparison line.</p>
<p>If you want to be able to redirect blah.domain.com to domain.com/blah/ so that blah.domain.com is shown in the address bar here&#8217;s a quick and dirty how to:</p>
<p>First off if you want any subdomain to be able to be redirected first you need to set-up your DNS correctly. In my case this was as simple as going to the  people that host my domain and adding an A record with the wildcard * that pointed to my server&#8217;s ip address. Bear in mind your DNS settings may take a while to work so be patient. Before you proceed you should check that anything.domain.com resolves to the ip address of your server. You can check this by running:</p>
<pre><code>ping iloveapache.domain.com</code></pre>
<p>This should respond with something like this:</p>
<pre><code>[root@cheekymonkey conf]# ping iloveapache.domain.com
PING iloveapache.domain.com (62.193.xxx.xxx) 56(84) bytes of data.
64 bytes from my.serverhostame.com (62.193.xxx.xxx): icmp_seq=0 ttl=64 time=0.058 ms
64 bytes from my.serverhostame.com (62.193.xxx.xxx): icmp_seq=1 ttl=64 time=0.040 ms
64 bytes from my.serverhostame.com (62.193.xxx.xxx): icmp_seq=2 ttl=64 time=0.071 ms
64 bytes from my.serverhostame.com (62.193.xxx.xxx): icmp_seq=3 ttl=64 time=0.028 ms</code></pre>
<p>The next step is to set-up the virtual host to respond to the wildcard subdomains. In the case of plesk you have to set-up a vhost.conf file but on any other apache installation you can just edit httpd.conf and look for the &lt;VirtualHost&gt; that corresponds to your site. If you are using Plesk you will need to ssh in to your server and create a vhost.conf file if it doesn&#8217;t already exist here where &lt;domain.com&gt; is your domain:</p>
<pre><code>/var/www/vhosts/&lt;domain.com&gt;/conf/vhost.conf</code></pre>
<p>Open that file with the command line editor of your choice and add the following directives:</p>
<pre><code>ServerAlias *.domain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.* [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com
RewriteCond /var/www/vhosts/domain.com/httpdocs/%1 -d
RewriteRule ^(.*) /%1/$1 [L]</code></pre>
<p>Substitute domain.com for your domain. Now here&#8217;s a quick walkthrough how these rules work. The first line <code>ServerAlias *.domain.com</code> tells apache to accept anysubdomain.domain.com. </p>
<p>Next the rewrite rules work as follows: </p>
<ol>
<li>The first line of mod_rewrite <code>!^www.*</code> only matches urls that don&#8217;t begin with www. You don&#8217;t want to redirect www.domain.com to www.domain.com/www/ do you? <em>Note: you could add additional lines like these to prevent re-writing other subdomains like secure.domain.com if that should not be redirected to domain.com/secure/</em></li>
<li>The second line <code>^([^\.]+)\.*$</code> captures into a backreference anything that doesn&#8217;t have a period e.g. the subdomain. The plus makes sure that there is at least one character that matches.</li>
<li>The next condition checked is that  the directory captured into the backreference does actually exist hence the -d.</li>
<li>This last line <code>^(.*) /%1/$1 [L]</code> takes the requested path and dumps it into a back reference and then rewrites it to point to the a directory (the subdomain backreference captured in the Rewrite conditions above) . In other words %1 is the subdomain backreference and $1 is the path backreference (that captured by .*). The important thing to rember is you can refer to backreferences in rewriteCond lines with % and backreferences in rewriteRules with $. Lastly the [L] (last) means doen&#8217;t further rewrite this URL. <em>Note: You might want to leave this out if you are doing any subsequent rewrites, be sure to test what you have set-up thoroughly!!!</em></li>
</ol>
<p>Now once you have made those changes if you are running plesk you will need to apply your vhost.conf changes with the following command: </p>
<pre><code>/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=&lt;domain.com&gt;</code></pre>
<p>And then whether are using Plesk or not you need to restart apache e.g:</p>
<pre><code>service httpd restart</code></pre>
<p>Now you should find that if you set-up a directory called &#8220;meegan&#8221; with a valid index.html file in it. meegan.domain.com should find that file. The job&#8217;s a good&#8217;un.</p>
]]></content:encoded>
			<wfw:commentRss>http://muffinresearch.co.uk/archives/2006/08/20/redirecting-subdomains-to-directories-in-apache/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
	</channel>
</rss>

