Permalink
Browse files

Site updated at 2014-02-03 01:51:24 UTC

  • Loading branch information...
1 parent 17f8f0f commit 2743f36271cbfadc452482386fe11a6a363cbd6b @nikhgupta committed Feb 3, 2014
View
379 atom.xml

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -9,7 +9,7 @@
<meta name="author" content="Nikhil Gupta">
- <meta name="description" content="2014 Jan 31 code wrapping long lines in ruby for display in source files Jan 1 diary, personal The overdue silence Jan 1 code wish yourself a happy &hellip;">
+ <meta name="description" content="2014 Feb 3 code serving legacy php applications using Apache alongside Pow Jan 31 code wrapping long lines in ruby for display in source files Jan 1 &hellip;">
<!-- http://t.co/dKP3o1e -->
@@ -117,6 +117,25 @@
<article itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<div class="meta">
+ <span class="date"><time datetime="2014-02-03T06:49:00+05:30" itemprop="datePublished">Feb 3</time></span>
+ <br>
+ <span class="tags">
+
+
+ <a class='category' href='/blog/categories/code/'>code</a>
+
+
+</span>
+
+ </div>
+ <h1 class="title" itemprop="name"><a href="/code/serving-legacy-php-applications-using-apache-alongside-pow/">serving legacy php applications using Apache alongside Pow</a></h1>
+</article>
+
+
+
+
+<article itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
+ <div class="meta">
<span class="date"><time datetime="2014-01-31T02:42:00+05:30" itemprop="datePublished">Jan 31</time></span>
<br>
<span class="tags">
@@ -4,7 +4,7 @@
<title><![CDATA[Category: code | Nikhil Gupta]]></title>
<link href="http://nikhgupta.com/blog/categories/code/atom.xml" rel="self"/>
<link href="http://nikhgupta.com/"/>
- <updated>2014-01-31T04:01:10+05:30</updated>
+ <updated>2014-02-03T07:21:14+05:30</updated>
<id>http://nikhgupta.com/</id>
<author>
<name><![CDATA[Nikhil Gupta]]></name>
@@ -14,6 +14,134 @@
<entry>
+ <title type="html"><![CDATA[serving legacy php applications using Apache alongside Pow]]></title>
+ <link href="http://nikhgupta.com/code/serving-legacy-php-applications-using-apache-alongside-pow/"/>
+ <updated>2014-02-03T06:49:00+05:30</updated>
+ <id>http://nikhgupta.com/code/serving-legacy-php-applications-using-apache-alongside-pow</id>
+ <content type="html"><![CDATA[<p>I have started using <a href="http://pow.cx">Pow</a> lately, which I have avoided for
+a long time, without any explicit reasoning. Now that I have actually tried it,
+I can definitely say that using Pow is really a breeze, and is really powerful
+at the same time. Before this, I used to run Phusion Passenger for my needs, and
+while that was a lot more powerful, it was a lot more fuss for my naive needs.</p>
+
+<p>Now, Pow is really great for Rack based applications, but does not work well
+enough with other applications, e.g. the ones using PHP. What makes it worse is
+that the default Pow configuration takes over the port 80, and thereby, my
+Apache server will never be hit. Great.</p>
+
+<p>I, quickly, googled some stuff and found a way to make Apache and Pow play
+nicely with each other, and at the same time remove the need for <code>dnsmasq</code>,
+which I am, currently, using to resolve arbitrary top-level domains. This post
+contains my notes on this topic.</p>
+
+<!-- more -->
+
+
+<h2>Uninstall Pow</h2>
+
+<p>The first step we need to perform is to uninstall Pow, if it is already
+installed. That way, we make sure that nothing interferes with our setup.</p>
+
+<p><code>bash
+curl get.pow.cx/uninstall.sh | sh
+</code></p>
+
+<h2>Add Configuration for Pow</h2>
+
+<p>We will tell Pow to use the port 3100, instead of taking over port 80, and let
+the poor Apache be. Furthermore, I will tell Pow to resolve a number of TLDs to
+<code>127.0.0.1</code>.</p>
+
+<p><code>bash
+echo 'export POW_DST_PORT=88' &gt;&gt; ~/.powconfig
+echo 'export POW_DOMAINS=dev,pow,lab,test' &gt;&gt; ~/.powconfig
+</code></p>
+
+<p>From the above list of TLDs, we want <code>dev</code>, and <code>pow</code> to serve applications
+using Pow, while <code>lab</code> and <code>test</code> will be serving Apache based applications
+using VirtualHost directives.</p>
+
+<h2>Adding Apache VirtualHosts</h2>
+
+<p>First, we will tell Apache to pass any requests for <code>dev</code>, and <code>pow</code> TLDs to
+Pow using reverse proxy:</p>
+
+<p>```apache
+<VirtualHost *:80></p>
+
+<pre><code>ServerName pow
+ServerAlias *.dev *.pow *.xip.io
+
+ProxyPass / http://localhost:20559/
+ProxyPassReverse / http://localhost:20559/
+ProxyPreserveHost On
+</code></pre>
+
+<p></VirtualHost>
+```</p>
+
+<p>Having done that, we tell Apache to serve up the remaining TLDs from
+a particular directory:</p>
+
+<p>```apache
+<VirtualHost *:80></p>
+
+<pre><code>ServerName lab
+ServerAlias *.lab *.test
+VirtualDocumentRoot "/Users/nikhgupta/Code/legacy-apps/%1"
+</code></pre>
+
+<p></VirtualHost>
+```</p>
+
+<p>Now, make sure that the above directives are being served up by Apache by
+including them in your <code>httpd.conf</code> somewhere, somehow.</p>
+
+<h2>Restart Apache</h2>
+
+<p>Apache will use the above VirtualHost directives upon restart/reload:</p>
+
+<p><code>bash
+sudo apachectl restart
+</code></p>
+
+<h2>Install Pow</h2>
+
+<p>All that remains is to install Pow:</p>
+
+<p><code>bash
+curl get.pow.cx | sh
+</code></p>
+
+<h2>Install Powder</h2>
+
+<p>Oh, yes, this is my favorite. Simply, install Powder to further simplify your
+life.</p>
+
+<p><code>bash
+gem install powder
+</code></p>
+
+<p><em>Ecstatic</em> :)</p>
+
+<h2>Results?</h2>
+
+<p>For starters, I can serve up any rack based application by simply running
+<code>powder list</code> in that directory, and then access it using <code>appname.dev</code> or
+<code>appname.pow</code>. And, this also works for static websites as well e.g.
+<a href="http://jekyllrb.com">Jekyll</a> (note that, this requires that the current
+directory has a <code>public</code> sub directory which contains an <code>index.html</code> file.)</p>
+
+<p>Moreover, my old Apache configurations run without any implications. And,
+therefore, I can keep on working on applications that are served using PHP.</p>
+
+<p>Effectively, I can run a ruby/rails based application in a single step by
+running <code>powder link</code>, and a php application in zero steps by simply placing it
+at the correct location.</p>
+]]></content>
+ </entry>
+
+ <entry>
<title type="html"><![CDATA[wrapping long lines in ruby for display in source files]]></title>
<link href="http://nikhgupta.com/code/wrapping-long-lines-in-ruby-for-display-in-source-files/"/>
<updated>2014-01-31T02:42:00+05:30</updated>
@@ -300,71 +428,4 @@ Happy, code browsing!</p>
]]></content>
</entry>
- <entry>
- <title type="html"><![CDATA[managing your scripts should not be that hard]]></title>
- <link href="http://nikhgupta.com/personal/code/managing-your-scripts-should-not-be-that-hard/"/>
- <updated>2013-10-23T01:46:00+05:30</updated>
- <id>http://nikhgupta.com/personal/code/managing-your-scripts-should-not-be-that-hard</id>
- <content type="html"><![CDATA[<p>I am, often, found creating simple scripts to automate one or the other part of
-my life. Most of the times, I would use a combination of project managers, task
-managers, automation tools, and so on to do the tedious work for me. But, at the
-other times, it is simply so much more easier to give my inner geek a kick in
-the butt and start writing some code which will explicitely be used by me to
-handle such one off tasks.</p>
-
-<!-- more -->
-
-
-<h2>The Problem</h2>
-
-<p>But, here comes the irony, no matter what I try, I end up either misplacing
-these little snippets of code, or otherwise it becomes so much tedious to
-collect and keep them in an organized manner. Not to mention, the really
-annoying part of creating aliases to these nice snippets and then, forgetting
-what aliases you, currently, have. Oh, did I mention, I have to keep them online
-in a Git repository, so that they are always versioned and sharing them is easy?
-And, what if I am booting a new server or working on some other one-time
-machine, it would kill me to do a clone of this repository, and then run them
-via their full paths, and what if the script does not work on this new machine,
-or what if I had to leave meanwhile?</p>
-
-<p>Let me have a quick answer: it is not the 1990s, where the above issues
-classified as a GNU license, and nor it is the 2000&rsquo;s, when I did not know how
-to create an app dedicated for my own purposes.</p>
-
-<h2>The Solution</h2>
-
-<p>The solution? It&rsquo;s easy. Search for an existing solution or roll out our own.
-Unfortunately, I was unable to find an existing solution (or, atleast, I will
-pretend the same), and therefore will be rolling out my own, with the following
-features:</p>
-
-<ul>
-<li>Has a client side gem that can be used to list a user&rsquo;s scripts, and allow him
-to copy them in a folder on his machine, and assign aliases to these scripts
-on the go.</li>
-<li>The gem should be able to search for scripts based on some keywords.</li>
-<li>User should be able to have CRUD rights over their scripts. They should be
-able to share these scripts, as well as export them. They should be able to
-reference another script inside the script they are creating.</li>
-<li>All the scripts would be created use Github Gists, and hence, be versioned.</li>
-<li>The application should provide an interface to write (and, probably, test) the
-scripts on the server, itself. Provide a dedicated backend to the user?</li>
-<li>The users should be able to run the scripts on their server via the app
-interface, once they have the SSH authentication established? This is not as
-straight-forward, since the app server will be the one connecting to the
-user&rsquo;s server and hence, it is not safe.</li>
-<li>Scripts should have a unique programming structure, which identifies their
-requirements and alike, and notifies the user about the same.</li>
-<li>Logging should be done on cloud for output of the scripts.</li>
-<li>Scripts should be marked as safe based on their MD5 hash, kinda like thor
-does for its installed scripts.</li>
-<li>Scripts should be intelligent in telling the user when the runtime is not
-available, e.g. the user tries to run a ruby script on a server with no-ruby
-installed.</li>
-</ul>
-
-]]></content>
- </entry>
-
</feed>
@@ -116,6 +116,25 @@
<article itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<div class="meta">
+ <span class="date"><time datetime="2014-02-03T06:49:00+05:30" itemprop="datePublished">Feb 3</time></span>
+ <br>
+ <span class="tags">
+
+
+ <a class='category' href='/blog/categories/code/'>code</a>
+
+
+</span>
+
+ </div>
+ <h1 class="title" itemprop="name"><a href="/code/serving-legacy-php-applications-using-apache-alongside-pow/">serving legacy php applications using Apache alongside Pow</a></h1>
+</article>
+
+
+
+
+<article itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
+ <div class="meta">
<span class="date"><time datetime="2014-01-31T02:42:00+05:30" itemprop="datePublished">Jan 31</time></span>
<br>
<span class="tags">
@@ -4,7 +4,7 @@
<title><![CDATA[Category: diary | Nikhil Gupta]]></title>
<link href="http://nikhgupta.com/blog/categories/diary/atom.xml" rel="self"/>
<link href="http://nikhgupta.com/"/>
- <updated>2014-01-31T04:01:10+05:30</updated>
+ <updated>2014-02-03T07:21:14+05:30</updated>
<id>http://nikhgupta.com/</id>
<author>
<name><![CDATA[Nikhil Gupta]]></name>
@@ -9,7 +9,7 @@
<meta name="author" content="Nikhil Gupta">
- <meta name="description" content=" Code [ 17 ] Personal [ 3 ] Diary [ 1 ] ">
+ <meta name="description" content=" Code [ 18 ] Personal [ 3 ] Diary [ 1 ] ">
<!-- http://t.co/dKP3o1e -->
@@ -112,7 +112,7 @@ <h1 class="title">Categories</h1>
<div class="entry-content"><ul>
- <li><a href="/blog/categories/code/">Code</a> [ 17 ]</li>
+ <li><a href="/blog/categories/code/">Code</a> [ 18 ]</li>
<li><a href="/blog/categories/personal/">Personal</a> [ 3 ]</li>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: personal | Nikhil Gupta]]></title>
<link href="http://nikhgupta.com/blog/categories/personal/atom.xml" rel="self"/>
<link href="http://nikhgupta.com/"/>
- <updated>2014-01-31T04:01:10+05:30</updated>
+ <updated>2014-02-03T07:21:14+05:30</updated>
<id>http://nikhgupta.com/</id>
<author>
<name><![CDATA[Nikhil Gupta]]></name>
Oops, something went wrong.

0 comments on commit 2743f36

Please sign in to comment.