<?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>dev.enekoalonso.com &#187; server</title>
	<atom:link href="http://dev.enekoalonso.com/tag/server/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.enekoalonso.com</link>
	<description>having fun with code</description>
	<lastBuildDate>Wed, 12 Oct 2011 21:40:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Having fun with node.js &amp; Redis</title>
		<link>http://dev.enekoalonso.com/2010/10/01/having-fun-with-node-js-redis/</link>
		<comments>http://dev.enekoalonso.com/2010/10/01/having-fun-with-node-js-redis/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 23:05:19 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[grasshopper]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[node_redis]]></category>
		<category><![CDATA[redis]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=670</guid>
		<description><![CDATA[Last week I set up node.js for the first time. I did it on my Dreamhost shared server, but since that goes against the Terms of Service, I set up a small dedicated virtual server at RackspaceCloud. My configuration uses: Ubuntu 10.04.1 subversion node.js grasshopper node_redis redis So far it&#8217;s been a lot of fun, [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I set up node.js for the first time. <a href="http://twitter.com/#!/eneko/status/25181307957">I did it</a> on my Dreamhost shared server, but since that goes against the Terms of Service, I set up a small dedicated virtual server at RackspaceCloud.</p>
<p>My configuration uses:</p>
<ul>
<li>Ubuntu 10.04.1</li>
<li>subversion</li>
<li><a href="http://nodejs.org/">node.js</a></li>
<li><a href="http://github.com/tuxychandru/grasshopper">grasshopper</a></li>
<li><a href="http://github.com/mranney/node_redis">node_redis</a></li>
<li><a href="http://code.google.com/p/redis/">redis</a></li>
</ul>
<p>So far it&#8217;s been a lot of fun, I&#8217;ll give more details about the installation steps and configuration later on :)</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>May 6, 2010 -- <a href="http://dev.enekoalonso.com/2010/05/06/tech-talks-at-level-studios/" title="Tech talks at LEVEL Studios">Tech talks at LEVEL Studios</a> (0)</li><li>February 19, 2010 -- <a href="http://dev.enekoalonso.com/2010/02/19/having-fun-with-mooml-and-twitter/" title="Having fun with Mooml &#038; Twitter">Having fun with Mooml &#038; Twitter</a> (0)</li><li>February 28, 2009 -- <a href="http://dev.enekoalonso.com/2009/02/28/kyte-rest-api/" title="Kyte&#8217;s REST API">Kyte&#8217;s REST API</a> (0)</li><li>October 12, 2011 -- <a href="http://dev.enekoalonso.com/2011/10/12/command-line-scripting-with-node-js/" title="Command line scripting with Node.js">Command line scripting with Node.js</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2010/10/01/having-fun-with-node-js-redis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MooTools Core for Server and Mobile Development</title>
		<link>http://dev.enekoalonso.com/2010/09/17/mootools-core-for-server-and-mobile-development/</link>
		<comments>http://dev.enekoalonso.com/2010/09/17/mootools-core-for-server-and-mobile-development/#comments</comments>
		<pubDate>Fri, 17 Sep 2010 17:50:30 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[appcelerator]]></category>
		<category><![CDATA[core]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[device]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[phone]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[titanium]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=655</guid>
		<description><![CDATA[One of the best things of MooTools is that it is very modular, from the core itself. This means you don&#8217;t need to include all core elements in your projects if you don&#8217;t want or don&#8217;t need some modules. For example, you may not want to include Array or Function, if you don&#8217;t need any [...]]]></description>
			<content:encoded><![CDATA[<p>One of the best things of MooTools is that it is very modular, from the core itself. This means you don&#8217;t need to include all core elements in your projects if you don&#8217;t want or don&#8217;t need some modules. For example, you may not want to include Array or Function, if you don&#8217;t need any enhancements of such objects.</p>
<p>In the case of server side or mobile applications (<a href="http://www.appcelerator.com/">Titanium Developer</a> and other Javascript based mobile frameworks), there is no browser involved which means there is no DOM. Thus, we can removed any kind of module that depend or are designed to work with this elements: Browser, Element, Selectors, Cookie&#8230; all those modules have no value for server side or mobile applications.</p>
<p>I found this page which summarizes the modules you should need for server or mobile development:</p>
<blockquote><p>
<strong><a href="http://mootools.net/core">MooTools Core</a></strong><br />
Core: core<br />
Native: Array, Function, Number, String, Hash<br />
Class: Class, Class.Extras</p>
<p><strong><a href="http://mootools.net/more">MooTools More</a></strong><br />
Core: More<br />
Class: Class.Refactor, Class.Binds, Class.Occludes
</p></blockquote>
<p><a href="http://onecrayon.com/spice/docs/mootools-server/">http://onecrayon.com/spice/docs/mootools-server/</a></p>
<p>Personally, I don&#8217;t find the MooTools More modules very useful, so I&#8217;m not including them in my projects. Maybe Binds would be a good addition, but it is not critical.</p>
<p>Having MooTools in a Javascript application makes it easier to develop and brings you all the power of Object Oriented programming with classes, inheritance and more.</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>July 30, 2010 -- <a href="http://dev.enekoalonso.com/2010/07/30/titanium-developer-love-and-hate/" title="Titanium Developer: love and hate">Titanium Developer: love and hate</a> (3)</li><li>June 14, 2011 -- <a href="http://dev.enekoalonso.com/2011/06/14/titanium-studio-and-titanium-mobile-1-7/" title="Titanium Studio and Titanium Mobile 1.7">Titanium Studio and Titanium Mobile 1.7</a> (0)</li><li>August 18, 2010 -- <a href="http://dev.enekoalonso.com/2010/08/18/titanium-developer-love-and-hate-part-ii/" title="Titanium Developer: love and hate (Part II)">Titanium Developer: love and hate (Part II)</a> (0)</li><li>September 21, 2010 -- <a href="http://dev.enekoalonso.com/2010/09/21/date-from-iso-8601-string/" title="Date from ISO 8601 string">Date from ISO 8601 string</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2010/09/17/mootools-core-for-server-and-mobile-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>More WebSockets, now with Python!</title>
		<link>http://dev.enekoalonso.com/2010/05/22/more-websockets-now-with-python/</link>
		<comments>http://dev.enekoalonso.com/2010/05/22/more-websockets-now-with-python/#comments</comments>
		<pubDate>Sun, 23 May 2010 06:41:27 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[websocket]]></category>
		<category><![CDATA[websockets]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=576</guid>
		<description><![CDATA[A couple of weeks ago, Tim and I worked on a little game/demo using WebSockets and C# (I haven&#8217;t been able to put it online since I do not have a Windows server). It was a lot of fun and we were able to see the potential of WebSockets and how much internet can will [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago, <a href="http://twitter.com/SkullDuggerT">Tim</a> and I worked on a <a href="http://dev.enekoalonso.com/2010/05/03/playing-with-websockets/">little game/demo using WebSockets and C#</a> (I haven&#8217;t been able to put it online since I do not have a Windows server). It was a lot of fun and we were able to see the potential of WebSockets and how much internet <del datetime="2010-05-23T06:09:54+00:00">can</del> will change in the next few years because of them.</p>
<p>Today I spent a couple of hours researching and implementing a WebSocket solution that I could run in my linux servers, and I found this very nice tutorial for creating a Python WebSockets server: <a href="http://yz.mit.edu/wp/web-sockets-tutorial-with-simple-python-server/">http://yz.mit.edu/wp/web-sockets-tutorial-with-simple-python-server/</a></p>
<p>So I took that code and modified to create a very, very basic chat, that broadcasts received messages to all connected clients. You can try it here (as long as the python server is still up): <a href="http://enekoalonso.com/research/html5/websockets/python/">http://enekoalonso.com/research/html5/websockets/python/</a></p>
<p>Here is the client code:</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1">&nbsp;<span class="kw2">var</span> form = document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&#39;form&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw2">var</span> msg = document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&#39;msg&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw2">var</span> output = document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&#39;serveroutput&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw2">var</span> s = <span class="kw2">new</span> WebSocket<span class="br0">&#40;</span><span class="st0">&quot;ws://&quot;</span>+window.<span class="me1">location</span>.<span class="me1">hostname</span>+<span class="st0">&quot;:9876/&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;s.<span class="me1">onopen</span> = <span class="kw2">function</span><span class="br0">&#40;</span>e<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; console.<span class="me1">log</span><span class="br0">&#40;</span><span class="st0">&quot;opened&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; out<span class="br0">&#40;</span><span class="st0">&#39;Connected.&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;s.<span class="me1">onclose</span> = <span class="kw2">function</span><span class="br0">&#40;</span>e<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; console.<span class="me1">log</span><span class="br0">&#40;</span><span class="st0">&quot;closed&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; out<span class="br0">&#40;</span><span class="st0">&#39;Connection closed.&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;s.<span class="me1">onmessage</span> = <span class="kw2">function</span><span class="br0">&#40;</span>e<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; console.<span class="me1">log</span><span class="br0">&#40;</span><span class="st0">&quot;got: &quot;</span> + e.<span class="me1">data</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; out<span class="br0">&#40;</span>e.<span class="me1">data</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;form.<span class="me1">onsubmit</span> = <span class="kw2">function</span><span class="br0">&#40;</span>e<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; e.<span class="me1">preventDefault</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; msg.<span class="me1">value</span> = <span class="st0">&#39;&#39;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; window.<span class="me1">scrollTop</span> = window.<span class="me1">scrollHeight</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw2">function</span> sendMsg<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; s.<span class="me1">send</span><span class="br0">&#40;</span>msg.<span class="me1">value</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw2">function</span> out<span class="br0">&#40;</span>text<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">var</span> el = document.<span class="me1">createElement</span><span class="br0">&#40;</span><span class="st0">&#39;p&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; el.<span class="me1">innerHTML</span> = text;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; output.<span class="me1">appendChild</span><span class="br0">&#40;</span>el<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;msg.<span class="kw3">focus</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>And the server code:</p>
<div class="geshi no python">
<ol>
<li class="li1">
<div class="de1"><span class="co1">#!/usr/bin/env python</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">import</span> <span class="kw3">socket</span>, <span class="kw3">threading</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># httphost = &quot;localhost:8888&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># sockethost = &quot;localhost:9876&quot;</span></div>
</li>
<li class="li1">
<div class="de1">httphost = <span class="st0">&quot;enekoalonso.com&quot;</span></div>
</li>
<li class="li1">
<div class="de1">sockethost = <span class="st0">&quot;enekoalonso.com:9876&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">def</span> handle<span class="br0">&#40;</span>s, addr<span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; handsake = <span class="st0">&quot;HTTP/1.1 101 Web Socket Protocol Handshake<span class="es0">\r</span><span class="es0">\n</span>Upgrade: WebSocket<span class="es0">\r</span><span class="es0">\n</span>Connection: Upgrade<span class="es0">\r</span><span class="es0">\n</span>WebSocket-Origin: http://%s<span class="es0">\r</span><span class="es0">\n</span>WebSocket-Location: ws://%s/<span class="es0">\r</span><span class="es0">\n</span>WebSocket-Protocol: sample<span class="es0">\r</span><span class="es0">\n</span><span class="es0">\r</span><span class="es0">\n</span>&quot;</span> <span class="sy0">%</span> <span class="br0">&#40;</span>httphost, sockethost<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; s.<span class="me1">send</span><span class="br0">&#40;</span>handsake<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; data = s.<span class="me1">recv</span><span class="br0">&#40;</span><span class="nu0">1024</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; lock = <span class="kw3">threading</span>.<span class="me1">Lock</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">while</span> <span class="nu0">1</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; data = s.<span class="me1">recv</span><span class="br0">&#40;</span><span class="nu0">1024</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="kw1">not</span> data: <span class="kw1">break</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">print</span> <span class="st0">&#39;Data from&#39;</span>, addr, <span class="st0">&#39;:&#39;</span>, data</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; lock.<span class="me1">acquire</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span>conn.<span class="me1">send</span><span class="br0">&#40;</span>data<span class="br0">&#41;</span> <span class="kw1">for</span> conn <span class="kw1">in</span> clients<span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; lock.<span class="me1">release</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">print</span> <span class="st0">&#39;Client closed:&#39;</span>, addr</div>
</li>
<li class="li1">
<div class="de1">&nbsp; lock.<span class="me1">acquire</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; clients.<span class="me1">remove</span><span class="br0">&#40;</span>s<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; lock.<span class="me1">release</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; s.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">def</span> start_server<span class="br0">&#40;</span><span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp;s = <span class="kw3">socket</span>.<span class="kw3">socket</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;s.<span class="me1">setsockopt</span><span class="br0">&#40;</span><span class="kw3">socket</span>.<span class="me1">SOL_SOCKET</span>, <span class="kw3">socket</span>.<span class="me1">SO_REUSEADDR</span>, <span class="nu0">1</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;s.<span class="me1">bind</span><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="st0">&#39;&#39;</span>, <span class="nu0">9876</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;s.<span class="me1">listen</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">while</span> <span class="nu0">1</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;conn, addr = s.<span class="me1">accept</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">print</span> <span class="st0">&#39;Connected by&#39;</span>, addr</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;clients.<span class="me1">append</span><span class="br0">&#40;</span>conn<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw3">threading</span>.<span class="me1">Thread</span><span class="br0">&#40;</span>target = handle, args = <span class="br0">&#40;</span>conn,addr<span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="me1">start</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">clients = <span class="br0">&#91;</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">start_server<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>Check the live demo (be aware WebSockets are only supported by Google Chrome right now): <a href="http://enekoalonso.com/research/html5/websockets/python/">http://enekoalonso.com/research/html5/websockets/python/</a><br />
Open a few tabs and send some text. You should see it appearing in all of them. It will also work if you open the page in multiple browser windows or even if you open the page in different computers.</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>May 3, 2010 -- <a href="http://dev.enekoalonso.com/2010/05/03/playing-with-websockets/" title="Playing with WebSockets">Playing with WebSockets</a> (4)</li><li>May 6, 2010 -- <a href="http://dev.enekoalonso.com/2010/05/06/tech-talks-at-level-studios/" title="Tech talks at LEVEL Studios">Tech talks at LEVEL Studios</a> (0)</li><li>February 19, 2010 -- <a href="http://dev.enekoalonso.com/2010/02/19/having-fun-with-mooml-and-twitter/" title="Having fun with Mooml &#038; Twitter">Having fun with Mooml &#038; Twitter</a> (0)</li><li>May 18, 2011 -- <a href="http://dev.enekoalonso.com/2011/05/18/location-hash-is-dead-on-html5-browsers/" title="location.hash is dead (on html5 browsers)">location.hash is dead (on html5 browsers)</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2010/05/22/more-websockets-now-with-python/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Playing with WebSockets</title>
		<link>http://dev.enekoalonso.com/2010/05/03/playing-with-websockets/</link>
		<comments>http://dev.enekoalonso.com/2010/05/03/playing-with-websockets/#comments</comments>
		<pubDate>Tue, 04 May 2010 04:20:37 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[studio]]></category>
		<category><![CDATA[tpc]]></category>
		<category><![CDATA[visual]]></category>
		<category><![CDATA[websocket]]></category>
		<category><![CDATA[websockets]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=521</guid>
		<description><![CDATA[Today I spent some time with Tim at work, playing with WebSockets, a new HTML5 feature that only Google Chrome supports so far. WebSockets allow browsers to create and maintain open direct TCP connections to the server, allowing instant communication in both directions. This means that ajax polling is no longer needed to get updates [...]]]></description>
			<content:encoded><![CDATA[<p>Today I spent some time with Tim at work, playing with <a href="http://en.wikipedia.org/wiki/Web_Sockets">WebSockets</a>, a new <a href="http://dev.w3.org/html5/websockets/">HTML5 feature</a> that only Google Chrome supports so far. WebSockets allow browsers to create and maintain open direct TCP connections to the server, allowing instant communication in both directions. This means that ajax polling is no longer needed to get updates from the server. Instead, the server can send a message directly to the browser at any point in time while the connection is open. Awesome!</p>
<p style="text-align: left;">Since we are currently working on a C# .Net project, we searched Internet and found this very cool example that we took as a base for a little multiuser game we were working on today: <a href="http://www.codeproject.com/KB/webservices/c_sharp_web_socket_server.aspx">WebSocket Chat</a></p>
<p style="text-align: left;"><a href="http://www.codeproject.com/KB/webservices/c_sharp_web_socket_server.aspx"></a><br />
<a href="http://www.codeproject.com/KB/webservices/c_sharp_web_socket_server.aspx"><img class="aligncenter" src="http://www.codeproject.com/KB/webservices/c_sharp_web_socket_server/WebSocketServer.png" alt="" /></a></p>
<p>The potential of WebSockets is incredible, specially for online games and multiuser applications.</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>May 22, 2010 -- <a href="http://dev.enekoalonso.com/2010/05/22/more-websockets-now-with-python/" title="More WebSockets, now with Python!">More WebSockets, now with Python!</a> (9)</li><li>May 12, 2011 -- <a href="http://dev.enekoalonso.com/2011/05/12/angry-birds-as-a-web-app/" title="Angry Birds as a Web App">Angry Birds as a Web App</a> (0)</li><li>June 8, 2010 -- <a href="http://dev.enekoalonso.com/2010/06/08/change-in-websockets-handshake-protocol/" title="Change in WebSockets handshake protocol">Change in WebSockets handshake protocol</a> (0)</li><li>May 6, 2010 -- <a href="http://dev.enekoalonso.com/2010/05/06/tech-talks-at-level-studios/" title="Tech talks at LEVEL Studios">Tech talks at LEVEL Studios</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2010/05/03/playing-with-websockets/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Got NFS working</title>
		<link>http://dev.enekoalonso.com/2010/02/06/got-nfs-working/</link>
		<comments>http://dev.enekoalonso.com/2010/02/06/got-nfs-working/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 06:19:27 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[exports]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[fedora11]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nfs]]></category>
		<category><![CDATA[nfs4]]></category>
		<category><![CDATA[nfsserver]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=457</guid>
		<description><![CDATA[Well, last night I started reading about how to share the files folder of a Drupal installation on a site with multiple web servers. Seems like NFS is the right way to go (as long as your traffic doesn&#8217;t grow too much). Perfect for Spaniards.es, since I want to move from a 2 dedicated server [...]]]></description>
			<content:encoded><![CDATA[<p>Well, last night I started reading about how to share the files folder of a Drupal installation on a site with multiple web servers. Seems like NFS is the right way to go (as long as your traffic doesn&#8217;t grow too much). Perfect for Spaniards.es, since I want to move from a 2 dedicated server setup to a more flexible one where I can launch new web servers easily, almost on demand.</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="co0"># Install NFS</span></div>
</li>
<li class="li1">
<div class="de1">yum -y <span class="kw2">install</span> rpcbind nfs-utils nfs-utils-lib system-config-nfs rsync</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># chkconfig nfs on</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">/</span>sbin<span class="sy0">/</span>chkconfig nfs on</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">vi <span class="sy0">/</span>etc<span class="sy0">/</span>idmapd.conf</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># [General]</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Domain = spaniards.es</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># [Mapping]</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Nobody-User = nfsnobody</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Nobody-Group = nfsnobody</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">service rpcidmapd restart</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;/files/archivos &nbsp;/nfs4exports/archivos none bind 0 0&quot;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>fstab</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">mount</span> <span class="sy0">/</span>nfs4exports<span class="sy0">/</span>archivos</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;/nfs4exports XXX.177.133.25(rw,insecure,no_subtree_check,nohide,fsid=0) XXX.177.136.14(rw,insecure,no_subtree_check,nohide,fsid=0)&quot;</span> <span class="sy0">&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>exports</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;/nfs4exports/archivos XXX.177.133.25(rw,insecure,no_subtree_check,nohide) XXX.177.136.14(rw,insecure,no_subtree_check,nohide)&quot;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>exports</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">su</span> -c <span class="st0">&quot;/usr/sbin/exportfs -rva&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">/</span>sbin<span class="sy0">/</span>service nfs restart</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;portmap:ALL&#39;</span> <span class="sy0">&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.deny</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;lockd:ALL&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.deny</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;mountd:ALL&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.deny</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;rquotad:ALL&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.deny</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;statd:ALL&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.deny</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;portmap:XXX.177.133.25,XXX.177.136.14&#39;</span> <span class="sy0">&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.allow</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;lockd:XXX.177.133.25,XXX.177.136.14&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.allow</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;mountd:XXX.177.133.25,XXX.177.136.14&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.allow</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;rquotad:XXX.177.133.25,XXX.177.136.14&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.allow</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;statd:XXX.177.133.25,XXX.177.136.14&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>hosts.allow</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;LOCKD_TCPPORT=48620&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>sysconfig<span class="sy0">/</span>nfs</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;LOCKD_UDPPORT=48620&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>sysconfig<span class="sy0">/</span>nfs</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;MOUNTD_PORT=48621&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>sysconfig<span class="sy0">/</span>nfs</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;STATD_PORT=48622&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>sysconfig<span class="sy0">/</span>nfs</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;RQUOTAD=no&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>sysconfig<span class="sy0">/</span>nfs</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&#39;RQUOTAD_PORT=48623&#39;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>sysconfig<span class="sy0">/</span>nfs</div>
</li>
</ol>
</div>
<p>At the end, setting up NFS is not that complicated, but it was my first time, so it took a while. Actually, I had everything working before I noticed, since, logged in as root, I couldn&#8217;t figure out why I wasn&#8217;t able to write to the nfs mounted directory, being this mounted as rw. Well, turns out that you shouldn&#8217;t do this as root, since <a href="http://lists.freebsd.org/pipermail/freebsd-questions/2005-October/101886.html">root access on nfs, once enabled does not require authentication</a>.</p>
<p>I&#8217;m not sure why there is a need to mount a bind directory on the nfs server, but I think it has to do with the NFS4 directory configuration.</p>
<p>I think I got all the information I needed between these two links:<br />
<a href="http://fconfig.wordpress.com/2006/08/17/setting-up-a-fedora-nfs-server/">http://fconfig.wordpress.com/2006/08/17/setting-up-a-fedora-nfs-server/</a><br />
<a href="http://fedorasolved.org/Members/renich/howtos/f7/en/nfsv4-fedora/?searchterm=nfs">http://fedorasolved.org/Members/renich/howtos/f7/en/nfsv4-fedora/?searchterm=nfs</a></p>
<p>Next step: set up the round robin load balancer: haproxy or dns?</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>January 31, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-web-server-with-httpd-php-memcached/" title="CloudServers: Creating a new web server with httpd, php &#038; memcached">CloudServers: Creating a new web server with httpd, php &#038; memcached</a> (1)</li><li>January 31, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-mysql-db-server/" title="CloudServers: Creating a new MySQL db server">CloudServers: Creating a new MySQL db server</a> (0)</li><li>January 30, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/30/got-new-servers-on-rackspace-cloud/" title="Got new servers on Rackspace Cloud">Got new servers on Rackspace Cloud</a> (5)</li><li>May 12, 2011 -- <a href="http://dev.enekoalonso.com/2011/05/12/angry-birds-as-a-web-app/" title="Angry Birds as a Web App">Angry Birds as a Web App</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2010/02/06/got-nfs-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CloudServers: Creating a new MySQL db server</title>
		<link>http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-mysql-db-server/</link>
		<comments>http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-mysql-db-server/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 05:29:46 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[fedora12]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rackspacecoud]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=444</guid>
		<description><![CDATA[On my previous post I posted the commands I used to create a brand new Linux web server for my Drupal site. Now I&#8217;ll post the commands to create the database server. While creating the server instance at RackspaceCloud, I&#8217;ve chosen Fedora 12 for my db server, which comes with MySQL 5.1.42. # Install MySQL [...]]]></description>
			<content:encoded><![CDATA[<p>On my previous post I posted the commands I used to create a brand <a href="http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-web-server-with-httpd-php-memcached/">new Linux web server for my Drupal site</a>. Now I&#8217;ll post the commands to create the database server. While creating the server instance at RackspaceCloud, I&#8217;ve chosen Fedora 12 for my db server, which comes with MySQL 5.1.42.</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="co0"># Install MySQL</span></div>
</li>
<li class="li1">
<div class="de1">yum -y <span class="kw2">install</span> mysql mysql-server rsync</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">/</span>sbin<span class="sy0">/</span>chkconfig &#8211;levels <span class="nu0">235</span> mysqld on</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Start DB</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">/</span>etc<span class="sy0">/</span>init.d<span class="sy0">/</span>mysqld start</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Grant permissions to db_user (1.2.3.4 is the web server IP address)</span></div>
</li>
<li class="li1">
<div class="de1">mysql -e <span class="st0">&quot;grant all privileges on db_name.* to db_user@&#39;1.2.3.4&#39; identified by &#39;password&#39;;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">mysql -e <span class="st0">&quot;flush privileges;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#############################################################</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># FIREWALL</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Open DB port 3306</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Allow connections only from web server</span></div>
</li>
<li class="li1">
<div class="de1">iptables -F</div>
</li>
<li class="li1">
<div class="de1">iptables -A INPUT -p tcp &#8211;dport <span class="nu0">22</span> -j ACCEPT</div>
</li>
<li class="li1">
<div class="de1">iptables -P INPUT DROP</div>
</li>
<li class="li1">
<div class="de1">iptables -P FORWARD DROP</div>
</li>
<li class="li1">
<div class="de1">iptables -P OUTPUT ACCEPT</div>
</li>
<li class="li1">
<div class="de1">iptables -A INPUT -i lo -j ACCEPT</div>
</li>
<li class="li1">
<div class="de1">iptables -A INPUT -m state &#8211;state ESTABLISHED,RELATED -j ACCEPT</div>
</li>
<li class="li1">
<div class="de1">iptables -A INPUT -s <span class="nu0">1.2</span><span class="nu0">.3</span><span class="nu0">.4</span> -p tcp &#8211;dport <span class="nu0">3306</span> -j ACCEPT</div>
</li>
<li class="li1">
<div class="de1">iptables -L -v</div>
</li>
<li class="li1">
<div class="de1">service iptables save</div>
</li>
</ol>
</div>
<p>As easy as that, having a MySQL server up and running is piece of cake :) </p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>January 31, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-web-server-with-httpd-php-memcached/" title="CloudServers: Creating a new web server with httpd, php &#038; memcached">CloudServers: Creating a new web server with httpd, php &#038; memcached</a> (1)</li><li>January 30, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/30/got-new-servers-on-rackspace-cloud/" title="Got new servers on Rackspace Cloud">Got new servers on Rackspace Cloud</a> (5)</li><li>February 6, 2010 -- <a href="http://dev.enekoalonso.com/2010/02/06/got-nfs-working/" title="Got NFS working">Got NFS working</a> (0)</li><li>October 1, 2010 -- <a href="http://dev.enekoalonso.com/2010/10/01/having-fun-with-node-js-redis/" title="Having fun with node.js &#038; Redis">Having fun with node.js &#038; Redis</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-mysql-db-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CloudServers: Creating a new web server with httpd, php &amp; memcached</title>
		<link>http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-web-server-with-httpd-php-memcached/</link>
		<comments>http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-web-server-with-httpd-php-memcached/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 17:16:47 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[fedora12]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rackspacecloud]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=442</guid>
		<description><![CDATA[Creating a new web server is piece of cake at Rackspace Cloud. Here is a demo video of how to set up a new instance with your favorite Linux distribution. I have used Fedora 12 for my new spaniards.es servers, and here is the script I&#8217;ve used to install everything needed so far: # Install [...]]]></description>
			<content:encoded><![CDATA[<p>Creating a new web server is piece of cake at Rackspace Cloud. Here is a demo video of <a href="http://www.rackspacecloud.com/cloud_hosting_demos/cloud_computing_cloud_servers">how to set up a new instance with your favorite Linux distribution</a>. I have used Fedora 12 for my new spaniards.es servers, and here is the script I&#8217;ve used to install everything needed so far:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="co0"># Install HTTPD</span></div>
</li>
<li class="li1">
<div class="de1">yum -y <span class="kw2">install</span> httpd rsync</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Install PHP</span></div>
</li>
<li class="li1">
<div class="de1">yum -y <span class="kw2">install</span> php php-mbstring php-mysql mysql</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#############################################################</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># FIREWALL</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Open http port 80 (and ssh)</span></div>
</li>
<li class="li1">
<div class="de1">iptables -F</div>
</li>
<li class="li1">
<div class="de1">iptables -A INPUT -p tcp &#8211;dport <span class="nu0">22</span> -j ACCEPT</div>
</li>
<li class="li1">
<div class="de1">iptables -P INPUT DROP</div>
</li>
<li class="li1">
<div class="de1">iptables -P FORWARD DROP</div>
</li>
<li class="li1">
<div class="de1">iptables -P OUTPUT ACCEPT</div>
</li>
<li class="li1">
<div class="de1">iptables -A INPUT -i lo -j ACCEPT</div>
</li>
<li class="li1">
<div class="de1">iptables -A INPUT -m state &#8211;state ESTABLISHED,RELATED -j ACCEPT</div>
</li>
<li class="li1">
<div class="de1">iptables -A INPUT -p tcp &#8211;dport <span class="nu0">80</span> -j ACCEPT</div>
</li>
<li class="li1">
<div class="de1">iptables -L -v</div>
</li>
<li class="li1">
<div class="de1">service iptables save</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Start HTTPD server</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">/</span>etc<span class="sy0">/</span>init.d<span class="sy0">/</span>httpd start</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Install &nbsp;memcached</span></div>
</li>
<li class="li1">
<div class="de1">yum -y <span class="kw2">install</span> memcached</div>
</li>
<li class="li1">
<div class="de1">memcached -d -u apache</div>
</li>
<li class="li1">
<div class="de1">yum -y <span class="kw2">install</span> php-pecl-memcache</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Restart HTTPD server</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">/</span>etc<span class="sy0">/</span>init.d<span class="sy0">/</span>httpd restart</div>
</li>
</ol>
</div>
<p>DNS configuration can be done through the admin pages, so there is no need for manual configuration. Copying the data from your old server can be done with rsync and having mysql installed is handy to test db connections from the console.</p>
<p>In less than 10 minutes you can have a new web server up and running :)</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>January 31, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-mysql-db-server/" title="CloudServers: Creating a new MySQL db server">CloudServers: Creating a new MySQL db server</a> (0)</li><li>January 30, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/30/got-new-servers-on-rackspace-cloud/" title="Got new servers on Rackspace Cloud">Got new servers on Rackspace Cloud</a> (5)</li><li>February 6, 2010 -- <a href="http://dev.enekoalonso.com/2010/02/06/got-nfs-working/" title="Got NFS working">Got NFS working</a> (0)</li><li>December 5, 2008 -- <a href="http://dev.enekoalonso.com/2008/12/05/enabling-php5-on-mac-os-x-leopard/" title="Enabling PHP5 on Mac OS X Leopard">Enabling PHP5 on Mac OS X Leopard</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-web-server-with-httpd-php-memcached/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Got new servers on Rackspace Cloud</title>
		<link>http://dev.enekoalonso.com/2010/01/30/got-new-servers-on-rackspace-cloud/</link>
		<comments>http://dev.enekoalonso.com/2010/01/30/got-new-servers-on-rackspace-cloud/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 01:06:09 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[ace-host]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rackspace]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[spaniards]]></category>
		<category><![CDATA[webserver]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=433</guid>
		<description><![CDATA[Last night I got an account at Rackspace Cloud and created three brand new CentOS Linux servers. Now I have to set them up: two web servers and one database server. My goal: Move Spaniards.es website to this new hosting. Why move? Currently I am hosting Spaniards.es on two dedicated servers at Ace-Host.net. So far, [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I got an account at <a href="http://www.rackspacecloud.com/cloud_hosting_products/servers">Rackspace Cloud</a> and created three brand new CentOS Linux servers. Now I have to set them up: two web servers and one database server. My goal: Move Spaniards.es website to this new hosting.</p>
<h3>Why move?</h3>
<p>Currently I am hosting <a href="http://spaniards.es/">Spaniards.es</a> on two dedicated servers at <a href="http://ace-host.net/">Ace-Host.net</a>. So far, so good, but the site has started to get slow (more the web server than the db server, which is running great so far). Some days I found the site running at 30 times the processor capacity (according to &#8216;top&#8217;), which is a lot. The biggest problem I have right now is the caching on the web server. I have installed both XCache and Memcached, but can get them to work since that server was my first ever dedicated server an has a CPanel installation that drives me nuts.</p>
<p>Sooner or later I had to move that webserver into a new clean installation, but I have decided that if I have to move, I&#8217;ll do it to a cloud. No more dependencies on a physical hardware, no more worries.</p>
<h3>Why not EC2</h3>
<p>Well, I&#8217;ve ried <a href="http://aws.amazon.com/ec2/">EC2</a> and it is not that I don&#8217;t like it. It is just that it is so much work. After seeing how <a href="http://www.rackspacecloud.com/cloud_hosting_products/servers">CloudServers</a> work on RackSpace, I have no doubt.</p>
<h3>When is Spaniards.es going to be moved?</h3>
<p>There is no date yet. First I have to set up the servers, make sure everything works fine, set up the domains, dns, mail, etc. Hopefully in a couple of weeks, if I can find enough time to do so.</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>January 31, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-web-server-with-httpd-php-memcached/" title="CloudServers: Creating a new web server with httpd, php &#038; memcached">CloudServers: Creating a new web server with httpd, php &#038; memcached</a> (1)</li><li>January 31, 2010 -- <a href="http://dev.enekoalonso.com/2010/01/31/cloudservers-creating-a-new-mysql-db-server/" title="CloudServers: Creating a new MySQL db server">CloudServers: Creating a new MySQL db server</a> (0)</li><li>February 6, 2010 -- <a href="http://dev.enekoalonso.com/2010/02/06/got-nfs-working/" title="Got NFS working">Got NFS working</a> (0)</li><li>October 1, 2010 -- <a href="http://dev.enekoalonso.com/2010/10/01/having-fun-with-node-js-redis/" title="Having fun with node.js &#038; Redis">Having fun with node.js &#038; Redis</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2010/01/30/got-new-servers-on-rackspace-cloud/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Check your server status with email notification</title>
		<link>http://dev.enekoalonso.com/2009/01/03/check-your-server-status-with-email-notification/</link>
		<comments>http://dev.enekoalonso.com/2009/01/03/check-your-server-status-with-email-notification/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 19:34:11 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[automatically]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[status]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=238</guid>
		<description><![CDATA[I wanted to do this for a while and never really sit down and code it. Yesterday I came across this pretty nice script by Ben from Coderholic which does exactly that: check your server status and send you an email if it is other than 200 (OK). #!/bin/bash &#160; &#160; # Query a supplied [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to do this for a while and never really sit down and code it. Yesterday I came across this pretty nice <a href="http://www.coderholic.com/server-status-checker-shell-script-2/">script by Ben from Coderholic</a> which does exactly that: check your server status and send you an email if it is other than 200 (OK).</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="co0">#!/bin/bash &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Query a supplied URL and output an error message if &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># the status code was not 200. Can be used as a cron &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># task to check if a server is up or not. &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Ben Dowling &#8211; http://www.coderholic.com &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># The URL to query &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re4">$#</span> -ne <span class="nu0">1</span> <span class="br0">&#93;</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">then</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;Usage: $0 &lt;URL&gt;&quot;</span>; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">exit</span>; &nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">fi</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="re2">url=</span>$<span class="nu0">1</span>; &nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">response=</span>$<span class="br0">&#40;</span>curl -s -I -L <span class="re1">$url</span> <span class="sy0">|</span> <span class="kw2">grep</span> HTTP<span class="br0">&#41;</span>; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="re2">status=</span>$<span class="br0">&#123;</span>response<span class="co0">#* }; # Strip off characters up to the first space &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">status=</span>$<span class="br0">&#123;</span>status:<span class="nu0">0</span>:<span class="nu0">3</span><span class="br0">&#125;</span>; <span class="co0"># Just use the 3 digit status code &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;$status&quot;</span> <span class="sy0">!</span>= <span class="st0">&quot;200&quot;</span> <span class="br0">&#93;</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">then</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;Error fetching $url. Status code &#39;$status&#39;&quot;</span>; &nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">fi</span></div>
</li>
</ol>
</div>
<p>Nice.</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>July 13, 2011 -- <a href="http://dev.enekoalonso.com/2011/07/13/clone-your-osxterminal-window/" title="Clone your OSX terminal window">Clone your OSX terminal window</a> (1)</li><li>October 12, 2011 -- <a href="http://dev.enekoalonso.com/2011/10/12/command-line-scripting-with-node-js/" title="Command line scripting with Node.js">Command line scripting with Node.js</a> (0)</li><li>August 6, 2011 -- <a href="http://dev.enekoalonso.com/2011/08/06/python-script-remove-empty-folders/" title="Python script: remove empty folders">Python script: remove empty folders</a> (1)</li><li>October 1, 2010 -- <a href="http://dev.enekoalonso.com/2010/10/01/having-fun-with-node-js-redis/" title="Having fun with node.js &#038; Redis">Having fun with node.js &#038; Redis</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2009/01/03/check-your-server-status-with-email-notification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

