<?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>A Noted Path by Theodore Nguyen-Cao &#187; apache</title>
	<atom:link href="http://www.theodorenguyen-cao.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theodorenguyen-cao.com</link>
	<description>Personal blog of Theodore Nguyen-Cao</description>
	<lastBuildDate>Wed, 21 Jul 2010 15:40:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Setup Apache on Mac OSX Leopard</title>
		<link>http://www.theodorenguyen-cao.com/2009/01/28/setup-apache-on-mac-osx-leopard/</link>
		<comments>http://www.theodorenguyen-cao.com/2009/01/28/setup-apache-on-mac-osx-leopard/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 05:46:01 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[tutorials]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.theodorenguyen-cao.com/?p=227</guid>
		<description><![CDATA[I&#8217;ve had my Macbook for a little over a year now. However, I just recently found out Leopard comes with apache (apache2 to be specific) already installed. To verify this is true, open up Terminal and type >> apachectl -V Server version: Apache/2.2.9 (Unix) Server built: Sep 19 2008 10:58:54 Server's Module Magic Number: 20051115:15 [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had my Macbook for a little over a year now. However, I just recently found out Leopard comes with apache (apache2 to be specific) already installed.  To verify this is true, open up Terminal and type</p>
<pre class="console">
>> apachectl -V
Server version: Apache/2.2.9 (Unix)
Server built:   Sep 19 2008 10:58:54
Server's Module Magic Number: 20051115:15
Server loaded:  APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_FLOCK_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/usr"
 -D SUEXEC_BIN="/usr/bin/suexec"
 -D DEFAULT_PIDLOG="/private/var/run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/private/var/run/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
</pre>
<p>To start up apache, you can do it a couple of ways.</p>
<p>Type <code>sudo apachectl -k start</code></p>
<p>or</p>
<p><img src="http://www.theodorenguyen-cao.com/wp-content/uploads/2009/01/web-sharing.png" alt="web-sharing" title="web-sharing" width="500" height="419" class="aligncenter size-full wp-image-237" /></p>
<ol>
<li>Go to System Preferences</li>
<li>Click on Sharing</li>
<li>Check the box that says Web Sharing</li>
</ol>
<p>You can go to http://localhost or the URL provided in the Web Sharing screen to confirm apache is running and is able to serve up requests.</p>
<p>There is also a <code>~/Sites</code> directory in your home folder.  Apache is already setup to serve up files from this directory under <code>http://localhost/~<b>[username]</b></code> where <b>[username]</b> is your user account name. Any files here will be render for example ~/Sites/index.html is accessible from the browser via http://localhost/~<b>[username]</b>/index.html.</p>
<p>One note to get this to work.  Out of the box, all requests to /Sites result in a Forbidden 403 error. To resolve this issue, modify the conf file specified above as <code>SERVER_CONFIG_FILE</code> (<code>/private/etc/apache2/httpd.conf</code> in my case) from </p>
<pre class="console">
&lt;Directory /&gt;
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
&lt;/Directory&gt;
</pre>
<p>to</p>
<pre class="console">
&lt;Directory /&gt;
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
&lt;/Directory&gt;
</pre>
<p>Restart apache (sudo apachectl -k restart) and try going to <code>http://localhost/~<b>[username]</b></code> again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2009/01/28/setup-apache-on-mac-osx-leopard/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Moving wordpress to another host</title>
		<link>http://www.theodorenguyen-cao.com/2009/01/21/moving-wordpress-to-another-host/</link>
		<comments>http://www.theodorenguyen-cao.com/2009/01/21/moving-wordpress-to-another-host/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 04:57:35 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.theodorenguyen-cao.com/?p=196</guid>
		<description><![CDATA[If you&#8217;ve been following my blog for awhile, you might have noticed I moved this blog from blog.notedpath.com to theodorenguyen-cao.com as it was more fitting domain. I originally just registered the domain, added the DNS record, and updated my apache config to have theodorenguyen-cao.com to be an server alias to blog.notedpath.com. This allowed requests to [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve been following my blog for awhile, you might have noticed I moved this blog from <a href="http://blog.notedpath.com">blog.notedpath.com</a> to <a href="http://www.theodorenguyen-cao.com">theodorenguyen-cao.com</a> as it was more fitting domain.  I originally just registered the domain, added the DNS record, and updated my apache config to have <a href="http://www.theodorenguyen-cao.com">theodorenguyen-cao.com</a> to be an server alias to blog.notedpath.com.</p>
<p>This allowed requests to blog.notedpath.com/* and theodorenguyen-cao/* respond with the same content.  I thought I was done.  I discovered this wasn&#8217;t the case when I saw blog.notedpath.com as a direct traffic source in my google analytics for <a href="http://www.theodorenguyen-cao.com">theodorenguyen-cao.com</a>.  To fix the screwed up analytics, I needed to make it so that all requests that go to blog.notedpath.com are permanently redirected (301) to <a href="http://www.theodorenguyen-cao.com">theodorenguyen-cao.com</a>.</p>
<p>To do this I had to apply an Apache mod_alias <a href="http://httpd.apache.org/docs/1.3/mod/mod_alias.html#redirect" target="_blank">redirect directive</a> as such:</p>
<pre name="code" class="xml" >
&lt;VirtualHost *:80&gt;
        VirtualDocumentRoot /var/www/blog
        ServerName blog.notedpath.com
        Redirect permanent / http://www.theodorenguyen-cao.com/
        ErrorLog /var/log/apache2/wp-error.log
        TransferLog /var/log/apache2/wp-access.log
&lt;/VirtualHost&gt;
</pre>
<p>The virtual host for <a href="http://www.theodorenguyen-cao.com">theodorenguyen-cao.com</a> looks like:</p>
<pre name="code" class="xml" >
&lt;VirtualHost *:80&gt;
    VirtualDocumentRoot /var/www/blog
    ServerName www.theodorenguyen-cao.com
    ServerAlias theodorenguyen-cao.com
    CustomLog /var/log/apache2/theodorenguyen-cao.com_access.log Combined
    ErrorLog /var/log/apache2/theodorenguyen-cao_error.log
&lt;/VirtualHost&gt;
</pre>
<p>At first I thought this would only fix the simple case of blog.notedpath.com redirecting to <a href="http://www.theodorenguyen-cao.com">theodorenguyen-cao.com</a>, but blog.notepath.com/foobar not being translated to theodorenguyen-cao.com/foobar.  However, this does exactly what I want. All blog.notedpath.com URLs will be replaced with <a href="http://www.theodorenguyen-cao.com">theodorenguyen-cao.com</a> URLs.  Old bookmarks will simply redirect to a theodorenguyen-cao.com URL and not 404.</p>
<p>Success!</p>
<p>I&#8217;m still waiting to see if Google will update the search result links that point to blog.notedpath.com to be <a href="http://www.theodorenguyen-cao.com">theodorenguyen-cao.com</a> URLs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2009/01/21/moving-wordpress-to-another-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up Phusion Passenger (mod_rails) with Capistrano support</title>
		<link>http://www.theodorenguyen-cao.com/2008/12/06/setting-up-phusion-passenger-mod_rails-with-capistrano-support/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/12/06/setting-up-phusion-passenger-mod_rails-with-capistrano-support/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 00:27:18 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.theodorenguyen-cao.com/?p=144</guid>
		<description><![CDATA[I had heard of mod_rails awhile back but never had the time to take a closer look at it. While setting up a new rails app, I was getting frustrated with all of the configuration I needed to do to get the mongrel clusters and proxy balancers setup. So I decided to give passenger a [...]]]></description>
			<content:encoded><![CDATA[<p>I had heard of mod_rails awhile back but never had the time to take a closer look at it.  While setting up a new rails app, I was getting frustrated with all of the configuration I needed to do to get the mongrel clusters and proxy balancers setup.  So I decided to give passenger a chance.  I&#8217;m a fan now <img src='http://www.theodorenguyen-cao.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The process was dead simple.</p>
<ol>
<li>Install the passenger gem
<pre class="console" name="code">sudo gem install passenger</pre>
</li>
<li>Install passenger as an Apache module
<pre class="console" name="code">passenger-install-apache2-module</pre>
</li>
<li>Load the passenger apache module by editing the Apache config
<pre class="console" name="code">
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.5/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.5
PassengerRuby /usr/bin/ruby1.8
</pre>
</li>
<li>Restart Apache</li>
</ol>
<p>If all things went well, you have everything installed you need. If there were some missing dependencies, you should be presented with how to install those dependencies.</p>
<p>In the installation output, it tells you how to mod_railsify your apps by creating a vhost as such:</p>
<pre class="console" name="code">
&lt;VirtualHost *:80&gt;
    ServerName www.mywebsite.com
    DocumentRoot /home/deploy/mywebsite/public
&lt;/VirtualHost&gt;
</pre>
<p>That&#8217;s it! No more of this proxy balancer and mongrel_cluster.yml configuration.</p>
<p>There&#8217;s some magic going on in the background.  As requests come in, passenger will spin up more application instances.  For more tweaking your configuration options check out the <a href="http://www.modrails.com/documentation/Users%20guide.html#_resource_control_and_optimization_options">user guide</a>.</p>
<p>Go to your website and you should see your rails app up and running.</p>
<p>So now we have your app up and running, how do we update or restart our app?  Passenger provides two ways for us to do this. </p>
<p>The first is whenever apache is restarted, your application is restarted.</p>
<p>The second way allows us to restart a specified application without affecting Apache.  Whenever passenger detects <code>tmp/restart.txt</code>, it will restart the application instances for us.  We can integrate this into our Capistrano deploy flow by adding the following  our <code>config/deploy.rb</code></p>
<pre name="code" class="ruby">
namespace :passenger do
  desc "Restart Application"
  task :restart do
    run "touch #{current_path}/tmp/restart.txt"
  end
end

after :deploy, "passenger:restart"
</pre>
<p>This will create that restart.txt after the cap:deploy task gets executed, causing the application to restart.</p>
<p>Finally, passenger comes with some pretty useful utilities.</p>
<p>Check out <code>passenger-status</code> which produces output showing current passenger server statuses.</p>
<p>Sample output: </p>
<pre name="code" class="console">
----------- General information -----------
max      = 6
count    = 1
active   = 0
inactive = 1
Using global queue: no
Waiting on global queue: 0

----------- Applications -----------
/home/deploy/www.myapp.com/releases/20081206183156:
  PID: 30784     Sessions: 0
</pre>
<p>Another utility <code>passenger-memory-status</code> gives you insight into how much memory is being used by apache and passenger.</p>
<p>Sample output:</p>
<pre name="code" class="console">
-------------- Apache processes ---------------
PID    PPID   Threads  VMSize    Private  Name
-----------------------------------------------
12841  1      1        225.9 MB  0.0 MB   /usr/sbin/apache2 -k start
28294  12841  1        248.4 MB  21.4 MB  /usr/sbin/apache2 -k start
28300  12841  1        243.7 MB  0.5 MB   /usr/sbin/apache2 -k start
28306  12841  1        248.4 MB  4.4 MB   /usr/sbin/apache2 -k start
28357  12841  1        249.1 MB  19.8 MB  /usr/sbin/apache2 -k start
29400  12841  1        249.4 MB  3.7 MB   /usr/sbin/apache2 -k start
29788  12841  1        249.3 MB  21.7 MB  /usr/sbin/apache2 -k start
29834  12841  1        245.8 MB  18.9 MB  /usr/sbin/apache2 -k start
29836  12841  1        245.8 MB  9.3 MB   /usr/sbin/apache2 -k start
29868  12841  1        245.8 MB  2.4 MB   /usr/sbin/apache2 -k start
29870  12841  1        246.5 MB  5.2 MB   /usr/sbin/apache2 -k start
### Processes: 11
### Total private dirty RSS: 107.44 MB

--------- Passenger processes ----------
PID    Threads  VMSize    Private  Name
----------------------------------------
28031  10       15.3 MB   0.1 MB   /usr/lib/ruby/gems/1.8/gems/passenger-2.0.5/ext/apache2/ApplicationPoolServerExecutable 0 /usr/lib/ruby/gems/1.8/gems/passenger-2.0.5/bin/passenger-spawn-server  /usr/bin/ruby1.8  /tmp/passenger_status.12841.fifo
28032  2        48.7 MB   0.6 MB   Passenger spawn server
29161  1        114.8 MB  0.7 MB   Passenger FrameworkSpawner: 2.1.2
30461  1        122.8 MB  32.3 MB  Passenger ApplicationSpawner: /home/deploy/www.myapp.com/releases/20081206183156
30784  1        129.3 MB  33.4 MB  Rails: /home/deploy/www.myapp.com/releases/20081206183156
### Processes: 5
### Total private dirty RSS: 67.08 MB
</pre>
<p>Pretty sweet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/12/06/setting-up-phusion-passenger-mod_rails-with-capistrano-support/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
