<?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>AnyHosting &#187; web hosting</title>
	<atom:link href="http://anyhosting.com/blog/category/web-hosting/feed/" rel="self" type="application/rss+xml" />
	<link>http://anyhosting.com/blog</link>
	<description>It&#039;s all about the web</description>
	<lastBuildDate>Sat, 10 Apr 2010 03:35:23 +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>limiting I/O and CPU on Linux with nice and ionice</title>
		<link>http://anyhosting.com/blog/2010/03/18/limiting-io-and-cpu-on-linux-with-nice-and-ionice/</link>
		<comments>http://anyhosting.com/blog/2010/03/18/limiting-io-and-cpu-on-linux-with-nice-and-ionice/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 21:03:47 +0000</pubDate>
		<dc:creator>rhelmer</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[web hosting]]></category>

		<guid isPermaLink="false">http://anyhosting.com/blog/?p=119</guid>
		<description><![CDATA[In one of my earlier posts about web hosting with Ubuntu Server, I left the startup script for the user-owned Apache instances as an exercise for the reader; the gist of it is to create a script in /etc/init.d/ (based on the &#8220;skeleton&#8221; file in that directory). The meat of it is something like: for [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my <a href="http://anyhosting.com/blog/2009/10/03/secure-shared-web-hosting-on-ubuntu-server-part-2/">earlier posts</a> about web hosting with Ubuntu Server, I left the startup script for the user-owned Apache instances as an exercise for the reader; the gist of it is to create a script in /etc/init.d/ (based on the &#8220;skeleton&#8221; file in that directory). The meat of it is something like:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">for</span> d <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/*</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; apache2 <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$d</span><span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>apache2.conf <span style="color: #660033;">-k</span> start<br />
<span style="color: #000000; font-weight: bold;">done</span></div></div>
<p>This iterates over the directories in /var/www and runs Apache for each one, each with it&#8217;s own config file.</p>
<p>One interesting thing you can do here is make the user&#8217;s Apache process &#8220;nice&#8221; to fellow processes:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">for</span> d <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/*</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">nice</span> <span style="color: #660033;">-10</span> ionice <span style="color: #660033;">-c3</span> apache2 <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$d</span><span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>apache2.conf <span style="color: #660033;">-k</span> start<br />
<span style="color: #000000; font-weight: bold;">done</span></div></div>
<p>&#8220;<a href="http://en.wikipedia.org/wiki/Nice_%28Unix%29">nice</a>&#8221; changes priority for tasks waiting on CPU, while &#8220;<a href="http://linux.die.net/man/1/ionice">ionice</a>&#8221; changes the priority for tasks waiting on IO (for example disk reads and writes).</p>
<p>This can keep one busy or misbehaving server from interrupting other sites or important background tasks; alternatively, you could set one site to be highest-priority.</p>
]]></content:encoded>
			<wfw:commentRss>http://anyhosting.com/blog/2010/03/18/limiting-io-and-cpu-on-linux-with-nice-and-ionice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>new open-source web hosting control panel</title>
		<link>http://anyhosting.com/blog/2010/03/18/new-open-source-web-hosting-control-panel/</link>
		<comments>http://anyhosting.com/blog/2010/03/18/new-open-source-web-hosting-control-panel/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 17:40:06 +0000</pubDate>
		<dc:creator>rhelmer</dc:creator>
				<category><![CDATA[customers]]></category>
		<category><![CDATA[web hosting]]></category>
		<category><![CDATA[web services]]></category>

		<guid isPermaLink="false">http://anyhosting.com/blog/?p=122</guid>
		<description><![CDATA[I have not found much on this subject since my last post, so instead of continuing to wait for someone else to do it I have started working on a new open-source web hosting control panel (alternative to Plesk, cPanel, etc). All the work is in my local repo, but I will be pushing to [...]]]></description>
			<content:encoded><![CDATA[<p>I have not found much on this subject since <a href="http://anyhosting.com/blog/2009/06/18/web-hosting-control-panels/">my last post</a>, so instead of continuing to wait for someone else to do it I have started working on a new open-source web hosting control panel (alternative to Plesk, cPanel, etc).</p>
<p>All the work is in my local repo, but I will be pushing to <a href="http://github.com/rhelmer/anyhosting_control">github</a> as milestones are hit.</p>
<p>I want to get the basics right, and not worry right now about competing feature-for-feature with the big guys:</p>
<ul>
<li>basic file management</li>
<li>configure apache, stop/start server</li>
<li>allow (and enthusiastically support!) plugins. I am using django/python, should be no problem.</li>
</ul>
<p>That&#8217;s for the user-facing side, the backend takes care of scaling across multiple hosts (on-demand scaling), billing, activating/deactivating accounts, you get the idea.</p>
<p>What do you want to see in a free, open-source web hosting control panel? Leave a comment or feel free to email me &#8211; <a href="mailto:robert@roberthelmer.com">rhelmer@anyhosting.com</a> &#8211; Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://anyhosting.com/blog/2010/03/18/new-open-source-web-hosting-control-panel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>monitoring ubuntu web servers with nagios3</title>
		<link>http://anyhosting.com/blog/2009/10/17/monitoring-ubuntu-web-servers-with-nagios3/</link>
		<comments>http://anyhosting.com/blog/2009/10/17/monitoring-ubuntu-web-servers-with-nagios3/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 01:41:28 +0000</pubDate>
		<dc:creator>rhelmer</dc:creator>
				<category><![CDATA[monitoring]]></category>
		<category><![CDATA[web hosting]]></category>

		<guid isPermaLink="false">http://anyhosting.com/blog/?p=114</guid>
		<description><![CDATA[I have chosen Nagios to keep track of the anyhosting.com network. There are many alternatives (some I have explored and some not yet), what I like about Nagios: I&#8217;ve been using it for a long time; familiarity very simple/powerful plugin system tons of users, so lots of examples and plugins already available Nagios version 3 [...]]]></description>
			<content:encoded><![CDATA[<p>I have chosen <a href="http://nagios.org">Nagios</a> to keep track of the <a href="http://anyhosting.com">anyhosting.com</a> network. There are <a href="http://www.zabbix.com/">many</a> <a href="http://mmonit.com/monit/">alternatives</a> (some I have explored and some not yet), what I like about Nagios:</p>
<ul>
<li>I&#8217;ve been using it for a long time; familiarity</li>
<li>very simple/powerful plugin system</li>
<li>tons of users, so lots of examples and plugins already available</li>
</ul>
<p>Nagios version 3 is provided in the Ubuntu repositories, and is quite simple to install:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">root@admin:~# </span><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> nagios3</div></div>
<p>The default config comes set up to monitor a set of services on localhost; I don&#8217;t really like the default Ubuntu/Debian setup of having one config file per host/service/etc, so on the master I&#8217;ve replaced the config file structure:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root<span style="color: #000000; font-weight: bold;">@</span>admin:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nagios3<span style="color: #000000; font-weight: bold;">/</span>conf.d<span style="color: #666666; font-style: italic;"># cd /etc/nagios3/conf.d/</span><br />
root<span style="color: #000000; font-weight: bold;">@</span>admin:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nagios3<span style="color: #000000; font-weight: bold;">/</span>conf.d<span style="color: #666666; font-style: italic;"># ls</span><br />
contacts.cfg  extinfo.cfg  groups.cfg  hosts.cfg  services.cfg  <br />
timeperiods.cfg</div></div>
<p>groups.conf contains the set of server types that I care about:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># A list of your web servers<br />
define hostgroup {<br />
&nbsp; hostgroup_name  http-servers<br />
&nbsp; alias           HTTP servers<br />
&nbsp; members         localhost<br />
}<br />
<br />
# A list of your mysql servers<br />
define hostgroup {<br />
&nbsp; hostgroup_name  mysql-servers<br />
&nbsp; alias           MySQL servers<br />
}<br />
<br />
# A list of your VHosts<br />
define hostgroup {<br />
&nbsp; hostgroup_name  http-vhosts<br />
&nbsp; alias           Virtual Host HTTP servers<br />
}</div></div>
<p>Note that the &#8220;http-servers&#8221; can define &#8220;members&#8221; (localhost in this case), however in general I do not add members in this file but instead in the hosts.cfg:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">define host {<br />
&nbsp; host_name   anyhosting1<br />
&nbsp; address     1.2.3.4<br />
&nbsp; use         generic-host<br />
&nbsp; hostgroups  http-servers<br />
}<br />
<br />
define host {<br />
&nbsp; host_name   example.com<br />
&nbsp; address     1.2.3.4<br />
&nbsp; use         generic-host<br />
&nbsp; hostgroups  http-vhosts<br />
}</div></div>
<p>Note the &#8220;hostgroups&#8221; line; anyhosting1 is the physical server (this monitor is really checking on the <a href="http://anyhosting.com/blog/2009/10/01/secure-shared-web-hosting-on-ubuntu-server-part-1/">reverse proxy</a>), and example.com is a vhost (which is really proxying to a user running Apache for the &#8220;example.com&#8221; domain). These two checks make sure that the whole system is working and proxying correctly.</p>
<p>Finally, services.cfg brings it all together by defining which groups should run which services:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># check that web services are running<br />
define service {<br />
&nbsp; hostgroup_name &nbsp; &nbsp; &nbsp; &nbsp; http-servers<br />
&nbsp; service_description &nbsp; &nbsp;HTTP<br />
&nbsp; check_command &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;check_http<br />
&nbsp; use &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;generic-service<br />
&nbsp; notification_interval &nbsp;0 # set &gt; 0 if you want to be renotified<br />
}<br />
<br />
define service {<br />
&nbsp; hostgroup_name &nbsp; &nbsp; &nbsp; &nbsp; http-vhosts<br />
&nbsp; service_description &nbsp; &nbsp;Virtual Host HTTP<br />
&nbsp; check_command &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;check_httpname<br />
&nbsp; use &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;generic-service<br />
&nbsp; notification_interval &nbsp;0 # set &gt; 0 if you want to be renotified<br />
}</div></div>
<p>The Ubuntu nagios-plugins package (which by default is installed along with the nagios3 package) contains plugins that can intelligently check MySQL databases, disk space, load average, etc. By default these only work on the local machine, but these can be made to run on remote machines by installing the nagios-nrpe-server package. I will cover this further in a future blog post.</p>
]]></content:encoded>
			<wfw:commentRss>http://anyhosting.com/blog/2009/10/17/monitoring-ubuntu-web-servers-with-nagios3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Secure shared web hosting on Ubuntu Server, part 3</title>
		<link>http://anyhosting.com/blog/2009/10/04/secure-shared-web-hosting-on-ubuntu-server-part-3/</link>
		<comments>http://anyhosting.com/blog/2009/10/04/secure-shared-web-hosting-on-ubuntu-server-part-3/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 07:26:29 +0000</pubDate>
		<dc:creator>rhelmer</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[web hosting]]></category>

		<guid isPermaLink="false">http://anyhosting.com/blog/?p=87</guid>
		<description><![CDATA[In this third and final installment, we&#8217;ll look at alternatives and future directions for shared web hosting on Ubuntu Server (go back in time to part 1 and part 2 in case you missed them). Our original goal was to provide websites for multiple users on one host, keeping them compartmentalized from each other, and [...]]]></description>
			<content:encoded><![CDATA[<p>In this third and final installment, we&#8217;ll look at alternatives and future directions for shared web hosting on Ubuntu Server (go back in time to <a href="http://anyhosting.com/blog/2009/10/03/secure-shared-web-hosting-on-ubuntu-server-part-1/">part 1</a> and <a href="http://anyhosting.com/blog/2009/10/03/secure-shared-web-hosting-on-ubuntu-server-part-2/">part 2</a> in case you missed them).</p>
<p>Our original goal was to provide websites for multiple users on one host, keeping them compartmentalized from each other, and to restrict break-ins. We chose to do reverse proxying using Apache, with separate Apache instances for each user, using mod_chroot.</p>
<p>Pros:</p>
<ul>
<li>user cannot see or read/write other users files, even on the same shared server, or use any system resources not explicitly provided in the chroot.</li>
<li>mod_chroot is way less work than building a full chroot jail, and is potentially safer since you don&#8217;t have to provide system libraries or binaries, reducing your attack surface</li>
</ul>
<p>Cons:</p>
<ul>
<li>multiple Apache instances consume more memory, and need special configuration and startup scripts</li>
<li>it is possible to <a href="http://kerneltrap.org/Linux/Abusing_chroot">break out of a chroot</a>. It is especially easy if the attacker can somehow get elevated to root (e.g. local security exploit)</li>
</ul>
<p>Further investigation:</p>
<ul>
<li> apache-mpm-itk &#8211; This runs Apache child processes as a separate user per vhost. Cannot be combined with mod_chroot, unfortunately, and has some serious drawbacks (see the section on <a href="http://mpm-itk.sesse.net/">Quirks and Warnings</a>).</li>
</ul>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Solaris_Containers">solaris containers</a>, <a href="http://en.wikipedia.org/wiki/FreeBSD_jail">freebsd jail</a>, <a href="http://en.wikipedia.org/wiki/Linux-VServer">linux vserver</a> &#8211; These are real jails; less overhead than <a href="http://en.wikipedia.org/wiki/Virtual_machine">Virtual Machines</a>, but provide more protection than a chroot. These tend to be significantly more complex to set up than something like mod_chroot, but are by design a lot harder to escape than a chroot.</li>
</ul>
<p>There are some other interesting security-related modules such as <a href="http://www.zdziarski.com/projects/mod_evasive/">mod_evasive</a> that I am checking into further, which may mitigate some of the &#8220;cons&#8221; above.</p>
<p>Hopefully this will be useful to someone, however <a href="http://www.schneier.com/book-sandl-pref.html">security is a process, not a product</a>, and you should not rely solely on something like mod_chroot, but it can be a useful tool as part of an overall strategy that includes monitoring, intrusion detection, and regular security updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://anyhosting.com/blog/2009/10/04/secure-shared-web-hosting-on-ubuntu-server-part-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Secure shared web hosting on Ubuntu Server, part 2</title>
		<link>http://anyhosting.com/blog/2009/10/03/secure-shared-web-hosting-on-ubuntu-server-part-2/</link>
		<comments>http://anyhosting.com/blog/2009/10/03/secure-shared-web-hosting-on-ubuntu-server-part-2/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 14:10:13 +0000</pubDate>
		<dc:creator>rhelmer</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[web hosting]]></category>

		<guid isPermaLink="false">http://anyhosting.com/blog/?p=70</guid>
		<description><![CDATA[Continuing from part 1, here are the nuts and bolts: Ubuntu 8.10 Server root@theo:~# apt-get install apache2 libapache2-mod-chroot For each domain, create a virtual host config like /etc/apache2/sites-available/example.com: &#60;VirtualHost *:80&#62; &#160; ServerAdmin webmaster@example.com &#160; ServerName example.com &#160; ServerAlias www.example.com &#160; ProxyPass / http://localhost:8080/ &#160; ProxyPassReverse / http://localhost:8080/ &#160; &#60;Proxy *&#62; &#160; &#160; Allow from all [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing from <a href="http://anyhosting.com/blog/2009/10/01/secure-shared-web-hosting-on-ubuntu-server-part-1/">part 1</a>, here are the nuts and bolts:</p>
<p>Ubuntu 8.10 Server</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">root@theo:~# </span><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> apache2 libapache2-mod-chroot</div></div>
<p>For each domain, create a virtual host config like /etc/apache2/sites-available/example.com:</p>
<div class="codecolorer-container apache default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;<br />
&nbsp; <span style="color: #00007f;">ServerAdmin</span> webmaster@example.com<br />
&nbsp; <span style="color: #00007f;">ServerName</span> example.com<br />
&nbsp; <span style="color: #00007f;">ServerAlias</span> www.example.com<br />
&nbsp; <span style="color: #00007f;">ProxyPass</span> / http://localhost:<span style="color: #ff0000;">8080</span>/<br />
&nbsp; <span style="color: #00007f;">ProxyPassReverse</span> / http://localhost:<span style="color: #ff0000;">8080</span>/<br />
&nbsp; &lt;<span style="color: #000000; font-weight:bold;">Proxy</span> *&gt;<br />
&nbsp; &nbsp; <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span><br />
&nbsp; &lt;/<span style="color: #000000; font-weight:bold;">Proxy</span>&gt;<br />
&nbsp; <span style="color: #00007f;">ErrorLog</span> /var/www/example.com/logs/error.log<br />
&nbsp; <span style="color: #adadad; font-style: italic;"># Possible values include: debug, info, notice, warn, error, crit,</span><br />
&nbsp; <span style="color: #adadad; font-style: italic;"># alert, emerg.</span><br />
&nbsp; <span style="color: #00007f;">LogLevel</span> warn<br />
&nbsp; <span style="color: #00007f;">CustomLog</span> /var/www/example.com/logs/access.log combined<br />
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</div></div>
<p>This will be used by the Apache proxy, which is the normal system apache2 running as the default &#8220;www-data&#8221; user. This proxy handles name-based virtual hosts, and proxies the requests to a second process, running at localhost on port 8080.</p>
<p>Note that the logs are configured here and not in the user&#8217;s Apache process, for two reasons:</p>
<ol>
<li>keep logs pristine in the event of a break-in on a user site (for example via a buggy or malicious PHP script)</li>
<li>single system-wide log file analysis process instead of per-user</li>
</ol>
<p>Next, create a user account for each domain:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">root@theo:~# </span><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<br />
<span style="color: #666666;">root@theo:~# </span><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">/</span><br />
root<span style="color: #000000; font-weight: bold;">@</span>theo:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #666666; font-style: italic;"># useradd -d `pwd`/htdocs example.com</span><br />
root<span style="color: #000000; font-weight: bold;">@</span>theo:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #666666; font-style: italic;"># mkdir htdocs logs conf</span><br />
root<span style="color: #000000; font-weight: bold;">@</span>theo:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #666666; font-style: italic;"># chown www-data:www-data logs</span><br />
root<span style="color: #000000; font-weight: bold;">@</span>theo:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #666666; font-style: italic;"># chown example.com:example.com htdocs/</span></div></div>
<p>Create the following in /var/www/example.com/conf/apache2.conf:</p>
<div class="codecolorer-container apache default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00007f;">ServerRoot</span> <span style="color: #7f007f;">&quot;/var/www/example.com/&quot;</span><br />
<span style="color: #00007f;">RequestHeader</span> set Host example.com<br />
<span style="color: #00007f;">LockFile</span> /var/www/example.com/conf/accept.lock<br />
<span style="color: #00007f;">PidFile</span> /conf/apache2.pid<br />
<span style="color: #00007f;">Timeout</span> <span style="color: #ff0000;">300</span><br />
<span style="color: #00007f;">KeepAlive</span> <span style="color: #0000ff;">On</span><br />
<span style="color: #00007f;">MaxKeepAliveRequests</span> <span style="color: #ff0000;">100</span><br />
<span style="color: #00007f;">KeepAliveTimeout</span> <span style="color: #ff0000;">15</span><br />
<span style="color: #00007f;">User</span> example.com<br />
<span style="color: #00007f;">Group</span> example.com<br />
<span style="color: #00007f;">AccessFileName</span> .htaccess<br />
&lt;<span style="color: #000000; font-weight:bold;">Files</span> ~ <span style="color: #7f007f;">&quot;^<span style="color: #000099; font-weight: bold;">\.</span>ht&quot;</span>&gt;<br />
&nbsp; <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span><br />
&nbsp; <span style="color: #00007f;">Deny</span> from <span style="color: #0000ff;">all</span><br />
&lt;/<span style="color: #000000; font-weight:bold;">Files</span>&gt;<br />
<br />
<span style="color: #00007f;">DefaultType</span> text/plain<br />
<span style="color: #00007f;">HostnameLookups</span> <span style="color: #0000ff;">Off</span><br />
<span style="color: #00007f;">ErrorLog</span> /var/www/example.com/conf/error.log<br />
<span style="color: #00007f;">LogLevel</span> warn<br />
<span style="color: #00007f;">LoadFile</span> /lib/libnss_dns.so.2<br />
<span style="color: #00007f;">LoadModule</span> chroot_module /usr/lib/apache2/modules/mod_chroot.so<br />
<span style="color: #00007f;">Include</span> /etc/apache2/mods-enabled/*.load<br />
<span style="color: #00007f;">Include</span> /etc/apache2/mods-enabled/*.conf<br />
<span style="color: #00007f;">Listen</span> <span style="color: #ff0000;">8080</span><br />
<span style="color: #00007f;">DocumentRoot</span> /htdocs<br />
ChrootDir /var/www/example.com/</div></div>
<p>Start up the user Apache process:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">root@theo:~# </span>apache2 <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>apache2.conf <span style="color: #660033;">-k</span> start</div></div>
<p>Everything should now work, but you may notice some problems with PHP or CGI scripts. Generally this means that you will need to make parts of the system available in the chroot; however making copies takes up a lot of space and can quickly get out of date, which is a security risk.</p>
<p>One workaround is to provide needed directories using the &#8220;mount -o bind&#8221; option, which will remount an existing, mounted part of the file hierarchy somewhere else. For example, this will provide all of &#8220;/usr&#8221; inside the chroot:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">root@theo:~# </span><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">/</span>usr<br />
<span style="color: #666666;">root@theo:~# </span><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> <span style="color: #7a0874; font-weight: bold;">bind</span>,ro <span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">/</span>usr</div></div>
<p>PHP sessions require /tmp to exist inside the chroot; there is no benefit to sharing this one, an empty directory is fine.</p>
<p>That&#8217;s pretty much it! Testing, getting startup right etc. is left as an exercise for the reader, since we&#8217;re venturing a bit out of the standard Ubuntu Apache setup. Entries in /etc/fstab and creating an init script to handle user Apache processes is probably the best way to go.</p>
<p>In part 3 we&#8217;ll cover take a more general look at the pros and cons to this setup, as well as possible future directions.</p>
<p><strong>UPDATE link to <a href="http://anyhosting.com/blog/2009/10/04/secure-shared-web-hosting-on-ubuntu-server-part-3/">secure shared hosting on ubuntu server part 3</a></strong></p>
<p><em>EDIT 2009-Oct-03 2:25 PM Pacific &#8211; create dir before cding into it; add read-only (ro) option to usr mount; override &#8220;host&#8221; header in user Apache process</em></p>
<p><em>EDIT 2009-Oct-05 4:41 PM Pacific &#8211; load resolver library and install caching proxy dns server, needed by popular wordpress anti-spam plugin Akismet<br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://anyhosting.com/blog/2009/10/03/secure-shared-web-hosting-on-ubuntu-server-part-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Secure shared web hosting on Ubuntu Server, part 1</title>
		<link>http://anyhosting.com/blog/2009/10/01/secure-shared-web-hosting-on-ubuntu-server-part-1/</link>
		<comments>http://anyhosting.com/blog/2009/10/01/secure-shared-web-hosting-on-ubuntu-server-part-1/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 01:51:07 +0000</pubDate>
		<dc:creator>rhelmer</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[web hosting]]></category>

		<guid isPermaLink="false">http://anyhosting.com/blog/?p=63</guid>
		<description><![CDATA[We&#8217;ve gone over securing a shared hosting setup briefly in the past, but I have made some improvements and simplifications that I&#8217;d like to share. This is part 1 of 3, an introduction to secure shared web hosting on Ubuntu Server. At AnyHosting we want to have multiple users on one shared server, but protect [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve gone over securing a shared hosting setup briefly <a href="http://anyhosting.com/blog/2008/01/14/web-hosting-with-ubuntu-server/">in the past</a>, but I have made some improvements and simplifications that I&#8217;d like to share. This is part 1 of 3, an introduction to secure shared web hosting on Ubuntu Server.</p>
<p>At AnyHosting we want to have multiple users on one shared server, but  protect them from reading or writing each other&#8217;s files (whether  accidental or intentional) and also limit damage caused by a break-in  via a poorly configured PHP script or CGI, or even an Apache exploit.</p>
<p>The solution here is to have each customer run their own Apache process, and do <a href="http://en.wikipedia.org/wiki/Virtual_hosting#Name-based">name-based virtual hosting</a> and forwarding via a <a href="http://en.wikipedia.org/wiki/Reverse_proxy">reverse proxy</a>. The proxy is currently Apache but we are also considering more scalable alternatives such as <a href="http://en.wikipedia.org/wiki/Nginx">nginx</a>. An important thing to note here is that the proxy could be on a separate machine and also combine <a href="http://en.wikipedia.org/wiki/Load_balancing_%28computing%29">load-balancing</a> into the mix, so it provides a lot of flexibility.</p>
<p>The <a href="http://www.faqs.org/docs/securing/chap29sec254.html">classic way to chroot Apache</a> (or any server process) is to copy the server process and all of it&#8217;s dependencies into the chroot jail, which makes keeping the files up to date not just a depressing chore but also a serious security hazard. Also it&#8217;s a ton of work to get right, especially if you want to support server-side scripting like PHP, since it depends on lots of system files and libraries.</p>
<p>Enter <a href="http://core.segfault.pl/~hobbit/mod_chroot/">mod_chroot</a>. This Apache module runs in the user&#8217;s process, and does the chroot system call after opening all the files it needs. The only caveats I&#8217;ve found (besides the ones on the mod_chroot <a href="http://core.segfault.pl/~hobbit/mod_chroot/caveats.html">caveats page</a>) are some files that the Ubuntu PHP install assumes it can reach (such as the MySQL server socket, timezone info, and random number generator). I will cover this in more detail in part 2.</p>
<p><strong>UPDATE link to <a href="http://anyhosting.com/blog/2009/10/03/secure-shared-web-hosting-on-ubuntu-server-part-2/">secure shared hosting on ubuntu server part 2</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://anyhosting.com/blog/2009/10/01/secure-shared-web-hosting-on-ubuntu-server-part-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AnyHosting launched!</title>
		<link>http://anyhosting.com/blog/2009/10/01/anyhosting-launched/</link>
		<comments>http://anyhosting.com/blog/2009/10/01/anyhosting-launched/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 05:25:04 +0000</pubDate>
		<dc:creator>rhelmer</dc:creator>
				<category><![CDATA[web hosting]]></category>

		<guid isPermaLink="false">http://anyhosting.com/blog/?p=58</guid>
		<description><![CDATA[I&#8217;ve just pushed a new front page to anyhosting.com with more details. If you&#8217;re looking for simple, secure and affordable web hosting, check it out! I&#8217;m also working on a series of blog posts and articles about the new setup (reverse proxy, mod_chroot, on ubuntu server).]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just pushed a new front page to <a href="http://anyhosting.com">anyhosting.com</a> with more details.</p>
<p>If you&#8217;re looking for simple, secure and affordable web hosting, check it out!</p>
<p>I&#8217;m also working on a series of blog posts and articles about the new setup (reverse proxy, mod_chroot, on ubuntu server).</p>
]]></content:encoded>
			<wfw:commentRss>http://anyhosting.com/blog/2009/10/01/anyhosting-launched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>web hosting control panels</title>
		<link>http://anyhosting.com/blog/2009/06/18/web-hosting-control-panels/</link>
		<comments>http://anyhosting.com/blog/2009/06/18/web-hosting-control-panels/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 22:43:58 +0000</pubDate>
		<dc:creator>rhelmer</dc:creator>
				<category><![CDATA[web hosting]]></category>

		<guid isPermaLink="false">http://anyhosting.com/blog/?p=55</guid>
		<description><![CDATA[I&#8217;ve been shopping around for virtual web hosting control panels. At this point, I am interested only in providing end-users things like file management, basic database administration, pre-defined package mangement. They seem to fall into three broad categories: expensive proprietary packages free open-source packages custom software developed by hosting companies The leader in #1 seems [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been shopping around for virtual web hosting control panels. At this point, I am interested only in providing end-users things like file management, basic database administration, pre-defined package mangement.</p>
<p>They seem to fall into three broad categories:</p>
<ol>
<li>expensive proprietary packages</li>
<li>free open-source packages</li>
<li>custom software developed by hosting companies</li>
</ol>
<p>The leader in #1 seems to be <a href="http://www.cpanel.net/">cPanel</a>. I am not at all impressed with their <a href="http://www.cpanel.net/products/cpanelwhm/try-demo.html">demo</a>, it looks very cluttered to me and I really want something simple, easy and aesthetically pleasing.</p>
<p>I have checked out all of the <a href="http://en.wikipedia.org/wiki/Control_panel_%28web_hosting%29#Free_and_open_source_software_-_FOSS">free/open-source web hosting control panels that Wikipedia lists</a>, and I am also very displeased with the UI, and the code doesn&#8217;t look very easy to jump into to me. There seems to be a lot of custom code (I&#8217;d be happiest with something based on <a href="http://www.djangoproject.com/">Django</a>, but the PHP ones could at least use <a href="http://cakephp.org/">Cake</a>). This makes me a little worried on the security aspect (XSS, SQL injection, etc.). Most of these code bases seem to be very old and not necessarily very active.</p>
<p>So is #3 the way to go? I&#8217;ve seen and heard about lots of great hosting control panels that only exist behind close doors, is this the big differentiator for modern hosting companies?</p>
]]></content:encoded>
			<wfw:commentRss>http://anyhosting.com/blog/2009/06/18/web-hosting-control-panels/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>avoiding vendor lock-in</title>
		<link>http://anyhosting.com/blog/2009/02/10/avoiding-vendor-lock-in/</link>
		<comments>http://anyhosting.com/blog/2009/02/10/avoiding-vendor-lock-in/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 09:19:47 +0000</pubDate>
		<dc:creator>rhelmer</dc:creator>
				<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[small business]]></category>
		<category><![CDATA[web hosting]]></category>

		<guid isPermaLink="false">http://anyhosting.com/blog/?p=42</guid>
		<description><![CDATA[Vendor lock-in is a serious concern for any business, and is a pretty tough problem in web hosting specifically. All of the major control panels like cPanel, Plesk, etc. are licensed at substantial fees, which cut into what you as a web host must charge each user. There are open-source alternatives such as ISPConfig and  [...]]]></description>
			<content:encoded><![CDATA[<p>Vendor lock-in is a serious concern for any business, and is a pretty tough problem in web hosting specifically.</p>
<p>All of the major control panels like cPanel, Plesk, etc. are licensed at substantial fees, which cut into what you as a web host must charge each user. There are open-source alternatives such as <a href="http://en.wikipedia.org/wiki/ISPConfig">ISPConfig</a> and  <a href="http://en.wikipedia.org/wiki/Gnupanel">GNUPanel</a>, but this of course means that you will be taking on a lot more of the support burden, although you are of course free to make and keep any customizations or enhancements that you like, unlike cPanel or Plesk.</p>
<p>Besides licensing fees, the other snare to recognize is switching costs. As the LAMP (Linux, Apache, MySQL, PHP) stack has grown in popularity, it has become quite easy to move from one web host to another. Don&#8217;t like <a href="http://dreamhost.com">DreamHost</a>? Move to <a href="http://www.linode.com/">Linnode</a>. Don&#8217;t like them? Try <a href="http://rimuhosting.com/">RimuHosting</a>.</p>
<p>However with the slick new cloud computing services like Amazon&#8217;s EC2 and Google&#8217;s App Engine, there is a ton of opportunity and also some things to watch out for:</p>
<ul>
<li>EC2 can run a regular Linux VM, but the management tools and other services like S3 (storage), queueing, billing etc. will not work out-of-the-box elsewhere</li>
<li>App Engine lets you use the free and open-source Python programming language and the popular Django web framework, but you must use Google&#8217;s storage service. It can be used in a very SQL-like way, or hidden behind Django&#8217;s ORM however</li>
</ul>
<p>I am going to continue using both Amazon and Google&#8217;s services, but I am being very careful about putting all of my eggs in one basket. There are some <a href="http://anyhosting.com/blog/2009/02/08/google-app-engine-becoming-more-useful/">impressive updates in the pipeline</a>, but you might want to think twice about letting any one company collect the tolls on your users.</p>
<p>You can read more about vendor lock-in and switching costs at <a href="http://en.wikipedia.org/wiki/Vendor_lock-in">Wikipedia</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://anyhosting.com/blog/2009/02/10/avoiding-vendor-lock-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google App Engine becoming more useful</title>
		<link>http://anyhosting.com/blog/2009/02/08/google-app-engine-becoming-more-useful/</link>
		<comments>http://anyhosting.com/blog/2009/02/08/google-app-engine-becoming-more-useful/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 06:48:58 +0000</pubDate>
		<dc:creator>rhelmer</dc:creator>
				<category><![CDATA[customers]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web hosting]]></category>
		<category><![CDATA[web services]]></category>

		<guid isPermaLink="false">http://anyhosting.com/blog/?p=38</guid>
		<description><![CDATA[I&#8217;ve been trying out the cloud computing service Google App Engine for a simple dynamic site. I&#8217;ll publish more details on this as it gets further along. I have heard and read a lot about App Engine, so I knew roughly what to expect, but I am still impressed with it. It is a very [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying out the cloud computing service <a href="http://code.google.com/appengine/">Google App Engine</a> for a simple dynamic site. I&#8217;ll publish more details on this as it gets further along.</p>
<p>I have heard and read a lot about App Engine, so I knew roughly what to expect, but I am still impressed with it. It is a very simple model, it&#8217;s basically CGI with a 10-second limit. Only the <a href="http://python.org">Python</a> programming language is supported right now (although they plan to add <a href="http://code.google.com/appengine/docs/whatisgoogleappengine.html">more</a>), and the <a href="http://www.djangoproject.com/">Django</a> web framework is pre-installed. There is a nice little <a href="http://code.google.com/p/googleappengine/">SDK</a> for running the environment locally, which I just noticed is open-source as well (Apache license).</p>
<p>The really incredible thing about this is that it runs on and takes advantage of Google&#8217;s massive server infrastructure. In-memory or persistent storage is super fast and easy to use, and no need to worry about redundancy of individual servers (this is probably why they use the CGI+shared storage model, way simpler to distribute applications on-demand).</p>
<p>Today the <a href="http://googleappengine.blogspot.com/2009/02/roadmap-update.html">roadmap</a> was updated to include a few very cool features coming later this year:</p>
<ul>
<li>Support for running scheduled tasks</li>
<li>Task queues for performing background processing</li>
<li>Ability to receive and process incoming email</li>
<li>Support for sending and receiving XMPP (Jabber) messages</li>
</ul>
<p>This environment being so easy to use and the cost being low due, which is likely because the price of hosting so marginal to Google (I imagine that they are effectively outsourcing spare capacity) plus these new features pretty much replace the need for a traditional shared or dedicated server.</p>
<p>They haven&#8217;t yet started charging for the service, but <a href="http://googleappengine.blogspot.com/2008/05/announcing-open-signups-expected.html">proposed pricing</a> is available, and they plan to start charging this year. The price is quite low considering the feature set, is pay-per-use, and is comparable with the popular cloud computing service <a href="http://anyhosting.com/blog/2007/05/13/pay-as-you-go-hosting/">Amazon Web Services</a> (AWS).</p>
<p>The difference between this and something like AWS is that while it is much easier to get from start to finish on Google App Engine, one must (likely) re-write your application in Python, using Google&#8217;s libraries. You&#8217;ve got less flexibility than a shared PHP host, for example; you can&#8217;t easily take your code elsewhere. AWS is on the other end of the spectrum, more like dedicated servers where you can install anything you want: Linux or Windows, PHP or .Net, etc.</p>
<p>In any case I highly recommend checking out <a href="http://code.google.com/appengine/">Google App Engine</a>, especially if you&#8217;re doing any new development. If you&#8217;re looking to move your existing servers to the cloud, then I think <a href="http://aws.amazon.com/">Amazon Web Services</a> still has the edge here.</p>
]]></content:encoded>
			<wfw:commentRss>http://anyhosting.com/blog/2009/02/08/google-app-engine-becoming-more-useful/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

