<?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>mobile and gis dev notes</title>
	<atom:link href="http:///wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>/wordpress</link>
	<description>by rupert</description>
	<lastBuildDate>Wed, 09 May 2012 00:31:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Setting up SSL https for Rails3</title>
		<link>/wordpress/2012/03/setting-up-ssl-https-for-rails3/</link>
		<comments>/wordpress/2012/03/setting-up-ssl-https-for-rails3/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 05:23:37 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[rails3]]></category>

		<guid isPermaLink="false">/wordpress/?p=1267</guid>
		<description><![CDATA[1. Generate your server.crt and server.key first. For local development, a self-signed certificate is adequate. For production, we can buy from Thawte, Verisign, the CArtels, etc. % openssl genrsa -des3 -out server.key 1024 % openssl req -new -key server.key -out server.csr % openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt Notes: Ensure [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1. Generate your server.crt and server.key first.</strong></p>
<p>For local development, <a href="http://superuser.com/questions/73979/how-to-easily-create-a-ssl-certificate-and-configure-it-in-apache2-in-mac-os-x">a self-signed certificate is adequate</a>. For production, we can <a href="http://www.williambharding.com/blog/rails/ultimate-guide-to-setup-ssl-on-rails-and-apache-2-with-ubuntu-seasoning/">buy from Thawte, Verisign, the CArtels, etc.</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #660033;">-out</span> server.key <span style="color: #000000;">1024</span>
<span style="color: #000000; font-weight: bold;">%</span> openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> server.key <span style="color: #660033;">-out</span> server.csr
<span style="color: #000000; font-weight: bold;">%</span> openssl x509 <span style="color: #660033;">-req</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">365</span> <span style="color: #660033;">-in</span> server.csr <span style="color: #660033;">-signkey</span> server.key <span style="color: #660033;">-out</span> server.crt</pre></div></div>

<p>Notes: Ensure that you use x509 because if we use the other one (PK something), then apache2 complains that it can&#8217;t load it, invalid tags.</p>
<p>The certificate (server.crt) should have the proper tags (BEGIN and END) as shown below.</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">-----BEGIN CERTIFICATE-----
MIIDBjCCAe4CCQDCzcL5z8chBzANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
......+OAFfG2MvIeawg==
-----END CERTIFICATE-----</pre></div></div>

<p><strong>2. Setup your Apache2 properly</strong></p>
<p>- Ensure that you have mod_ssl loaded</p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">LoadModule ssl_module libexec/apache22/mod_ssl.so</pre></div></div>

<p>- Enusure that you are listening to 80 and 443.</p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">Listen 80
Listen 443</pre></div></div>

<p><strong>Very Important Note:</strong> Please note that if you are not listening to these ports you might get <a href="http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#refused">&#8220;Connection Refused&#8221;</a> messages. Please make sure that your Listen directives match your <VirtualHost> directives.</p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">&lt;VirtualHost 192.168.10.1:80&gt;
   ServerAdmin rupert@2rmobile.com
   ServerName foo.2rmobile.com
   ServerAlias foo.2rmobile.com
&nbsp;
   DocumentRoot &quot;/path/to/rails/app/public&quot;
   &lt;Directory &quot;/path/to/rails/app/public&quot;&gt;
      #Options Indexes MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
   &lt;/Directory&gt;
&nbsp;
   CustomLog /var/log/httpd/myapp.log combinedio
   LogLevel warn
&lt;/VirtualHost&gt;
&nbsp;
&lt;VirtualHost 192.168.10.1:443&gt;
   ServerAdmin rupert@2rmobile.com
   ServerName foo.2rmobile.com
   ServerAlias foo.2rmobile.com
&nbsp;
   DocumentRoot &quot;/path/to/rails/app/public&quot;
   &lt;Directory &quot;/path/to/rails/app/public&quot;&gt;
      #Options Indexes MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
   &lt;/Directory&gt;
&nbsp;
   CustomLog /var/log/httpd/myapp.log combinedio
   LogLevel warn
&nbsp;
   SSLEngine on
   SSLCertificateFile /path/to/certs/server.crt
   SSLCertificateKeyFile /path/to/certs/server.key
&lt;/VirtualHost&gt;</pre></div></div>

<p>Restart! Hopefully, apache2 will load with ssl support. If not, do some googling.</p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">% /usr/local/etc/rc.d/apache22 restart #freebsd
Performing sanity check on apache22 configuration:
Syntax OK
Stopping apache22.
Waiting for PIDS: 89044.
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
% tail -f /var/log/apache2/httpd-access.log
....&quot;Apache/2.2.15 (FreeBSD) mod_ssl/2.2.15 OpenSSL/0.9.8q DAV/2 PHP/5.2.14 with Suhosin-Patch Phusion_Passenger/3.0.11 (internal dummy connection)&quot;</pre></div></div>

<p><strong>3. Configure Rails3.0.10 for rack/ssl support.</strong><br />
Read this <a href="http://collectiveidea.com/blog/archives/2010/11/29/ssl-with-rails/">http://collectiveidea.com/blog/archives/2010/11/29/ssl-with-rails/</a>. If you&#8217;re on Rails3.1? you didn&#8217;t read this <a href="http://collectiveidea.com/blog/archives/2010/11/29/ssl-with-rails/">http://collectiveidea.com/blog/archives/2010/11/29/ssl-with-rails/</a>..</p>
<p><code>Gemfile</code></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">gem <span style="color:#996600;">'rack-ssl'</span>, <span style="color:#ff3333; font-weight:bold;">:require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'rack/ssl'</span></pre></div></div>

<p><code>production.rb</code></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rack/ssl'</span>
&nbsp;
<span style="color:#6666ff; font-weight:bold;">Cws::Application</span>.<span style="color:#9900CC;">configure</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  config.<span style="color:#9900CC;">middleware</span>.<span style="color:#9900CC;">insert_before</span> <span style="color:#6666ff; font-weight:bold;">ActionDispatch::Cookies</span>, <span style="color:#6666ff; font-weight:bold;">Rack::SSL</span>
  <span style="color:#008000; font-style:italic;">#config.middleware.insert_before ActionDispatch::Cookies, Rack::SSL, :exclude =&gt; proc { |env| env['HTTPS'] != 'on' }</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Settings specified here will take precedence over those in config/application.rb</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># The production environment is meant for finished, &quot;live&quot; apps.</span>
  <span style="color:#008000; font-style:italic;"># Code is not reloaded between requests</span>
  config.<span style="color:#9900CC;">cache_classes</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Full error reports are disabled and caching is turned on</span>
  config.<span style="color:#9900CC;">consider_all_requests_local</span>       = <span style="color:#0000FF; font-weight:bold;">false</span>
  config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">perform_caching</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Specifies the header that your server uses for sending files</span>
  config.<span style="color:#9900CC;">action_dispatch</span>.<span style="color:#9900CC;">x_sendfile_header</span> = <span style="color:#996600;">&quot;X-Sendfile&quot;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># For nginx:</span>
  <span style="color:#008000; font-style:italic;"># config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># If you have no front-end server that supports something like X-Sendfile,</span>
  <span style="color:#008000; font-style:italic;"># just comment this out and Rails will serve the files</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># See everything in the log (default is :info)</span>
  <span style="color:#008000; font-style:italic;"># config.log_level = :debug</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Use a different logger for distributed setups</span>
  <span style="color:#008000; font-style:italic;"># config.logger = SyslogLogger.new</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Use a different cache store in production</span>
  <span style="color:#008000; font-style:italic;"># config.cache_store = :mem_cache_store</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Disable Rails's static asset server</span>
  <span style="color:#008000; font-style:italic;"># In production, Apache or nginx will already do this</span>
  config.<span style="color:#9900CC;">serve_static_assets</span> = <span style="color:#0000FF; font-weight:bold;">false</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Enable serving of images, stylesheets, and javascripts from an asset server</span>
  <span style="color:#008000; font-style:italic;"># config.action_controller.asset_host = &quot;http://assets.example.com&quot;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Disable delivery errors, bad email addresses will be ignored</span>
  <span style="color:#008000; font-style:italic;"># config.action_mailer.raise_delivery_errors = false</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Enable threaded mode</span>
  <span style="color:#008000; font-style:italic;"># config.threadsafe!</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Enable locale fallbacks for I18n (makes lookups for any locale fall back to</span>
  <span style="color:#008000; font-style:italic;"># the I18n.default_locale when a translation can not be found)</span>
  config.<span style="color:#9900CC;">i18n</span>.<span style="color:#9900CC;">fallbacks</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Send deprecation notices to registered listeners</span>
  config.<span style="color:#9900CC;">active_support</span>.<span style="color:#9900CC;">deprecation</span> = <span style="color:#ff3333; font-weight:bold;">:notify</span>
&nbsp;
  config.<span style="color:#9900CC;">action_mailer</span>.<span style="color:#9900CC;">default_url_options</span> = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:host</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'whatever'</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>If you want to have http and https working on both sites, then you can use</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">config.<span style="color:#9900CC;">middleware</span>.<span style="color:#9900CC;">insert_before</span> <span style="color:#6666ff; font-weight:bold;">ActionDispatch::Cookies</span>, <span style="color:#6666ff; font-weight:bold;">Rack::SSL</span>, <span style="color:#ff3333; font-weight:bold;">:exclude</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC0066; font-weight:bold;">proc</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>env<span style="color:#006600; font-weight:bold;">|</span> env<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'HTTPS'</span><span style="color:#006600; font-weight:bold;">&#93;</span> != <span style="color:#996600;">'on'</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p><strong>4. Test time!</strong><br />
- On Safari, ensure you blow away your cache.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Safari &gt; Reset
Safari &gt; Empty Cache</pre></div></div>

<p><strong>If you go to your http://server.website.com/ then it should redirect https://server.website.com/</strong></p>
<p>Note:<br />
- If  you see a &#8220;Connection Refused&#8221; or ERROR bad URI or ERROR bad Request-Line, then ensure that it&#8217;s not an apache2 misconfiguration! I got apache2 listening to 80 only but have two virtual hosts. Not easy to see especially if you have the virtual hosts included.</p>
<p>- In Google Chrome, if you get a green icon lock then it fine.<br />
<img src="/wordpress/wp-content/uploads/2012/03/trusted.png" alt="trusted.png" border="0" width="467" height="130" /></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2012/03/setting-up-ssl-https-for-rails3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>devise limit one session per user at a time</title>
		<link>/wordpress/2012/02/devise-limit-one-session-per-user-at-a-time/</link>
		<comments>/wordpress/2012/02/devise-limit-one-session-per-user-at-a-time/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 04:05:10 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[devise]]></category>

		<guid isPermaLink="false">/wordpress/?p=1253</guid>
		<description><![CDATA[A user can only be signed in a single session at a time. This means if he logged in to computer A then afterwards he logged in to computer B, then computer A times out. The original question was solved in http://stackoverflow.com/questions/7068919/devise-limit-one-session-per-user-at-a-time app/controllers/application_controller.rb class ApplicationController &#60; ActionController::Base protect_from_forgery &#160; before_filter :authenticate_user!, :check_concurrent_session, :store_location &#160; ... [...]]]></description>
			<content:encoded><![CDATA[<p>A user can only be signed in a single session at a time. This means if he logged in to computer A then afterwards he logged in to computer B, then computer A times out. The original question was solved in <a href="http://stackoverflow.com/questions/7068919/devise-limit-one-session-per-user-at-a-time">http://stackoverflow.com/questions/7068919/devise-limit-one-session-per-user-at-a-time</a></p>
<p><code>app/controllers/application_controller.rb</code></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> ApplicationController <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActionController::Base</span>
  protect_from_forgery
&nbsp;
  before_filter <span style="color:#ff3333; font-weight:bold;">:authenticate_user</span>!, <span style="color:#ff3333; font-weight:bold;">:check_concurrent_session</span>, <span style="color:#ff3333; font-weight:bold;">:store_location</span>
&nbsp;
  ... 
  <span style="color:#9966CC; font-weight:bold;">def</span> check_concurrent_session
    <span style="color:#9966CC; font-weight:bold;">if</span> is_already_logged_in?
      sign_out_and_redirect<span style="color:#006600; font-weight:bold;">&#40;</span>current_user<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> is_already_logged_in?
    current_user <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> !<span style="color:#006600; font-weight:bold;">&#40;</span>session<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:token</span><span style="color:#006600; font-weight:bold;">&#93;</span> == current_user.<span style="color:#9900CC;">login_token</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> after_sign_out_path_for<span style="color:#006600; font-weight:bold;">&#40;</span>resource<span style="color:#006600; font-weight:bold;">&#41;</span>
    loggedout_path
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><code>app/controllers/sessions_controller.rb</code></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> SessionsController <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">Devise::SessionsController</span>
&nbsp;
  skip_before_filter <span style="color:#ff3333; font-weight:bold;">:check_concurrent_session</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> create
    <span style="color:#9966CC; font-weight:bold;">super</span>
    set_login_token
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  private
  <span style="color:#9966CC; font-weight:bold;">def</span> set_login_token
    token = Devise.<span style="color:#9900CC;">friendly_token</span>
    session<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:token</span><span style="color:#006600; font-weight:bold;">&#93;</span> = token
    current_user.<span style="color:#9900CC;">login_token</span> = token
    current_user.<span style="color:#9900CC;">save</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><code>app/controllers/static_controller.rb</code></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> StaticController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
  skip_before_filter <span style="color:#ff3333; font-weight:bold;">:authenticate_user</span>!
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><code>app/views/sessions/new.html.erb</code></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;application&quot;&gt;
&nbsp;
 &lt;nav id=&quot;secondary&quot;&gt;
    &lt;ul&gt;
      &lt;li class=&quot;current&quot;&gt;&lt;%= link_to &quot;Log In&quot;, new_user_session_path %&gt;&lt;/li&gt;
      &lt;%- if devise_mapping.recoverable? &amp;&amp; controller_name != 'passwords' %&gt;
        &lt;li&gt;&lt;%= link_to &quot;Forgot Password&quot;, new_password_path(resource_name) %&gt;&lt;/li&gt;
      &lt;% end -%&gt;
    &lt;/ul&gt;
  &lt;/nav&gt;
&nbsp;
  &lt;section id=&quot;content&quot;&gt;
&nbsp;
    &lt;%= semantic_form_for(resource, :as =&gt; resource_name, :url =&gt; session_path(resource_name)) do |f| %&gt;
      &lt;section&gt;
        &lt;%= f.input :username %&gt;
      &lt;/section&gt;
&nbsp;
      &lt;section&gt;
        &lt;%= f.input :password %&gt;
      &lt;/section&gt;
&nbsp;
      &lt;%= f.buttons do %&gt;
        &lt;%= f.commit_button :label =&gt; &quot;Login&quot;, :button_html =&gt; { :class =&gt; &quot;button primary submit&quot;} %&gt;
      &lt;% end %&gt;
&nbsp;
      &lt;br/&gt;
    &lt;% end %&gt;
&nbsp;
    &lt;%= render :partial =&gt; 'layouts/devise/devise_error_messages' %&gt;
&nbsp;
  &lt;/section&gt;
&nbsp;
&lt;/div&gt;</pre></div></div>

<p><code>app/views/static/loggedout.html.erb</code></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;section id=&quot;content&quot;&gt;
&nbsp;
  &lt;h1&gt;Logged Out&lt;/h1&gt;
&nbsp;
  &lt;hr/&gt;
&nbsp;
  &lt;p&gt;This is not an error page but an indication that you have lost your session.&lt;/p&gt;
&nbsp;
  &lt;p&gt;&lt;b&gt;So why are you here?&lt;/b&gt;&lt;/p&gt;
&nbsp;
  &lt;ul&gt;
    &lt;li&gt;- You have successfully logged out after clicking the &quot;Logout&quot; button.&lt;/li&gt;
    &lt;li&gt;- You logged in to another machine so we logged this session out. We don't want to have multiple logins everywhere for security purposes.&lt;/li&gt;
    &lt;li&gt;- You have been inactive for a while, we logged this session out.&lt;/li&gt;
  &lt;/ul&gt;
&nbsp;
  &lt;p&gt;&lt;b&gt;&lt;%= link_to &quot;Login&quot;, new_user_session_path, :class =&gt; &quot;button&quot; %&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/section&gt;</pre></div></div>

<p><code>config/routes.rb</code></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  devise_for <span style="color:#ff3333; font-weight:bold;">:users</span>, <span style="color:#ff3333; font-weight:bold;">:controllers</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:sessions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;sessions&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
  ..
  <span style="color:#9900CC;">match</span> <span style="color:#996600;">&quot;loggedout&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;static#loggedout&quot;</span>
 <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><code>db/migrate/20120223022102_add_login_token_to_users.rb</code></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> AddLoginTokenToUsers <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    PgTools.<span style="color:#9900CC;">restore_default_search_path</span>
&nbsp;
    change_table <span style="color:#996600;">&quot;users&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
      t.<span style="color:#CC0066; font-weight:bold;">string</span> <span style="color:#996600;">&quot;login_token&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    PgTools.<span style="color:#9900CC;">restore_default_search_path</span>
&nbsp;
    change_table <span style="color:#996600;">&quot;users&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
      t.<span style="color:#9900CC;">remove</span> <span style="color:#996600;">&quot;login_token&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2012/02/devise-limit-one-session-per-user-at-a-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>freebsd + jdk + geoserver</title>
		<link>/wordpress/2012/02/freebsd-jdk-geoserver/</link>
		<comments>/wordpress/2012/02/freebsd-jdk-geoserver/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 00:44:02 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[freebsd]]></category>
		<category><![CDATA[geoserver]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">/wordpress/?p=1246</guid>
		<description><![CDATA[1. Install java % cd /usr/ports/java/jdk16 % make Installing java on freebsd is not fully automated, you will be prompted to download files IMPORTANT: To build the JDK 1.6.0 port, you should have at least 2.5Gb of free disk space in the build area! &#160; &#160; Due to licensing restrictions, certain files must be fetched [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1. Install java</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>jdk16
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>Installing java on freebsd is not fully automated, you will be prompted to download files</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">IMPORTANT: To build the JDK 1.6.0 port, you should have at least
2.5Gb of <span style="color: #c20cb9; font-weight: bold;">free</span> disk space <span style="color: #000000; font-weight: bold;">in</span> the build area<span style="color: #000000; font-weight: bold;">!</span>
&nbsp;
&nbsp;
 Due to licensing restrictions, certain files must be fetched manually.
&nbsp;
 Please download the Update <span style="color: #000000;">3</span> Source from
 http:<span style="color: #000000; font-weight: bold;">//</span>www.java.net<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span>jdk6<span style="color: #000000; font-weight: bold;">/</span>6u3<span style="color: #000000; font-weight: bold;">/</span>promoted<span style="color: #000000; font-weight: bold;">/</span>b05<span style="color: #000000; font-weight: bold;">/</span>jdk-6u3-fcs-src-b05-jrl-<span style="color: #000000;">24</span>_sep_2007.jar
 and the Source Binaries from
 http:<span style="color: #000000; font-weight: bold;">//</span>www.java.net<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span>jdk6<span style="color: #000000; font-weight: bold;">/</span>6u3<span style="color: #000000; font-weight: bold;">/</span>promoted<span style="color: #000000; font-weight: bold;">/</span>b05<span style="color: #000000; font-weight: bold;">/</span>jdk-6u3-fcs-bin-b05-jrl-<span style="color: #000000;">24</span>_sep_2007.jar
 and the Mozilla Headers from
 http:<span style="color: #000000; font-weight: bold;">//</span>www.java.net<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span>jdk6<span style="color: #000000; font-weight: bold;">/</span>6u3<span style="color: #000000; font-weight: bold;">/</span>promoted<span style="color: #000000; font-weight: bold;">/</span>b05<span style="color: #000000; font-weight: bold;">/</span>jdk-6u3-fcs-mozilla_headers-b05-unix-<span style="color: #000000;">24</span>_sep_2007.jar
 .
&nbsp;
 Please open http:<span style="color: #000000; font-weight: bold;">//</span>www.oracle.com<span style="color: #000000; font-weight: bold;">/</span>technetwork<span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>javase<span style="color: #000000; font-weight: bold;">/</span>downloads<span style="color: #000000; font-weight: bold;">/</span>index.html
 <span style="color: #000000; font-weight: bold;">in</span> a web browser and follow the <span style="color: #ff0000;">&quot;Download&quot;</span> <span style="color: #c20cb9; font-weight: bold;">link</span> <span style="color: #000000; font-weight: bold;">for</span>
 <span style="color: #ff0000;">&quot;JDK DST Timezone Update Tool - 1_3_45&quot;</span> to obtain the
 <span style="color: #000000; font-weight: bold;">time</span> zone update <span style="color: #c20cb9; font-weight: bold;">file</span>, tzupdater-<span style="color: #000000;">1</span>_3_45-2011n.zip.
&nbsp;
 Please download the patchset, bsd-jdk16-patches-4.tar.bz2, from
 http:<span style="color: #000000; font-weight: bold;">//</span>www.eyesbeyond.com<span style="color: #000000; font-weight: bold;">/</span>freebsddom<span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>jdk16.html.
&nbsp;
 Please place the downloaded <span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>distfiles 
 and restart the build.
&nbsp;
<span style="color: #000000; font-weight: bold;">***</span> Error code <span style="color: #000000;">1</span>
&nbsp;
Stop <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>jdk16.
<span style="color: #000000; font-weight: bold;">***</span> Error code <span style="color: #000000;">1</span>
&nbsp;
Stop <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>jdk16.
<span style="color: #000000; font-weight: bold;">***</span> Error code <span style="color: #000000;">1</span></pre></div></div>

<p>These files are:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>distfiles
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.java.net<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span>jdk6<span style="color: #000000; font-weight: bold;">/</span>6u3<span style="color: #000000; font-weight: bold;">/</span>promoted<span style="color: #000000; font-weight: bold;">/</span>b05<span style="color: #000000; font-weight: bold;">/</span>jdk-6u3-fcs-src-b05-jrl-<span style="color: #000000;">24</span>_sep_2007.jar
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.java.net<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span>jdk6<span style="color: #000000; font-weight: bold;">/</span>6u3<span style="color: #000000; font-weight: bold;">/</span>promoted<span style="color: #000000; font-weight: bold;">/</span>b05<span style="color: #000000; font-weight: bold;">/</span>jdk-6u3-fcs-bin-b05-jrl-<span style="color: #000000;">24</span>_sep_2007.jar
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.java.net<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span>jdk6<span style="color: #000000; font-weight: bold;">/</span>6u3<span style="color: #000000; font-weight: bold;">/</span>promoted<span style="color: #000000; font-weight: bold;">/</span>b05<span style="color: #000000; font-weight: bold;">/</span>jdk-6u3-fcs-mozilla_headers-b05-unix-<span style="color: #000000;">24</span>_sep_2007.jar
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #666666; font-style: italic;"># download manually tzupdater-1_3_45-2011n.zip from http://www.oracle.com/technetwork/java/javase/downloads/index.html</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #666666; font-style: italic;"># download manually bsd-jdk16-patches-4.tar.bz2 from http://www.eyesbeyond.com/freebsddom/java/jdk16.html</span></pre></div></div>

<p><strong>2. Run make</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>jdk16
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><strong>3. Install geoserver</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>graphics<span style="color: #000000; font-weight: bold;">/</span>geoserver
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><strong>4. Startup geoserver</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.conf
<span style="color: #007800;">geoserver_enable</span>=YES</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.d<span style="color: #000000; font-weight: bold;">/</span>geoserver start</pre></div></div>

<p><strong>5. Browse</strong> <a href="http://127.0.0.1:8080/geoserver/">http://127.0.0.1:8080/geoserver/</a></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2012/02/freebsd-jdk-geoserver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>freebsd + apache + php</title>
		<link>/wordpress/2012/02/freebsd-apache-php/</link>
		<comments>/wordpress/2012/02/freebsd-apache-php/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 00:30:41 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[freebsd]]></category>

		<guid isPermaLink="false">/wordpress/?p=1244</guid>
		<description><![CDATA[1. Install apache22 % cd /usr/ports/www/apache22 % make config % make install clean % vim /etc/rc.conf apache22_enable=YES /usr/local/etc/rc.d/apache22 start 2. Install php52 % cd /usr/ports/lang/php52 % make config #enable APACHE module % make % make install clean Installing PHP CLI binary: /usr/local/bin/ Installing PHP CLI man page: /usr/local/man/man1/ Installing PHP CGI binary: /usr/local/bin/ Installing build [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1. Install apache22</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>apache22
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> config
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.conf
<span style="color: #007800;">apache22_enable</span>=YES</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">/usr/local/etc/rc.d/apache22 start</pre></div></div>

<p><strong>2. Install php52</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>lang<span style="color: #000000; font-weight: bold;">/</span>php52
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> config <span style="color: #666666; font-style: italic;">#enable APACHE module</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean
Installing PHP CLI binary:        <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>
Installing PHP CLI <span style="color: #c20cb9; font-weight: bold;">man</span> page:      <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>man<span style="color: #000000; font-weight: bold;">/</span>man1<span style="color: #000000; font-weight: bold;">/</span>
Installing PHP CGI binary: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>
Installing build environment:     <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>build<span style="color: #000000; font-weight: bold;">/</span>
Installing header files:          <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>
Installing helper programs:       <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>
  program: phpize
  program: php-config
....
      This port has installed the following files <span style="color: #c20cb9; font-weight: bold;">which</span> may act <span style="color: #c20cb9; font-weight: bold;">as</span> network
      servers and may therefore pose a remote security risk to the system.
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>apache22<span style="color: #000000; font-weight: bold;">/</span>libphp5.so
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-cgi
...</pre></div></div>

<p><img src="/wordpress/wp-content/uploads/2012/02/enable_apache.png" alt="enable_apache.png" border="0" width="495" height="168" /></p>
<p><strong>3 Configure Apache for php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache22<span style="color: #000000; font-weight: bold;">/</span>httpd.conf</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">LoadModule php5_module        libexec/apache22/libphp5.so</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">&lt;IfModule dir_module&gt;
    DirectoryIndex index.html index.php
&lt;/IfModule&gt;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">&lt;IfModule mime_module&gt;
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
&lt;/IfModule&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2012/02/freebsd-apache-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>please install libyaml and reinstall your ruby.</title>
		<link>/wordpress/2012/02/please-install-libyaml-and-reinstall-your-ruby/</link>
		<comments>/wordpress/2012/02/please-install-libyaml-and-reinstall-your-ruby/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 00:01:25 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[rvm]]></category>

		<guid isPermaLink="false">/wordpress/?p=1232</guid>
		<description><![CDATA[/Users/rupert/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/yaml.rb:56:in `&#60;top (required)&#62;': It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. ~% rvm remove ruby-1.9.3-p0 Removing /Users/rupert/.rvm/src/ruby-1.9.3-p0... Removing /Users/rupert/.rvm/rubies/ruby-1.9.3-p0... Removing ruby-1.9.3-p0 aliases... Removing ruby-1.9.3-p0 wrappers... Removing ruby-1.9.3-p0 environments... Removing ruby-1.9.3-p0 binaries... ~% rvm list rvm rubies &#160; ruby-1.8.7-p302 [ x86_64 ] [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">/Users/rupert/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/yaml.rb:56:in `&lt;top (required)&gt;':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~% rvm remove ruby-1.9.3-p0
Removing /Users/rupert/.rvm/src/ruby-1.9.3-p0...
Removing /Users/rupert/.rvm/rubies/ruby-1.9.3-p0...
Removing ruby-1.9.3-p0 aliases...
Removing ruby-1.9.3-p0 wrappers...
Removing ruby-1.9.3-p0 environments...
Removing ruby-1.9.3-p0 binaries...</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~% rvm list
rvm rubies
&nbsp;
   ruby-1.8.7-p302 [ x86_64 ]
   ruby-1.9.2-p0 [ x86_64 ]
=&gt; ruby-1.9.2-p180 [ x86_64 ]</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~% rvm install ruby-1.9.3-p0
/Users/rupert/.rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your cpu(s)...
&nbsp;
ruby-1.9.3-p0 - #fetching 
ruby-1.9.3-p0 - #extracting ruby-1.9.3-p0 to /Users/rupert/.rvm/src/ruby-1.9.3-p0
ruby-1.9.3-p0 - #extracted to /Users/rupert/.rvm/src/ruby-1.9.3-p0
ruby-1.9.3-p0 - #configuring 
ruby-1.9.3-p0 - #compiling 
ruby-1.9.3-p0 - #installing 
ruby-1.9.3-p0 - updating #rubygems for /Users/rupert/.rvm/gems/ruby-1.9.3-p0@global
ruby-1.9.3-p0 - updating #rubygems for /Users/rupert/.rvm/gems/ruby-1.9.3-p0
ruby-1.9.3-p0 - adjusting #shebangs for (gem).
ruby-1.9.3-p0 - #importing default gemsets (/Users/rupert/.rvm/gemsets/)</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~% rvm list
&nbsp;
rvm rubies
&nbsp;
   ruby-1.8.7-p302 [ x86_64 ]
   ruby-1.9.2-p0 [ x86_64 ]
=&gt; ruby-1.9.2-p180 [ x86_64 ]
   ruby-1.9.3-p0 [ x86_64 ]</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~% rvm use ruby-1.9.3-p0
Using /Users/rupert/.rvm/gems/ruby-1.9.3-p0</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~/current[master]% gem list
&nbsp;
*** LOCAL GEMS ***
&nbsp;
rake (0.9.2.2)
rubygems-update (1.8.15)</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2012/02/please-install-libyaml-and-reinstall-your-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nominatim (Reverse Geocoder) via PL/PYTHON for RubyOnRails Mapping App</title>
		<link>/wordpress/2012/01/nominatim-reverse-geocoder-via-plpython-for-rubyonrails-app/</link>
		<comments>/wordpress/2012/01/nominatim-reverse-geocoder-via-plpython-for-rubyonrails-app/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 04:16:17 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[geocoding]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[nominatim]]></category>

		<guid isPermaLink="false">/wordpress/?p=1190</guid>
		<description><![CDATA[Even google maps enterprise have restrictions on their geocoding/reverse-geocoding services, 100k if my memory serves me correctly. So, I have to rollout our own service to allow millions of lonlats for reverse geocoding. Have a look at Nominatim, yes it&#8217;s opensource. If you need to get it up and running, have a read of my [...]]]></description>
			<content:encoded><![CDATA[<p>Even google maps enterprise have restrictions on their geocoding/reverse-geocoding services, 100k if my memory serves me correctly.  So, I have to rollout our own service to allow millions of lonlats for reverse geocoding.  Have a look at <a href="http://wiki.openstreetmap.org/wiki/Nominatim">Nominatim</a>, yes it&#8217;s opensource. If you need to get it up and running, have a read of my <a href="/wordpress/2011/11/nominatim-on-osx/">nominatim installation via homebrew on OSX.</a></p>
<p>The nominatim www interface which spits out <a href="http://open.mapquestapi.com/nominatim/v1/reverse?format=xml&#038;lat=-37.856206&#038;lon=145.233980" target="_blank"><code>xml/json</code></a> depending on the format parameter is done in php. </p>
<p>Anyway, I wanted to expose/use this webservice for our Rails3 app. It will also be good if we don&#8217;t use the nominatim webservice all the time if the lonlat was already requested&#8211;caching.</p>
<p><strong>Python-Nominatim</strong> <a href="https://github.com/rdeguzman/python-nominatim">https://github.com/rdeguzman/python-nominatim</a></p>
<p>This project was forked from <a href="https://github.com/agabel/python-nominatim.git">Austin&#8217;s Gabels python-nominatim. </a>  I added the ability to pass a <code>base_url</code> to the classes and added <code>reverse_geocode.py</code>. So assuming you have Python installed, you can do a reverse geocode like this&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> nominatim <span style="color: #ff7700;font-weight:bold;">import</span> ReverseGeocoder
client = ReverseGeocoder<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://127.0.0.1/nominatim/reverse.php?format=json&quot;</span><span style="color: black;">&#41;</span>
response = client.<span style="color: black;">geocode</span><span style="color: black;">&#40;</span>-<span style="color: #ff4500;">37.856206</span>, <span style="color: #ff4500;">145.233980</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> response<span style="color: black;">&#91;</span><span style="color: #483d8b;">'full_address'</span><span style="color: black;">&#93;</span>
<span style="color: #808080; font-style: italic;">#Amesbury Avenue, Wantirna, City of Knox, 3152, Australia</span></pre></div></div>

<p><strong>PL/PYTHON</strong><br />
Now we wrap this python code via PL/PYTHON so Postgres can call it. Checkout <a href="https://github.com/rdeguzman/python-nominatim/blob/master/setup.sql">setup.sql</a></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURAL</span> <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #ff0000;">'plpythonu'</span> HANDLER plpython_call_handler;
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> reverse_geocode<span style="color: #66cc66;">&#40;</span>geocoding_url text<span style="color: #66cc66;">,</span> latitude float<span style="color: #66cc66;">,</span> longitude float<span style="color: #66cc66;">&#41;</span> RETURNS
  text
  <span style="color: #993333; font-weight: bold;">AS</span>
  $$
    import nominatim
    client <span style="color: #66cc66;">=</span> nominatim<span style="color: #66cc66;">.</span>ReverseGeocoder<span style="color: #66cc66;">&#40;</span>geocoding_url<span style="color: #66cc66;">&#41;</span>
    response <span style="color: #66cc66;">=</span> client<span style="color: #66cc66;">.</span>geocode<span style="color: #66cc66;">&#40;</span>latitude<span style="color: #66cc66;">,</span> longitude<span style="color: #66cc66;">&#41;</span>
    <span style="color: #993333; font-weight: bold;">RETURN</span> response<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'full_address'</span><span style="color: #66cc66;">&#93;</span>
  $$
  <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #ff0000;">'plpythonu'</span>;</pre></div></div>

<p>With the snippet above, we can now call this with a regular SELECT statement&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> reverse_geocode<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'http://127.0.0.1/nominatim/reverse.php?format=json'</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-</span><span style="color: #cc66cc;">37.856206</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">145.233980</span><span style="color: #66cc66;">&#41;</span>; 
                       reverse_geocode
  <span style="color: #808080; font-style: italic;">----------------------------------------------------------</span>
   Amesbury Avenue<span style="color: #66cc66;">,</span> Wantirna<span style="color: #66cc66;">,</span> City of Knox<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">3152</span><span style="color: #66cc66;">,</span> Australia
  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span> row<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p><strong>Rails ActiveRecord</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    create_table <span style="color:#ff3333; font-weight:bold;">:locations</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
      t.<span style="color:#CC0066; font-weight:bold;">float</span>    <span style="color:#ff3333; font-weight:bold;">:latitude</span>
      t.<span style="color:#CC0066; font-weight:bold;">float</span>    <span style="color:#ff3333; font-weight:bold;">:longitude</span>
      t.<span style="color:#9900CC;">text</span>     <span style="color:#ff3333; font-weight:bold;">:address</span>
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>In AR, I created a <code>location</code> model above and exposed a <code>reverse_geocode</code> method below</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Location <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">reverse_geocode</span><span style="color:#006600; font-weight:bold;">&#40;</span>geocode_url, lat, lon<span style="color:#006600; font-weight:bold;">&#41;</span>
    sql_string = <span style="color:#996600;">&quot;SELECT reverse_geocode('#{geocode_url}', #{lat}, #{lon}) as address, #{lat} as latitude, #{lon} as longitude&quot;</span>
    loc_array = <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">find_by_sql</span> sql_string
    loc_array<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>So now, in one of my models, I could simply do..</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> ActiveSession <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
...
  <span style="color:#9966CC; font-weight:bold;">def</span> location_address
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">has_gps</span>?
      loc = Location.<span style="color:#9900CC;">reverse_geocode</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'http://path/to/reverse.php?format=json'</span>, <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">gps_latitude</span>, <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">gps_longitude</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      loc.<span style="color:#9900CC;">address</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#0000FF; font-weight:bold;">nil</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
...
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>In the view, we can simple call <code>model.location_address</code> to retrieve the location details. Below is a code snippet which creates a google marker and adds the location details in the infoWindow.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;%</span> location <span style="color: #339933;">=</span> active_session.<span style="color: #660066;">location_address</span> <span style="color: #339933;">%&gt;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> latlong <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">LatLng</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&lt;%=</span> active_session.<span style="color: #660066;">gps_latitude</span> <span style="color: #339933;">%&gt;,</span> <span style="color: #339933;">&lt;%=</span> active_session.<span style="color: #660066;">gps_longitude</span> <span style="color: #339933;">%&gt;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> content <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;div style=&quot;width: 300px;&quot;&gt;'</span><span style="color: #339933;">;</span>
content <span style="color: #339933;">=</span> content <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;p&gt;&lt;%= escape_javascript location %&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
content <span style="color: #339933;">=</span> content <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;p&gt;&lt;%= active_session.gps_longitude %&gt;,&lt;%= active_session.gps_latitude %&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span></pre></div></div>

<p><img src="/wordpress/wp-content/uploads/2012/01/marker.png" alt="marker.png" border="0" width="413" height="373" /></p>
<p><strong>Caching</strong><br />
Our last step is to improve performance via caching. I have opted to do this from the PL/PYTHON end but using a Rails activerecord model/table.  This way, the Rails activerecord has no idea that it is cached when it calls <code>model.location_address</code>. Below, I wrap the new <code>reverse_geocode PL/PYTHON function</code> in a rails migration.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> CreateFunctionReverseGeocoder <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">connection</span>.<span style="color:#9900CC;">schema_search_path</span> = <span style="color:#996600;">&quot;public&quot;</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    execute <span style="color:#996600;">'CREATE OR REPLACE FUNCTION reverse_geocode(geocoding_url text, latitude float, longitude float) RETURNS
      text
      AS
      $$
        plan = plpy.prepare(&quot;SELECT address FROM locations WHERE latitude = $1 AND longitude = $2&quot;, [ &quot;float&quot;, &quot;float&quot; ])
        rv = plpy.execute(plan, [ latitude, longitude ], 1)
&nbsp;
        if rv.nrows() &gt; 0:
          result = rv[0][&quot;address&quot;]
        else:
          import nominatim
          client = nominatim.ReverseGeocoder(geocoding_url)
          response = client.geocode(latitude, longitude)
          result = response[&quot;full_address&quot;]
          insert_plan = plpy.prepare(&quot;INSERT INTO locations(latitude, longitude, address) VALUES($1, $2, $3)&quot;, [&quot;float&quot;, &quot;float&quot;, &quot;text&quot;])
          plpy.execute(insert_plan, [ latitude, longitude, result ])
&nbsp;
        return result
      $$
      language plpythonu;'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    execute <span style="color:#996600;">'DROP FUNCTION IF EXISTS reverse_geocode(text, double precision, double precision);'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><strong>Benchmarks</strong><br />
I plotted 1000 records on my MBP (old core2duo early 2009 4GB RAM). Initial launch takes 108 seconds to load, ~ 2 minutes? But subsequent requests loads < 2 secs.</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">For 1000 records:
Completed 200 OK in 110478ms (Views: 1608.8ms | ActiveRecord: 108674.6ms)
Completed 200 OK in 1744ms (Views: 1110.7ms | ActiveRecord: 443.3ms)</pre></div></div>

<p>Below is an architecture diagram of how the systems talk to each other. The locations cache is inside the geo_app_development db. Ofcourse, the nominatim database (gazetteer_au) is separate from our domain so it goes into a different db/server whereever.<br />
<img src="/wordpress/wp-content/uploads/2012/01/archi.png" alt="archi.png" border="0" width="604" height="534" /></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2012/01/nominatim-reverse-geocoder-via-plpython-for-rubyonrails-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>homebrew + python</title>
		<link>/wordpress/2011/12/homebrew-python/</link>
		<comments>/wordpress/2011/12/homebrew-python/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 21:14:06 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[homebrew]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">/wordpress/?p=1140</guid>
		<description><![CDATA[Read http://docs.python-guide.org/en/latest/starting/installation/ Installation /usr/local/Cellar% brew install python --framework ==&#62; Downloading http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2 File already downloaded in /Users/rupert/Library/Caches/Homebrew ==&#62; Patching patching file Lib/whichdb.py Hunk #1 succeeded at 91 with fuzz 1. ==&#62; ./configure --prefix=/usr/local/Cellar/python/2.7.2 --enable-framework=/usr/local/Cellar/python/2.7.2/Frameworks ==&#62; make ==&#62; make install ==&#62; Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.24.tar.gz File already downloaded in /Users/rupert/Library/Caches/Homebrew ==&#62; /usr/local/Cellar/python/2.7.2/bin/python setup.py install ==&#62; Caveats A &#34;distutils.cfg&#34; has [...]]]></description>
			<content:encoded><![CDATA[<p>Read <a href="http://docs.python-guide.org/en/latest/starting/installation/">http://docs.python-guide.org/en/latest/starting/installation/</a></p>
<p><strong>Installation</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">/usr/local/Cellar% brew install python --framework
==&gt; Downloading http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
File already downloaded in /Users/rupert/Library/Caches/Homebrew
==&gt; Patching
patching file Lib/whichdb.py
Hunk #1 succeeded at 91 with fuzz 1.
==&gt; ./configure --prefix=/usr/local/Cellar/python/2.7.2 --enable-framework=/usr/local/Cellar/python/2.7.2/Frameworks
==&gt; make
==&gt; make install
==&gt; Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.24.tar.gz
File already downloaded in /Users/rupert/Library/Caches/Homebrew
==&gt; /usr/local/Cellar/python/2.7.2/bin/python setup.py install
==&gt; Caveats
A &quot;distutils.cfg&quot; has been written to:
  /usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils
specifing the install-scripts folder as:
  /usr/local/share/python
&nbsp;
If you install Python packages via &quot;python setup.py install&quot;, easy_install, pip,
any provided scripts will go into the install-scripts folder above, so you may
want to add it to your PATH.
&nbsp;
Distribute has been installed, so easy_install is available.
To update distribute itself outside of Homebrew:
    /usr/local/share/python/easy_install pip
    /usr/local/share/python/pip install --upgrade distribute
&nbsp;
See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
&nbsp;
Framework Python was installed to:
  /usr/local/Cellar/python/2.7.2/Frameworks/Python.framework
&nbsp;
You may want to symlink this Framework to a standard OS X location,
such as:
    mkdir ~/Frameworks
    ln -s &quot;/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework&quot; ~/Frameworks
==&gt; Summary
/usr/local/Cellar/python/2.7.2: 4808 files, 77M, built in 86 seconds
brew install python --framework  76.78s user 21.49s system 112% cpu 1:27.00 total</pre></div></div>

<p><strong>Symlinks</strong></p>
<p>The following links were created below to ensure that 2.7 is the latest Python picked up during installation of other software (i.e postgresql)</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">sudo ln -s /usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions/2.7
sudo ln -s /usr/local/share/python/easy_install /usr/bin/easy_install
sudo ln -s /usr/local/share/python/easy_install-2.7 /usr/bin/easy_install-2.7
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /usr/bin/python2.7
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config /usr/bin/python2.7-config
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7 /usr/bin/pydoc2.7
sudo ln -s /usr/bin/python2.7 /usr/bin/python
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions/Current
mkdir -p /Library/Python/2.7
ln -s /usr/local/lib/python2.7/site-packages /Library/Python/2.7/site-packages</pre></div></div>

<p><strong>Site-Packages. Where?</strong></p>
<p>Note that <strong>site-packages</strong> will be installed in</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">/usr/local/lib/python2.7/site-packages</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~% ls -la /Library/Python/2.6/site-packages
total 136
drwxrwxr-x  14 root    admin    476 30 Dec 18:13 ./
drwxrwxr-x   4 root    admin    136 30 Dec 18:11 ../
-rw-r--r--@  1 rupert  admin   6148 30 Dec 18:13 .DS_Store
-rw-rw-r--   1 root    admin    119 11 Feb  2010 README
-rw-r--r--   1 rupert  admin    241 30 Dec 18:01 easy-install.pth
-rw-r--r--   1 rupert  admin   3129 30 Dec 18:02 googlemaps-1.0.2-py2.6.egg-info
-rw-r--r--   1 rupert  admin  19703 16 Oct  2009 googlemaps.py
-rw-r--r--   1 rupert  admin  19153 30 Dec 18:02 googlemaps.pyc
drwxr-xr-x  39 root    admin   1326  7 Feb  2010 mod_python/
-rw-r--r--   1 root    admin    267  7 Feb  2010 mod_python-3.3.2_dev_20080819-py2.6.egg-info
drwxr-xr-x   8 rupert  admin    272 30 Dec 18:13 nominatim/
-rw-r--r--   1 rupert  admin   4462 30 Dec 18:08 nominatim-0.90-py2.6.egg
drwxr-xr-x  15 rupert  admin    510 30 Dec 18:01 simplejson/
drwxr-xr-x   4 rupert  admin    136 30 Dec 18:13 simplejson-2.3.1-py2.6.egg/
~% ls -la /Library/Python/2.7/site-packages
lrwxr-xr-x  1 root  admin  38 30 Dec 18:23 /Library/Python/2.7/site-packages@ -&gt; /usr/local/lib/python2.7/site-packages</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~% which python
/usr/local/bin/python
~% python --version
Python 2.7.2</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/12/homebrew-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing PHP on OSX</title>
		<link>/wordpress/2011/12/installing-php-on-osx/</link>
		<comments>/wordpress/2011/12/installing-php-on-osx/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 09:22:20 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">/wordpress/?p=1132</guid>
		<description><![CDATA[I need wordpress + nominatim running on OSX and since it uses php&#8230; http://www.php.net/manual/en/install.unix.apache2.php 1. Installation ./configure --prefix=/usr/local/php-5.3.8 --with-mysql --with-pgsql=/usr/local/postgresql --with-apxs2=/usr/local/apache2/bin/apxs make sudo make install rupert-mbp~/Desktop/php-5.3.8% sudo make install Password: Installing PHP SAPI module: apache2handler /usr/local/apache2.2.14/build/instdso.sh SH_LIBTOOL='/usr/local/apache2.2.14/build/libtool' libs/libphp5.so /usr/local/apache2.2.14/modules /usr/local/apache2.2.14/build/libtool --mode=install cp libs/libphp5.so /usr/local/apache2.2.14/modules/ cp libs/libphp5.so /usr/local/apache2.2.14/modules/libphp5.so Warning! dlname not found in /usr/local/apache2.2.14/modules/libphp5.so. Assuming installing [...]]]></description>
			<content:encoded><![CDATA[<p>I need wordpress + nominatim running on OSX and since it uses php&#8230;</p>
<p><a href="http://www.php.net/manual/en/install.unix.apache2.php">http://www.php.net/manual/en/install.unix.apache2.php</a></p>
<p><strong>1. Installation</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">./configure --prefix=/usr/local/php-5.3.8 --with-mysql --with-pgsql=/usr/local/postgresql --with-apxs2=/usr/local/apache2/bin/apxs
make
sudo make install</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">rupert-mbp~/Desktop/php-5.3.8% sudo make install
Password:
Installing PHP SAPI module:       apache2handler
/usr/local/apache2.2.14/build/instdso.sh SH_LIBTOOL='/usr/local/apache2.2.14/build/libtool' libs/libphp5.so /usr/local/apache2.2.14/modules
/usr/local/apache2.2.14/build/libtool --mode=install cp libs/libphp5.so /usr/local/apache2.2.14/modules/
cp libs/libphp5.so /usr/local/apache2.2.14/modules/libphp5.so
Warning!  dlname not found in /usr/local/apache2.2.14/modules/libphp5.so.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/local/apache2.2.14/modules/libphp5.so
[activating module `php5' in /usr/local/apache2.2.14/conf/httpd.conf]
Installing PHP CLI binary:        /usr/local/php-5.3.8/bin/
Installing PHP CLI man page:      /usr/local/php-5.3.8/man/man1/
Installing build environment:     /usr/local/php-5.3.8/lib/php/build/
Installing header files:          /usr/local/php-5.3.8/include/php/
Installing helper programs:       /usr/local/php-5.3.8/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php-5.3.8/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php-5.3.8/lib/php/
[PEAR] Archive_Tar    - installed: 1.3.7
[PEAR] Console_Getopt - installed: 1.3.0
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util       - installed: 1.2.1
[PEAR] PEAR           - installed: 1.9.4
Wrote PEAR system config file at: /usr/local/php-5.3.8/etc/pear.conf
You may want to add: /usr/local/php-5.3.8/lib/php to your php.ini include_path
/Users/rupert/Desktop/php-5.3.8/build/shtool install -c ext/phar/phar.phar /usr/local/php-5.3.8/bin
ln -s -f /usr/local/php-5.3.8/bin/phar.phar /usr/local/php-5.3.8/bin/phar
Installing PDO headers:          /usr/local/php-5.3.8/include/php/ext/pdo/
sudo make install  5.52s user 9.35s system 79% cpu 18.819 total</pre></div></div>

<p><strong>2. Configuration</strong><br />
Specify php.ini per virtualhost<br />
<VirtualHost 127.0.0.1:80><br />
  PHPINIDir /etc<br />
</VirtualHost></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/12/installing-php-on-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>freebsd + apache + rvm + rails + passenger</title>
		<link>/wordpress/2011/11/freebsd-rvm-rails-passenger/</link>
		<comments>/wordpress/2011/11/freebsd-rvm-rails-passenger/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 02:10:44 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[freebsd]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rvm]]></category>

		<guid isPermaLink="false">/wordpress/?p=1114</guid>
		<description><![CDATA[1. Install apache22 % cd /usr/ports/www/apache22 % make config % make install clean % vim /etc/rc.conf apache22_enable=YES /usr/local/etc/rc.d/apache22 start 2. Install rvm via multi user install from http://beginrescueend.com/rvm/install/ Login as root. % bash -s stable &#60; &#60;&#40;curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer&#41; Downloading RVM from wayneeseguin branch stable % Total % Received % Xferd Average Speed Time Time [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1. Install apache22</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>apache22
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> config
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.conf
<span style="color: #007800;">apache22_enable</span>=YES</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">/usr/local/etc/rc.d/apache22 start</pre></div></div>

<p><strong>2. Install <a href="http://beginrescueend.com/rvm/install/">rvm via multi user install from http://beginrescueend.com/rvm/install/</a></strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Login <span style="color: #c20cb9; font-weight: bold;">as</span> root.
<span style="color: #000000; font-weight: bold;">%</span>  <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-s</span> stable <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>curl <span style="color: #660033;">-s</span> https:<span style="color: #000000; font-weight: bold;">//</span>raw.github.com<span style="color: #000000; font-weight: bold;">/</span>wayneeseguin<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #000000; font-weight: bold;">/</span>master<span style="color: #000000; font-weight: bold;">/</span>binscripts<span style="color: #000000; font-weight: bold;">/</span>rvm-installer<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Downloading RVM from wayneeseguin branch stable
  <span style="color: #000000; font-weight: bold;">%</span> Total    <span style="color: #000000; font-weight: bold;">%</span> Received <span style="color: #000000; font-weight: bold;">%</span> Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
<span style="color: #000000;">100</span>  799k  <span style="color: #000000;">100</span>  799k    <span style="color: #000000;">0</span>     <span style="color: #000000;">0</span>   109k      <span style="color: #000000;">0</span>  <span style="color: #000000;">0</span>:00:07  <span style="color: #000000;">0</span>:00:07 --:--:--  199k
&nbsp;
Installing RVM to <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #000000; font-weight: bold;">/</span>
    RVM system user group <span style="color: #ff0000;">'rvm'</span> exists, proceeding with installation.
&nbsp;
<span style="color: #666666; font-style: italic;"># RVM:  Shell scripts enabling management of multiple ruby environments.</span>
<span style="color: #666666; font-style: italic;"># RTFM: https://rvm.beginrescueend.com/</span>
<span style="color: #666666; font-style: italic;"># HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)</span>
<span style="color: #666666; font-style: italic;"># Screencast: http://screencasts.org/episodes/how-to-use-rvm</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># In case of any issues read output of 'rvm requirements' and/or 'rvm notes'</span>
&nbsp;
Installation of RVM <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #000000; font-weight: bold;">/</span> is almost <span style="color: #7a0874; font-weight: bold;">complete</span>:
&nbsp;
  <span style="color: #000000; font-weight: bold;">*</span> First you need add all <span style="color: #c20cb9; font-weight: bold;">users</span> that will be using rvm to <span style="color: #ff0000;">'rvm'</span> group,
    anyone using rvm will be operating with <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">umask</span> g+<span style="color: #c20cb9; font-weight: bold;">w</span><span style="color: #000000; font-weight: bold;">`</span>.
&nbsp;
  <span style="color: #000000; font-weight: bold;">*</span> To start using RVM you need to run <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>profile.d<span style="color: #000000; font-weight: bold;">/</span>rvm.sh<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #000000; font-weight: bold;">in</span> all your open shell windows, <span style="color: #000000; font-weight: bold;">in</span> rare cases you need to reopen all shell windows.
&nbsp;
  <span style="color: #000000; font-weight: bold;">*</span> Optionally you can run <span style="color: #000000; font-weight: bold;">`</span>rvm tools rvm-env ruby <span style="color: #c20cb9; font-weight: bold;">bash</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #c20cb9; font-weight: bold;">which</span> will generate 
    shebang wrappers <span style="color: #000000; font-weight: bold;">for</span> easier selecting ruby <span style="color: #000000; font-weight: bold;">in</span> scripts.
&nbsp;
<span style="color: #666666; font-style: italic;"># root,</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   Thank you for using RVM!</span>
<span style="color: #666666; font-style: italic;">#   I sincerely hope that RVM helps to make your life easier and more enjoyable!!!</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># ~Wayne</span></pre></div></div>

<p><strong>3. Add your users to rvm group</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># vim /etc/group</span>
....
rvm:<span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">1003</span>:root,rupert</pre></div></div>

<p><strong>Load rvm script to current shell by calling <code>source /etc/profile.d/rvm.sh</code></strong> or add it to /etc/profile and re-login</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#vim /etc/profile</span>
<span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>profile.d<span style="color: #000000; font-weight: bold;">/</span>rvm.sh</pre></div></div>

<p>After relogging in, simply type <code>rvm</code> and it should spit out something. If the command is not found, then you are doing something wrong.</p>
<p><strong>4. Install 1.9.3</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% rvm install 1.9.3
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your cpu(s)...
&nbsp;
ruby-1.9.3-p0 - #fetching 
ruby-1.9.3-p0 - #downloading ruby-1.9.3-p0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  3 8604k    3  340k    0     0  27173      0  0:05:24  0:00:12  0:05:12 64100</pre></div></div>

<p>Use ruby1.9.3</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% rvm --default use 1.9.3-p0
% gem install bundler -V</pre></div></div>

<p><strong>5. Install passenger3</strong></p>
<p>This will install system wide passenger gem which is installed on 1.9.3-p0 gemset.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> passenger <span style="color: #660033;">-V</span></pre></div></div>

<p>You should have at least the ff gems installed:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">bundler <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.1.3<span style="color: #7a0874; font-weight: bold;">&#41;</span>
daemon_controller <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.0.0<span style="color: #7a0874; font-weight: bold;">&#41;</span>
fastthread <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.0.7<span style="color: #7a0874; font-weight: bold;">&#41;</span>
passenger <span style="color: #7a0874; font-weight: bold;">&#40;</span>3.0.12<span style="color: #7a0874; font-weight: bold;">&#41;</span>
rack <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.4.1<span style="color: #7a0874; font-weight: bold;">&#41;</span>
rake <span style="color: #7a0874; font-weight: bold;">&#40;</span>0.9.2.2<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.3-p0<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-3.0.11<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #000000; font-weight: bold;">%</span> .<span style="color: #000000; font-weight: bold;">/</span>passenger-install-apache2-module</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">--------------------------------------------
The Apache 2 module was successfully installed.
&nbsp;
Please edit your Apache configuration file, and add these lines:
&nbsp;
   LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11
   PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p0/ruby
&nbsp;
After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!
&nbsp;
Press ENTER to continue.
&nbsp;
&nbsp;
--------------------------------------------
Deploying a Ruby on Rails application: an example
&nbsp;
Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:
&nbsp;
   &lt;VirtualHost *:80&gt;
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # &lt;-- be sure to point to 'public'!
      &lt;Directory /somewhere/public&gt;
         AllowOverride all              # &lt;-- relax Apache security settings
         Options -MultiViews            # &lt;-- MultiViews must be turned off
      &lt;/Directory&gt;
   &lt;/VirtualHost&gt;</pre></div></div>

<p><strong>6. Edit httpd.conf to load the passenger module</strong></p>
<p>To use a rvm gemset by passenger read &#8220;Rails app with custom .rvmrc and a system wide passenger install&#8221; <a href="https://rvm.beginrescueend.com/integration/passenger/">https://rvm.beginrescueend.com/integration/passenger/</a></p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p0/ruby</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">&lt;VirtualHost 192.168.69.3:80&gt;
   ServerAdmin rupert@2rmobile.com
   ServerName myserver
   ServerAlias myserver
&nbsp;
   DocumentRoot &quot;/path/to/myapp/public&quot;
   &lt;Directory &quot;/path/to/myapp/public&quot;&gt;
&nbsp;
   #DocumentRoot &quot;/path/to/myapp/current/public&quot;
   #&lt;Directory &quot;/path/to/myapp/current/public&quot;&gt;
      Options Indexes MultiViews
      AllowOverride None 
      Order allow,deny
      Allow from all 
   &lt;/Directory&gt;
&nbsp;
   CustomLog /var/log/apache22/myapp-error.log combinedio
   LogLevel warn 
&lt;/VirtualHost&gt;</pre></div></div>

<p>We need a <code>railsapp/config/setup_load_paths.rb</code> to use our custom <code>.rvmrc</code></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">if</span> ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'MY_RUBY_HOME'</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'MY_RUBY_HOME'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'rvm'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
   <span style="color:#9966CC; font-weight:bold;">begin</span>
      rvm_path     = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span>ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'MY_RUBY_HOME'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      rvm_lib_path = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>rvm_path, <span style="color:#996600;">'lib'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#ff6633; font-weight:bold;">$LOAD_PATH</span>.<span style="color:#9900CC;">unshift</span> rvm_lib_path
      <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rvm'</span>
      RVM.<span style="color:#9900CC;">use_from_path</span>! <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
   <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">LoadError</span>
      <span style="color:#008000; font-style:italic;"># RVM is unavailable at this point.</span>
      <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;RVM ruby lib is currently unavailable.&quot;</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Pick the lines for your version of Bundler</span>
<span style="color:#008000; font-style:italic;"># If you're not using Bundler at all, remove all of them</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Require Bundler 1.0 </span>
ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'BUNDLE_GEMFILE'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">expand_path</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'../Gemfile'</span>, <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'bundler/setup'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Require Bundler 0/9</span>
<span style="color:#008000; font-style:italic;"># if File.exist?(&quot;.bundle/environment.rb&quot;)</span>
<span style="color:#008000; font-style:italic;">#   require '.bundle/environment'</span>
<span style="color:#008000; font-style:italic;"># else</span>
<span style="color:#008000; font-style:italic;">#   require 'rubygems'</span>
<span style="color:#008000; font-style:italic;">#   require 'bundler'</span>
<span style="color:#008000; font-style:italic;">#   Bundler.setup</span>
<span style="color:#008000; font-style:italic;"># end</span></pre></div></div>

<p>Visit this stackoverflow question <a href="http://stackoverflow.com/questions/5680341/how-to-load-passenger-from-apache-with-rvm-and-unique-gem-sets">http://stackoverflow.com/questions/5680341/how-to-load-passenger-from-apache-with-rvm-and-unique-gem-sets</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> git clone rupert<span style="color: #000000; font-weight: bold;">@</span>server:<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>your<span style="color: #000000; font-weight: bold;">/</span>myapp.git
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> myapp</pre></div></div>

<p><strong>9. Run bundle</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> bundle <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-V</span>
Fetching <span style="color: #7a0874; font-weight: bold;">source</span> index <span style="color: #000000; font-weight: bold;">for</span> http:<span style="color: #000000; font-weight: bold;">//</span>rubygems.org<span style="color: #000000; font-weight: bold;">/</span>
....</pre></div></div>

<p><strong>Errors that you may encounter</strong></p>
<p>Note: The rvmrc located in &#8216;../releases/20120208034235&#8242; could not be loaded, likely due to trust mechanisms. Please run &#8216;rvm rvmrc {trust,untrust} &#8220;../releases/20120208034235&#8243;&#8216; to continue, or set rvm_trust_rvmrcs_flag to 1. (RVM::ErrorLoadingRVMRC)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rvmrc
<span style="color: #7a0874; font-weight: bold;">umask</span> g+<span style="color: #c20cb9; font-weight: bold;">w</span>
<span style="color: #007800;">rvm_trust_rvmrcs_flag</span>=<span style="color: #000000;">1</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/11/freebsd-rvm-rails-passenger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>freebsd + git server + gitweb</title>
		<link>/wordpress/2011/11/freebsd-git-server/</link>
		<comments>/wordpress/2011/11/freebsd-git-server/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 02:09:25 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[freebsd]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">/wordpress/?p=1112</guid>
		<description><![CDATA[1. install git server $ cd /usr/ports/devel/git $ make install clean Note: Include gitweb as an option 2. Modify /etc/rc.conf git_daemon_enable=&#34;YES&#34; git_daemon_directory=&#34;/var/db/git/repo&#34; git_daemon_flags=&#34;--export-all --syslog --enable=receive-pack --listen=ip_address --verbose&#34; 3. Create git user $ pw user add git $ passwd git $ chsh git Login: git Password: ******************* Uid &#91;#]: 1002 Gid &#91;# or name]: 1002 Change [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1. install git server</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>devel<span style="color: #000000; font-weight: bold;">/</span>git
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean</pre></div></div>

<p>Note: Include gitweb as an option</p>
<p><strong>2. Modify /etc/rc.conf</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">git_daemon_enable</span>=<span style="color: #ff0000;">&quot;YES&quot;</span>
<span style="color: #007800;">git_daemon_directory</span>=<span style="color: #ff0000;">&quot;/var/db/git/repo&quot;</span>
<span style="color: #007800;">git_daemon_flags</span>=<span style="color: #ff0000;">&quot;--export-all --syslog --enable=receive-pack --listen=ip_address --verbose&quot;</span></pre></div></div>

<p><strong>3. Create git user</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ pw user add git
$ <span style="color: #c20cb9; font-weight: bold;">passwd</span> git
$ <span style="color: #c20cb9; font-weight: bold;">chsh</span> git
Login: git
Password: <span style="color: #000000; font-weight: bold;">*******************</span>
Uid <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #666666; font-style: italic;">#]: 1002</span>
Gid <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #666666; font-style: italic;"># or name]: 1002</span>
Change <span style="color: #7a0874; font-weight: bold;">&#91;</span>month day year<span style="color: #7a0874; font-weight: bold;">&#93;</span>:
Expire <span style="color: #7a0874; font-weight: bold;">&#91;</span>month day year<span style="color: #7a0874; font-weight: bold;">&#93;</span>:
Class:
Home directory: <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>db<span style="color: #000000; font-weight: bold;">/</span>git
Shell: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>git-shell
Full Name: User <span style="color: #000000; font-weight: bold;">&amp;</span>
Office Location:
Office Phone:
Home Phone:
Other information:</pre></div></div>

<p>&#8220;git&#8221; user would create repositories. We could also add &#8220;rupert&#8221; to the git group.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pw user mod rupert <span style="color: #660033;">-G</span> git</pre></div></div>

<p><strong>4. Let&#8217;s create a repository</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <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>db<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>repo
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> cws-rails.git
$ <span style="color: #7a0874; font-weight: bold;">cd</span> cws-rails.git<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> git <span style="color: #660033;">--bare</span> init
Initialized empty Git repository <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>db<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>repo<span style="color: #000000; font-weight: bold;">/</span>cws-rails.git<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span>
total <span style="color: #000000;">4</span>
drwxr-xr-x  <span style="color: #000000;">7</span> root  git  <span style="color: #000000;">512</span> Nov <span style="color: #000000;">16</span> <span style="color: #000000;">12</span>:<span style="color: #000000;">54</span> cws-rails.git
drwxrwxr-x  <span style="color: #000000;">7</span> git   git  <span style="color: #000000;">512</span> Nov <span style="color: #000000;">16</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">52</span> myproject.git
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-Rf</span> git:git cws-rails.git
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-Rf</span> <span style="color: #000000;">775</span> cws-rails.git</pre></div></div>

<p>Make sure to change the ownership to git. We also make it writable to the group so users like rupert will have write access.</p>
<p><strong>5. Let&#8217;s clone, commit and push</strong><br />
So now in my MBP, i will clone myproject.git, change some file and push.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git clone rupert<span style="color: #000000; font-weight: bold;">@</span>rupert-bsd:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>db<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>repo<span style="color: #000000; font-weight: bold;">/</span>myproject.git
Cloning into myproject...
Password:
remote: Counting objects: <span style="color: #000000;">12</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">9</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">12</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">12</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">12</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>myproject<span style="color: #7a0874; font-weight: bold;">&#91;</span>master<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">gc</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Updated CHANGELOG&quot;</span> CHANGELOG 
<span style="color: #7a0874; font-weight: bold;">&#91;</span>master d9fd0f7<span style="color: #7a0874; font-weight: bold;">&#93;</span> Updated CHANGELOG
 <span style="color: #000000;">1</span> files changed, <span style="color: #000000;">1</span> insertions<span style="color: #7a0874; font-weight: bold;">&#40;</span>+<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">0</span> deletions<span style="color: #7a0874; font-weight: bold;">&#40;</span>-<span style="color: #7a0874; font-weight: bold;">&#41;</span>
~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>myproject<span style="color: #7a0874; font-weight: bold;">&#91;</span>master<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">%</span> git push
Password:
Counting objects: <span style="color: #000000;">5</span>, done.
Delta compression using up to <span style="color: #000000;">2</span> threads.
Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Writing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">332</span> bytes, done.
Total <span style="color: #000000;">3</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
To rupert<span style="color: #000000; font-weight: bold;">@</span>rupert-bsd:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>db<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>repo<span style="color: #000000; font-weight: bold;">/</span>myproject.git
   5d16498..d9fd0f7  master -<span style="color: #000000; font-weight: bold;">&gt;</span> master</pre></div></div>

<p>Note: So that we don&#8217;t need to specify the password all the time, generate an ssh-keygen -t rsa for id_rsa.pub and append it to rupert@rupert-bsd:/home/rupert/.ssh/authorized_keys</p>
<p><strong>6. Setup Git, Configure and Restart Apache2</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;"># Copy the gitweb directory to your apache22 directory
$ sudo cp -Rf /usr/local/share/examples/git/gitweb /usr/local/www/apache22/data/
&nbsp;
# Edit gitweb.cgi to point to your repo
$ vim /usr/local/www/apache22/data/gitweb/gitweb.cgi
our $projectroot = &quot;/var/db/git/repo&quot;;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;"># Allow apache to execute gitweb.cgi
Alias /gitweb /usr/local/www/apache22/data/gitweb
&nbsp;
&lt;Directory /usr/local/www/apache22/data/gitweb&gt;
  Options FollowSymLinks +ExecCGI
  AddHandler cgi-script .cgi
&lt;/Directory&gt;</pre></div></div>

<p>Browse http://servername/gitweb/gitweb.cgi</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/11/freebsd-git-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>freebsd + postgresql-server + plpython + postgis</title>
		<link>/wordpress/2011/11/freebsd-postgresql9-0-3-2/</link>
		<comments>/wordpress/2011/11/freebsd-postgresql9-0-3-2/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 01:41:06 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgres]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[postgis]]></category>

		<guid isPermaLink="false">/wordpress/?p=1109</guid>
		<description><![CDATA[1. Install prerequisites % cd /usr/ports/textproc/libxml2 % make % make install 2. Install python % cd /usr/ports/lang/python26 % make config #opens up blue terminal which allows to choose options % make % make install 3. Install % cd /usr/ports/databases/postgresql90-server % make % make install clean 4. Initialize % vim /etc/rc.conf postgresql_enable=YES postgresql_data=/var/db/pgsql % mkdir /var/db/pgsql [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1. Install prerequisites</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>textproc<span style="color: #000000; font-weight: bold;">/</span>libxml2
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><strong>2. Install python</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>lang<span style="color: #000000; font-weight: bold;">/</span>python26
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> config <span style="color: #666666; font-style: italic;">#opens up blue terminal which allows to choose options</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><strong>3. Install</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>databases<span style="color: #000000; font-weight: bold;">/</span>postgresql90-server
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean</pre></div></div>

<p><strong>4. Initialize</strong></p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">% vim /etc/rc.conf
postgresql_enable=YES
postgresql_data=/var/db/pgsql
% mkdir /var/db/pgsql
% chown -Rf pgsql:pgsql /var/db/pgsql
% /usr/local/etc/rc.d/postgresql initdb -E utf8</pre></div></div>

<p><strong>5. Configuration</strong><br />
Allow incoming connections and set the default timezone to &#8216;UTC&#8217;</p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">% vim /var/db/pgsql/postgresql.conf
listen_addresses = '*'     # what IP address(es) to listen on;
&nbsp;
timezone = 'UTC' #not necessary</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">% vim /var/db/pgsql/pg_hba.conf
# your network
host    all             all             192.168.10.0/24          trust</pre></div></div>

<p><strong>6. Start/Stop</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.d<span style="color: #000000; font-weight: bold;">/</span>postgresql start
<span style="color: #000000; font-weight: bold;">%</span> telnet 127.0.0.1 <span style="color: #000000;">5432</span></pre></div></div>

<p><strong>7. Create user. Login as root then switch to pgsql user</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% su - pgsql
[root@rupert ~]# su - pgsql
$ psql -d postgres
psql (9.0.6)
Type &quot;help&quot; for help.
&nbsp;
postgres=# CREATE ROLE rupert WITH LOGIN PASSWORD '**********' SUPERUSER INHERIT CREATEDB CREATEROLE;
CREATE ROLE
postgres=#</pre></div></div>

<p><strong>8. Install plpython</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>databases<span style="color: #000000; font-weight: bold;">/</span>postgresql-plpython
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean</pre></div></div>

<p><em>To test if plpython is working properly, we create a testdb and loadup plpythonu and call a plpython function.</em></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">[root@rupert ~]# createdb -U rupert testdb
[root@rupert ~]# psql -d testdb -U rupert
psql (9.0.6)
Type &quot;help&quot; for help.
&nbsp;
testdb=# CREATE PROCEDURAL LANGUAGE 'plpythonu' HANDLER plpython_call_handler;
NOTICE:  using pg_pltemplate information instead of CREATE LANGUAGE parameters
CREATE LANGUAGE
testdb=# create or replace function pyver() returns text as
testdb-# $$
testdb$# import sys
testdb$# return sys.version
testdb$# $$ language 'plpythonu';
CREATE FUNCTION
testdb=# select pyver();
                   pyver                    
--------------------------------------------
 2.6.7 (r267:88850, Feb  6 2012, 13:10:39) +
 [GCC 4.2.1 20070831 patched [FreeBSD]]
(1 row)
&nbsp;
testdb=#</pre></div></div>

<p><strong>9. Install postgis</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>databases<span style="color: #000000; font-weight: bold;">/</span>postgis
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><em>Note that ports should install proj and geos.</em></p>
<p><strong>10. Create template_postgis</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgis
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">su</span> - pgsql
$ createdb <span style="color: #660033;">-E</span> utf8 template_postgis
$ psql <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> postgis.sql
$ psql <span style="color: #660033;">-d</span> template_postgis <span style="color: #660033;">-f</span> spatial_ref_sys.sql</pre></div></div>

<p><strong>11. Install adminpack module</strong></p>
<p><em>This will eliminate &#8220;servers instrument error&#8221; when pgAdmin loads up postgres (default) db</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>databases<span style="color: #000000; font-weight: bold;">/</span>postgresql90-contrib
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span>contrib
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">su</span> - pgsql
$ psql <span style="color: #660033;">-U</span> pgsql <span style="color: #660033;">-d</span> postgres <span style="color: #660033;">-f</span> adminpack.sql</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/11/freebsd-postgresql9-0-3-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nominatim + homebrew on OSX + OSM data + PHP = open sourced reverse geocoder</title>
		<link>/wordpress/2011/11/nominatim-on-osx/</link>
		<comments>/wordpress/2011/11/nominatim-on-osx/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 05:45:20 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">/wordpress/?p=1098</guid>
		<description><![CDATA[This installation guide (at the time of writing) was tested on SVN trunk of OSM2PGSQL and running on latest/stable Postgres/Postgis versions on OSX via homebrew. 1. Summary OSX Snow Leopard &#160; OSM2PGSQL: Head http://svn.openstreetmap.org/applications/utils/export/osm2pgsql Revision: 27034 Last Changed Author: frederik Last Changed Rev: 27030 Last Changed Date: 2011-11-09 10:57:49 +1100 (Wed, 09 Nov 2011) &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>This installation guide (at the time of writing) was tested on SVN trunk of OSM2PGSQL and running on latest/stable Postgres/Postgis versions on OSX via homebrew.</p>
<p><strong>1. Summary</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">OSX Snow Leopard
&nbsp;
OSM2PGSQL: 
Head http://svn.openstreetmap.org/applications/utils/export/osm2pgsql Revision: 27034
Last Changed Author: frederik
Last Changed Rev: 27030
Last Changed Date: 2011-11-09 10:57:49 +1100 (Wed, 09 Nov 2011)
&nbsp;
POSTGRES: 9.0.4
&nbsp;
POSTGIS: &quot;POSTGIS=&quot;1.5.3&quot; GEOS=&quot;3.3.1-CAPI-1.7.1&quot; PROJ=&quot;Rel. 4.7.1, 23 September 2009&quot; LIBXML=&quot;2.7.3&quot; USE_STATS&quot; # SELECT POSTGIS_FULL_VERSION();
&nbsp;
PHP: 5.3.8 (cli) (built: Nov 14 2011 14:41:52) #php -v</pre></div></div>

<p><strong>2. Installation</strong><br />
Most of the software is installed via <a href="https://github.com/mxcl/homebrew">homebrew.</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Install homebrew</span>
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(curl -fsSL https://raw.github.com/gist/323731)</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Install postgresql</span>
<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> postgresql
<span style="color: #000000; font-weight: bold;">%</span> initdb <span style="color: #660033;">-E</span> utf8 <span style="color: #660033;">-D</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>postgres
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span>9.0.4<span style="color: #000000; font-weight: bold;">/</span>org.postgresql.postgres.plist ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #000000; font-weight: bold;">%</span> launchctl load <span style="color: #660033;">-w</span> ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents<span style="color: #000000; font-weight: bold;">/</span>org.postgresql.postgres.plist
<span style="color: #000000; font-weight: bold;">%</span> psql <span style="color: #660033;">-d</span> postgres <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span>9.0.4<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>adminpack.sql
&nbsp;
<span style="color: #666666; font-style: italic;"># Install postgis</span>
<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> proj
<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> geos
<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> postgis
&nbsp;
<span style="color: #666666; font-style: italic;"># Create template_postgis_osm</span>
<span style="color: #000000; font-weight: bold;">%</span> createdb <span style="color: #660033;">-E</span> utf8 template_postgis_osm
<span style="color: #000000; font-weight: bold;">%</span> psql <span style="color: #660033;">-d</span> template_postgis_osm <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;/usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/pg_trgm.sql&quot;</span>
<span style="color: #000000; font-weight: bold;">%</span> psql <span style="color: #660033;">-d</span> template_postgis_osm <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>postgis<span style="color: #000000; font-weight: bold;">/</span>1.5.3<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgis<span style="color: #000000; font-weight: bold;">/</span>postgis.sql
<span style="color: #000000; font-weight: bold;">%</span> psql <span style="color: #660033;">-d</span> template_postgis_osm <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>postgis<span style="color: #000000; font-weight: bold;">/</span>1.5.3<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgis<span style="color: #000000; font-weight: bold;">/</span>spatial_ref_sys.sql
&nbsp;
<span style="color: #666666; font-style: italic;"># Install osm2pgsql. Can skip this.</span>
<span style="color: #666666; font-style: italic;"># % brew install osm2pgsql</span></pre></div></div>

<p>For detail instructions on installing Postgres/Postgis via Homebrew, read this <a href="/wordpress/2011/11/homebrew-postgresql9-0-4-postgis-1-5-3/">homebrew + postgresql9.0.4 + postgis.1.5.3 + proj4 + geos3.3.1 + osm2pgsql</a>.  If you are having problems installing GEOS, then read that link as it shows you how to upgrade GEOS to 3.3.1.</p>
<p>OSM2PGSQL needs GEOS as well. Note that brew only install the osm2pgsql binary. Don&#8217;t worry, we will compile this via source later. </p>
<p><strong>3. More Installation.</strong></p>
<p>We need to get PHP installed to run gazetteer <a href="http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/website/">http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/website/</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Install PHP</span>
<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> php <span style="color: #660033;">--with-mysql</span> <span style="color: #660033;">--with-pgsql</span> <span style="color: #660033;">--with-apache</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Hookup with Apache</span>
<span style="color: #666666; font-style: italic;"># Edit httpd.conf to LoadModule</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Install PEAR DB</span>
<span style="color: #000000; font-weight: bold;">%</span> pear <span style="color: #c20cb9; font-weight: bold;">install</span> db</pre></div></div>

<p><strong>4. OSM2PGSQL</strong><br />
Read this wiki: <a href="http://wiki.openstreetmap.org/wiki/Osm2pgsql">http://wiki.openstreetmap.org/wiki/Osm2pgsql</a>. Well, we eventually need the whole OSM2PGSQL source as it contains the website (gazetteer).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.openstreetmap.org<span style="color: #000000; font-weight: bold;">/</span>applications<span style="color: #000000; font-weight: bold;">/</span>utils<span style="color: #000000; font-weight: bold;">/</span>export<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql osm2pgsql
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> osm2pgsql
<span style="color: #000000; font-weight: bold;">%</span> .<span style="color: #000000; font-weight: bold;">/</span>autogen.sh
<span style="color: #000000; font-weight: bold;">%</span> .<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># At this point there should be an osm2pgsql binary.</span></pre></div></div>

<p><em>We need to compile gazetteer for gazetteer.so which is used by gazetteer-functions.sql</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gis<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> clean
gis<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> 
gis<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;/usr/local/lib/osm2pgsql&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> ..<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">/</span>install-sh <span style="color: #660033;">-c</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;/usr/local/lib/osm2pgsql&quot;</span>
 <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> ..<span style="color: #000000; font-weight: bold;">/</span>libtool <span style="color: #660033;">--mode</span>=<span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span>  <span style="color: #ff0000;">'gazetteer.la'</span> <span style="color: #ff0000;">'/usr/local/lib/osm2pgsql/gazetteer.la'</span>
libtool: <span style="color: #c20cb9; font-weight: bold;">install</span>: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> .libs<span style="color: #000000; font-weight: bold;">/</span>gazetteer.so <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer.so
libtool: <span style="color: #c20cb9; font-weight: bold;">install</span>: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> .libs<span style="color: #000000; font-weight: bold;">/</span>gazetteer.lai <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer.la
<span style="color: #660033;">----------------------------------------------------------------------</span>
Libraries have been installed <span style="color: #000000; font-weight: bold;">in</span>:
   <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql
&nbsp;
If you ever happen to want to <span style="color: #c20cb9; font-weight: bold;">link</span> against installed libraries
<span style="color: #000000; font-weight: bold;">in</span> a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the <span style="color: #000000; font-weight: bold;">`</span>-LLIBDIR<span style="color: #ff0000;">'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH'</span> environment variable
     during execution
&nbsp;
See any operating system documentation about shared libraries <span style="color: #000000; font-weight: bold;">for</span>
<span style="color: #c20cb9; font-weight: bold;">more</span> information, such <span style="color: #c20cb9; font-weight: bold;">as</span> the <span style="color: #c20cb9; font-weight: bold;">ld</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> and ld.so<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> manual pages.
<span style="color: #660033;">----------------------------------------------------------------------</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;/usr/local/share/gazetteer&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> ..<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">/</span>install-sh <span style="color: #660033;">-c</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;/usr/local/share/gazetteer&quot;</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'extract_countrynames.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/extract_countrynames.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'gazetteer-index.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/gazetteer-index.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'gazetteer-loaddata.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/gazetteer-loaddata.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'gazetteer-tables.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/gazetteer-tables.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_country_name.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_country_name.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_country_osm_grid.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_country_osm_grid.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_gb_postcodearea.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_gb_postcodearea.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_gb_postcode.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_gb_postcode.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_specialwords.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_specialwords.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_us_statecounty.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_us_statecounty.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_us_state.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_us_state.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'import_worldboundaries.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/import_worldboundaries.sql'</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">644</span> <span style="color: #ff0000;">'gazetteer-functions.sql'</span> <span style="color: #ff0000;">'/usr/local/share/gazetteer/gazetteer-functions.sql'</span></pre></div></div>

<p><strong>5. Download Data</strong><br />
You can get some regional OSM data from cloudmade. <a href="http://downloads.cloudmade.com/oceania/australia_and_new_zealand/australia/victoria">http://downloads.cloudmade.com/oceania/australia_and_new_zealand/australia/victoria</a> </p>
<p>I suggest you download a regional extract prior to downloading/testing with the whole planet-osm. If you don&#8217;t believe me that it will take long, you can read <a href="http://wiki.openstreetmap.org/wiki/Nominatim/Installation">http://wiki.openstreetmap.org/wiki/Nominatim/Installation</a></p>
<p><strong>6. Load and Index Data</strong><br />
Basically, this is the summary of commands taken from <a href="http://wiki.openstreetmap.org/wiki/Nominatim/Installation">http://wiki.openstreetmap.org/wiki/Nominatim/Installation</a> At the time of writing this, I had issues such as &#8220;planet_osm_ways&#8221; (and several tables) does not exist. So I did a pg_dump and restored the tables afterwards. Be very careful with using the script below, you can comment the indexing part just to speed up on loading and see if you have errors, etc.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">DATABASE_NAME</span>=gazetteer_vic
<span style="color: #007800;">OSM2PGSQL_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>gis<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql
<span style="color: #007800;">SOURCE_DATA</span>=<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>australia<span style="color: #000000; font-weight: bold;">/</span>victoria.osm
<span style="color: #007800;">DUMP_DIR</span>=<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>pg_dumps<span style="color: #000000; font-weight: bold;">/</span>streetlookup
&nbsp;
dropdb <span style="color: #007800;">$DATABASE_NAME</span> 
<span style="color: #666666; font-style: italic;">#dropuser www-data</span>
&nbsp;
createdb <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-E</span> UTF8 <span style="color: #660033;">-T</span> template_postgis_osm
createuser <span style="color: #660033;">-SDR</span> www-data
&nbsp;
<span style="color: #666666; font-style: italic;"># This will create the planet_osm_ways, etc</span>
<span style="color: #007800;">$OSM2PGSQL_HOME</span><span style="color: #000000; font-weight: bold;">/</span>osm2pgsql <span style="color: #660033;">--create</span> <span style="color: #660033;">--latlong</span> <span style="color: #660033;">--database</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--slim</span> <span style="color: #660033;">--prefix</span> planet_osm <span style="color: #660033;">--cache</span> <span style="color: #000000;">2048</span> <span style="color: #007800;">$SOURCE_DATA</span>
&nbsp;
pg_dump <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--format</span> custom <span style="color: #660033;">--file</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_ways.backup&quot;</span> <span style="color: #660033;">--table</span> public.planet_osm_ways <span style="color: #007800;">$DATABASE_NAME</span>
pg_dump <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--format</span> custom <span style="color: #660033;">--file</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_nodes.backup&quot;</span> <span style="color: #660033;">--table</span> public.planet_osm_nodes <span style="color: #007800;">$DATABASE_NAME</span>
pg_dump <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--format</span> custom <span style="color: #660033;">--file</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_rels.backup&quot;</span> <span style="color: #660033;">--table</span> public.planet_osm_rels <span style="color: #007800;">$DATABASE_NAME</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This will create the place table</span>
<span style="color: #007800;">$OSM2PGSQL_HOME</span><span style="color: #000000; font-weight: bold;">/</span>osm2pgsql <span style="color: #660033;">--latlong</span> <span style="color: #660033;">-O</span> gazetteer <span style="color: #660033;">--database</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--slim</span> <span style="color: #660033;">--prefix</span> planet_osm <span style="color: #660033;">--cache</span> <span style="color: #000000;">2048</span> <span style="color: #007800;">$SOURCE_DATA</span>
&nbsp;
pg_restore <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--dbname</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_ways.backup&quot;</span>
pg_restore <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--dbname</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_nodes.backup&quot;</span>
pg_restore <span style="color: #660033;">--host</span> 127.0.0.1 <span style="color: #660033;">--port</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">--username</span> rupert <span style="color: #660033;">--dbname</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUMP_DIR</span>/planet_osm_rels.backup&quot;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-Rf</span> <span style="color: #007800;">$DUMP_DIR</span><span style="color: #000000; font-weight: bold;">/*</span>.backup
&nbsp;
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_country_osm_grid.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_worldboundaries.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_country_name.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_gb_postcode.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_gb_postcodearea.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_us_state.sql
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-f</span> import_us_statecounty.sql
&nbsp;
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-f</span> gazetteer-functions.sql
&nbsp;
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-f</span> gazetteer-tables.sql
&nbsp;
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-f</span> gazetteer-functions.sql
&nbsp;
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-f</span> gazetteer-loaddata.sql
&nbsp;
<span style="color: #666666; font-style: italic;">#Indexing</span>
psql <span style="color: #660033;">-d</span> <span style="color: #007800;">$DATABASE_NAME</span> <span style="color: #660033;">-f</span> gazetteer-index.sql</pre></div></div>

<p>Save this as run.sh in <code>/Users/rupert/projects/gis/osm2pgsql/gazetteer</code></p>
<p>Where do you run this?</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>gis<span style="color: #000000; font-weight: bold;">/</span>osm2pgsql<span style="color: #000000; font-weight: bold;">/</span>gazetteer
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> run.sh</pre></div></div>

<p><strong>6. Test</strong><br />
If you are successful, <strong>you should have a &#8220;placex&#8221; table.</strong> Now that we have a postgis database running, you can now run spatial statements thru pgadmin. See the guts of <a href="http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/website/reverse.php">reverse.php</a></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> 
<span style="color: #993333; font-weight: bold;">FROM</span> placex
<span style="color: #993333; font-weight: bold;">WHERE</span> ST_DWithin<span style="color: #66cc66;">&#40;</span> ST_SetSRID<span style="color: #66cc66;">&#40;</span>ST_Point<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">145.234377</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-</span><span style="color: #cc66cc;">37.856320</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">4326</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> geometry<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">0.0001</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">AND</span> ST_GeometryType<span style="color: #66cc66;">&#40;</span>geometry<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'ST_Polygon'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'ST_MultiPolygon'</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This one took only 21 ms.</p>
<p><strong>7. Website</strong></p>
<p>Make sure <code>www-data</code> have permissions to the tables. Rememeber to replace gazetteer_vic with your DATABASE_NAME.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> tbl <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>psql <span style="color: #660033;">-qAt</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;select tablename from pg_tables where schemaname = 'public';&quot;</span> gazetteer_vic<span style="color: #000000; font-weight: bold;">`</span> ; <span style="color: #000000; font-weight: bold;">do</span> psql <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;alter table <span style="color: #007800;">$tbl</span> owner to <span style="color: #000099; font-weight: bold;">\&quot;</span>www-data<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> gazetteer_vic; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Assuming you have PHP and PEAR DB installed. Then update the data connection settings found in <a href="http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/website/.htlib/settings.php">http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/website/.htlib/settings.php</a></p>
<p>Run the same query but using reverse.php.</p>
<p><a href="http://127.0.0.1/nominatim/reverse.php?format=xml&#038;lat=-37.856320&#038;lon=145.234377&#038;zoom=18&#038;addressdetails=1">http://127.0.0.1/nominatim/reverse.php?format=xml&#038;lat=-37.856320&#038;lon=145.234377&#038;zoom=18&#038;addressdetails=1</a></p>
<p><img src="/wordpress/wp-content/uploads/2011/11/reverse.png" alt="reverse.png" border="0" width="920" height="343" /></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/11/nominatim-on-osx/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>homebrew + php</title>
		<link>/wordpress/2011/11/homebrew-php/</link>
		<comments>/wordpress/2011/11/homebrew-php/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 04:09:18 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[homebrew]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">/wordpress/?p=1092</guid>
		<description><![CDATA[Update This is now been depracated and used as reference only. I opted to install php via source here 1. Cleanup existing PHP So by default, OSX Leopard/Snow Leopard?, comes with apache2 and php installed. mv /usr/local/include/php /usr/local/include/php.old mv /usr/local/lib/php /usr/local/lib/php.old 2. Install PHP http://notfornoone.com/2010/07/install-php53-homebrew-snow-leopard/ ~/Desktop% brew install php --with-apache --with-mysql --with-pgsql ==&#62; Installing php [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong><br />
This is now been depracated and used as reference only.  I opted to install php via source <a href="/wordpress/2011/12/installing-php-on-osx/">here</a></p>
<p><strong>1. Cleanup existing PHP</strong><br />
So by default, OSX Leopard/Snow Leopard?, comes with apache2 and php installed.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>php <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>php.old
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>php <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>php.old</pre></div></div>

<p>2. Install PHP</p>
<p><a href="http://notfornoone.com/2010/07/install-php53-homebrew-snow-leopard/">http://notfornoone.com/2010/07/install-php53-homebrew-snow-leopard/</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> php <span style="color: #660033;">--with-apache</span> <span style="color: #660033;">--with-mysql</span> <span style="color: #660033;">--with-pgsql</span>
==<span style="color: #000000; font-weight: bold;">&gt;</span> Installing php dependency: jpeg
==<span style="color: #000000; font-weight: bold;">&gt;</span> Installing php dependency: mcrypt
==<span style="color: #000000; font-weight: bold;">&gt;</span> Installing php dependency: <span style="color: #c20cb9; font-weight: bold;">gettext</span>
==<span style="color: #000000; font-weight: bold;">&gt;</span> Installing php
....
==<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> .<span style="color: #000000; font-weight: bold;">/</span>php.ini-production <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini
==<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">644</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>.lock
==<span style="color: #000000; font-weight: bold;">&gt;</span> Caveats
   To <span style="color: #7a0874; font-weight: bold;">enable</span> PHP <span style="color: #000000; font-weight: bold;">in</span> Apache add the following to httpd.conf and restart Apache:
    LoadModule php5_module    <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>libphp5.so
&nbsp;
    The php.ini <span style="color: #c20cb9; font-weight: bold;">file</span> can be found <span style="color: #000000; font-weight: bold;">in</span>:
      <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>5.3.8<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini
brew <span style="color: #c20cb9; font-weight: bold;">install</span> php <span style="color: #660033;">--with-apache</span> <span style="color: #660033;">--with-mysql</span> <span style="color: #660033;">--with-pgsql</span> 452.56s user 272.47s system <span style="color: #000000;">126</span><span style="color: #000000; font-weight: bold;">%</span> cpu <span style="color: #000000;">9</span>:<span style="color: #000000;">31.75</span> total</pre></div></div>

<p>The most important here is the compiled libphp5.so which we will hook into apache2.</p>
<p><strong>3. Hookup Apache2 to libphp5</strong><br />
Depending on your installation, edit httpd.conf and make sure you have this line</p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">LoadModule php5_module    /usr/local/Cellar/php/5.3.8/libexec/apache2/libphp5.so</pre></div></div>

<p><strong>4. Test</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% php -m #List all php modules
mysql
mysqli
pdo_mysql
pdo_pgsql
pgsql
/usr/local/bin% l php #brew makes the symlinks
lrwxr-xr-x  1 rupert  admin    27B 14 Nov 14:42 php@ -&gt; ../Cellar/php/5.3.8/bin/php</pre></div></div>

<p>Well if you have a wordpress site, you can test if the whole thing works.</p>
<p><strong>5. Restart Apache</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>StartupItems<span style="color: #000000; font-weight: bold;">/</span>Apache2<span style="color: #000000; font-weight: bold;">/</span>Apache2 restart</pre></div></div>

<p><strong>UPDATE: Dec 19, 2011</strong><br />
Maintaining php installations via homebrew is such a pain. I reverted back via source.<br />
1. Download php from source<br />
2. Configure</p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">./configure --prefix=/usr/local/php5.3.8 \
  --mandir=/usr/share/man \
  --infodir=/usr/share/info \
  --sysconfdir=/etc \
  --with-config-file-path=/etc \
  --with-zlib \
  --with-zlib-dir=/usr \
  --with-openssl \
  --without-iconv \
  --enable-exif \
  --enable-ftp \
  --enable-mbstring \
  --enable-mbregex \
  --enable-sockets \
  --with-mysql=/usr/local/mysql \
  --with-pdo-mysql=/usr/local/mysql \
  --with-mysqli=/usr/local/mysql/bin/mysql_config \
  --with-apxs2=/usr/local/apache2/bin/apxs</pre></div></div>

<p>3. Make and Make Install</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~/Desktop/php-5.3.8% sudo make install
Password:
Installing PHP SAPI module:       apache2handler
/usr/local/apache2.2.14/build/instdso.sh SH_LIBTOOL='/usr/local/apache2.2.14/build/libtool' libs/libphp5.so /usr/local/apache2.2.14/modules
/usr/local/apache2.2.14/build/libtool --mode=install cp libs/libphp5.so /usr/local/apache2.2.14/modules/
cp libs/libphp5.so /usr/local/apache2.2.14/modules/libphp5.so
Warning!  dlname not found in /usr/local/apache2.2.14/modules/libphp5.so.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/local/apache2.2.14/modules/libphp5.so
[activating module `php5' in /usr/local/apache2.2.14/conf/httpd.conf]
Installing PHP CLI binary:        /usr/local/php5.3.8/bin/
Installing PHP CLI man page:      /usr/share/man/man1/
Installing build environment:     /usr/local/php5.3.8/lib/php/build/
Installing header files:          /usr/local/php5.3.8/include/php/
Installing helper programs:       /usr/local/php5.3.8/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/share/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php5.3.8/lib/php/
[PEAR] Archive_Tar    - installed: 1.3.7
[PEAR] Console_Getopt - installed: 1.3.0
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util: upgrade to a newer version (1.2.1 is not newer than 1.2.1)
[PEAR] PEAR           - installed: 1.9.4
Wrote PEAR system config file at: /etc/pear.conf
You may want to add: /usr/local/php5.3.8/lib/php to your php.ini include_path
/Users/rupert/Desktop/php-5.3.8/build/shtool install -c ext/phar/phar.phar /usr/local/php5.3.8/bin
ln -s -f /usr/local/php5.3.8/bin/phar.phar /usr/local/php5.3.8/bin/phar
Installing PDO headers:          /usr/local/php5.3.8/include/php/ext/pdo/
sudo make install  6.84s user 11.50s system 80% cpu 22.843 total</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/11/homebrew-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>homebrew + mysql = installed but access denied for root</title>
		<link>/wordpress/2011/11/homebrew-mysql-access-denied-for-root/</link>
		<comments>/wordpress/2011/11/homebrew-mysql-access-denied-for-root/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 02:21:10 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[homebrew]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">/wordpress/?p=1090</guid>
		<description><![CDATA[1. Cleanup I have an existing mysql @ /usr/local/mysql, so we remove that. % sudo rm -rf mysql-5.1.43-osx10.6-x86_64 Note: I suggest you backup your mysql data by doing mysqldump prior to removing the old mysql. 2. Install mysql #brew install mysql Set up databases to run AS YOUR USER ACCOUNT with: unset TMPDIR mysql_install_db --verbose [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1. Cleanup</strong><br />
I have an existing mysql @ /usr/local/mysql, so we remove that.</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% sudo rm -rf mysql-5.1.43-osx10.6-x86_64</pre></div></div>

<p>Note: I suggest you backup your mysql data by doing mysqldump prior to removing the old mysql.</p>
<p><strong>2. Install mysql</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">#brew install mysql
Set up databases to run AS YOUR USER ACCOUNT with:
    unset TMPDIR
    mysql_install_db --verbose --user=`whoami` --basedir=&quot;$(brew --prefix mysql)&quot; --datadir=/usr/local/var/mysql --tmpdir=/tmp
&nbsp;
To set up base tables in another folder, or use a different user to run
mysqld, view the help for mysqld_install_db:
    mysql_install_db --help
&nbsp;
and view the MySQL documentation:
  * http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html
  * http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html
&nbsp;
To run as, for instance, user &quot;mysql&quot;, you may need to `sudo`:
    sudo mysql_install_db ...options...
&nbsp;
Start mysqld manually with:
    mysql.server start
&nbsp;
    Note: if this fails, you probably forgot to run the first two steps up above
&nbsp;
A &quot;/etc/my.cnf&quot; from another install may interfere with a Homebrew-built
server starting up correctly.
&nbsp;
To connect:
    mysql -uroot
&nbsp;
To launch on startup:
* if this is your first install:
    mkdir -p ~/Library/LaunchAgents
    cp /usr/local/Cellar/mysql/5.5.15/com.mysql.mysqld.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
&nbsp;
* if this is an upgrade and you already have the com.mysql.mysqld.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
    cp /usr/local/Cellar/mysql/5.5.15/com.mysql.mysqld.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
&nbsp;
You may also need to edit the plist to use the correct &quot;UserName&quot;.
&nbsp;
Warning: m4 macros were installed to &quot;share/aclocal&quot;.
Homebrew does not append &quot;/usr/local/share/aclocal&quot;
to &quot;/usr/share/aclocal/dirlist&quot;. If an autoconf script you use
requires these m4 macros, you'll need to add this path manually.
==&gt; Summary
/usr/local/Cellar/mysql/5.5.15: 6277 files, 217M, built in 4.9 minutes
brew install mysql  498.39s user 83.40s system 135% cpu 7:08.37 total</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~/Desktop% unset TMPDIR
~/Desktop% echo $TMPDIR
&nbsp;
~/Desktop% mysql_install_db --verbose --user=`whoami` --basedir=&quot;$(brew --prefix mysql)&quot; --datadir=/usr/local/var/mysql --tmpdir=/tmp
Installing MySQL system tables...
OK
Filling help tables...
OK
&nbsp;
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
&nbsp;
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
&nbsp;
/usr/local/Cellar/mysql/5.5.15/bin/mysqladmin -u root password 'new-password'
/usr/local/Cellar/mysql/5.5.15/bin/mysqladmin -u root -h rupert-imac password 'new-password'
&nbsp;
Alternatively you can run:
/usr/local/Cellar/mysql/5.5.15/bin/mysql_secure_installation
&nbsp;
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
&nbsp;
See the manual for more instructions.
&nbsp;
You can start the MySQL daemon with:
cd /usr/local/Cellar/mysql/5.5.15 ; /usr/local/Cellar/mysql/5.5.15/bin/mysqld_safe &amp;
&nbsp;
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/Cellar/mysql/5.5.15/mysql-test ; perl mysql-test-run.pl
&nbsp;
Please report any problems with the /usr/local/Cellar/mysql/5.5.15/scripts/mysqlbug script!</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~/Desktop% which mysql.server
/usr/local/bin/mysql.server
~/Desktop% ls -la `which mysql.server`
lrwxr-xr-x  1 rupert  admin  39 30 Dec 11:20 /usr/local/bin/mysql.server@ -&gt; ../Cellar/mysql/5.5.15/bin/mysql.server
~/Desktop% mysql.server start
Starting MySQL
.. SUCCESS!</pre></div></div>

<p><strong>3. That&#8217;s it? No.</strong> </p>
<p>At the time of writing this, mysql is at 5.5 and was installed successfully by homebrew. However, I cannot login using the root account. Have a read of this <a href="http://stackoverflow.com/questions/4359131/brew-install-mysql-on-mac-os">stackoverflow: brew install mysql on mac os</a>.</p>
<p>To fix this, stop mysql</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist</pre></div></div>

<p>and start mysql by skipping the grant tables.</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">mysqld_safe --skip-grant-tables</pre></div></div>

<p>Depending if you have a record in mysql.user (select * from mysql.user), then you can either create or update the user.</p>
<p>create:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">ALL</span> PRIVILEGES <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #66cc66;">.</span> <span style="color: #993333; font-weight: bold;">TO</span> <span style="color: #ff0000;">'root'</span>@<span style="color: #ff0000;">'localhost'</span> <span style="color: #993333; font-weight: bold;">IDENTIFIED</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">'whatever'</span> <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">OPTION</span>;
<span style="color: #993333; font-weight: bold;">FLUSH</span> PRIVILEGES;</pre></div></div>

<p>update:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> mysql<span style="color: #66cc66;">.</span>user <span style="color: #993333; font-weight: bold;">SET</span> Password <span style="color: #66cc66;">=</span> PASSWORD<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'NewPassword'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> User<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'root'</span>;
<span style="color: #993333; font-weight: bold;">FLUSH</span> PRIVILEGES;</pre></div></div>

<p><strong>4. Cleanup paths</strong><br />
This is just removing the pgsql and mysql from the current path</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #007800;">$ORACLE_HOME</span>:<span style="color: #007800;">$MYSQL_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$CLANG_HOME</span>:<span style="color: #007800;">$ANDROID_HOME</span><span style="color: #000000; font-weight: bold;">/</span>tools:<span style="color: #007800;">$APACHE2_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$MAGICK_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$SPHINX_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PGSQL_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/11/homebrew-mysql-access-denied-for-root/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>homebrew + postgresql9.0.4 + postgis.1.5.3 + proj4 + geos3.3.1 + osm2pgsql</title>
		<link>/wordpress/2011/11/homebrew-postgresql9-0-4-postgis-1-5-3/</link>
		<comments>/wordpress/2011/11/homebrew-postgresql9-0-4-postgis-1-5-3/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 02:02:21 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[homebrew]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=1088</guid>
		<description><![CDATA[For the impatient % /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.github.com/gist/323731)&#34; % brew install postgresql % initdb -E utf8 -D /usr/local/var/postgres % cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/ % launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist % psql -d postgres -f /usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/adminpack.sql % brew install proj % brew install geos %you should really read below before running this % brew install postgis or [...]]]></description>
			<content:encoded><![CDATA[<p><strong>For the impatient</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% /usr/bin/ruby -e &quot;$(curl -fsSL https://raw.github.com/gist/323731)&quot;
% brew install postgresql
% initdb -E utf8 -D /usr/local/var/postgres
% cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
% launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
% psql -d postgres -f /usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/adminpack.sql
% brew install proj
% brew install geos %you should really read below before running this
% brew install postgis or brew install --HEAD postgis to install postgis2 from svn
% createdb -E utf8 template_postgis
% psql -d template_postgis -f /usr/local/Cellar/postgis/1.5.3/share/postgis/postgis.sql
% psql -d template_postgis -f /usr/local/Cellar/postgis/1.5.3/share/postgis/spatial_ref_sys.sql</pre></div></div>

<p><strong>1. Install homebrew</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">%open https://github.com/mxcl/homebrew
%open https://github.com/mxcl/homebrew/wiki/Installation
%/usr/bin/ruby -e &quot;$(curl -fsSL https://raw.github.com/gist/323731)&quot;</pre></div></div>

<p><strong>2. Install Postgres</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">%brew install postgresql
....
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
  https://github.com/mxcl/homebrew/issues/issue/2510
&nbsp;
To build plpython against a specific Python, set PYTHON prior to brewing:
  PYTHON=/usr/local/bin/python  brew install postgresql
See:
  http://www.postgresql.org/docs/9.0/static/install-procedure.html
&nbsp;
&nbsp;
If this is your first install, create a database with:
  initdb /usr/local/var/postgres
&nbsp;
If this is your first install, automatically load on login with:
  mkdir -p ~/Library/LaunchAgents
  cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
  launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
&nbsp;
If this is an upgrade and you already have the org.postgresql.postgres.plist loaded:
  launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
  cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
  launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
&nbsp;
Or start manually with:
  pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
&nbsp;
And stop with:
  pg_ctl -D /usr/local/var/postgres stop -s -m fast
&nbsp;
&nbsp;
Some machines may require provisioning of shared memory:
  http://www.postgresql.org/docs/current/static/kernel-resources.html%SYSVIPC
&nbsp;
If you want to install the postgres gem, including ARCHFLAGS is recommended:
    env ARCHFLAGS=&quot;-arch x86_64&quot; gem install pg
&nbsp;
To install gems without sudo, see the Homebrew wiki.
==&gt; Summary
/usr/local/Cellar/postgresql/9.0.4: 2577 files, 35M, built in 3.1 minutes
brew install postgresql  188.73s user 62.38s system 106% cpu 3:55.06 total</pre></div></div>

<p><strong>3. Postgres Post Installation. Initialize DB.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% initdb -E utf8 -D /usr/local/var/postgres
The files belonging to this database system will be owned by user &quot;rupert&quot;.
This user must also own the server process.
&nbsp;
The database cluster will be initialized with locale en_AU.UTF-8.
The default text search configuration will be set to &quot;english&quot;.
&nbsp;
creating directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting default max_connections ... 20
selecting default shared_buffers ... 2400kB
creating configuration files ... ok
creating template1 database in /usr/local/var/postgres/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
&nbsp;
WARNING: enabling &quot;trust&quot; authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.
&nbsp;
Success. You can now start the database server using:
&nbsp;
    postgres -D /usr/local/var/postgres
or
    pg_ctl -D /usr/local/var/postgres -l logfile start</pre></div></div>

<p><strong>4. Postgres Startup</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
% launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
%telnet 127.0.0.1 5432
Trying 127.0.0.1...
Connected to rupert-mbp.
Escape character is '^]'.
% psql -d postgres -f /usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/adminpack.sql</pre></div></div>

<p><strong>5. Postgis</strong><br />
Note this will install dependencies, PROJ4 and GEOS. At the time of writing this, we have a problem with GEOS. Need to update GEOS formula to 3.3.1. For more info read:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% open https://github.com/mxcl/homebrew/issues/8151
% open https://gist.github.com/1306088
% brew edit geos</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">% brew install proj
% brew install geos
% brew install postgis OR brew install --HEAD postgis
% createdb -E utf8 template_postgis
% psql -d template_postgis -f /usr/local/Cellar/postgis/1.5.3/share/postgis/postgis.sql
% psql -d template_postgis -f /usr/local/Cellar/postgis/1.5.3/share/postgis/spatial_ref_sys.sql</pre></div></div>

<p><strong>6. osm2pgsql</strong></p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">~% brew install osm2pgsql
==&gt; Checking out http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/
==&gt; ./autogen.sh
==&gt; ./configure
==&gt; make
/usr/local/Cellar/osm2pgsql/HEAD: 6 files, 328K, built in 70 seconds</pre></div></div>

<p>Ok.</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/11/homebrew-postgresql9-0-4-postgis-1-5-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Invalid gemspec on what?!</title>
		<link>/wordpress/2011/09/invalid-gemspec-on-what/</link>
		<comments>/wordpress/2011/09/invalid-gemspec-on-what/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 06:15:58 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">/wordpress/?p=1070</guid>
		<description><![CDATA[This belongs to a royal PITA moment, thus needs a worthy post. I&#8217;m trying to do a bundle install with my Gemfile as follows: group :development, :test do gem 'capybara' gem 'cucumber' gem 'cucumber-rails' gem 'database_cleaner' gem 'rspec-rails' gem 'autotest' gem 'spork' gem 'launchy' end At the time of writing this, these are the errors [...]]]></description>
			<content:encoded><![CDATA[<p>This belongs to a royal PITA moment, thus needs a worthy post. I&#8217;m trying to do a</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">bundle <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>with my Gemfile as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">group <span style="color:#ff3333; font-weight:bold;">:development</span>, <span style="color:#ff3333; font-weight:bold;">:test</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  gem <span style="color:#996600;">'capybara'</span>
  gem <span style="color:#996600;">'cucumber'</span>
  gem <span style="color:#996600;">'cucumber-rails'</span>
  gem <span style="color:#996600;">'database_cleaner'</span>
  gem <span style="color:#996600;">'rspec-rails'</span>
  gem <span style="color:#996600;">'autotest'</span>
  gem <span style="color:#996600;">'spork'</span>
  gem <span style="color:#996600;">'launchy'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>At the time of writing this, these are the errors that I encountered.  Since you are reading this, then I guess something is still wrong here.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Installing cucumber <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.0.6<span style="color: #7a0874; font-weight: bold;">&#41;</span> 
Installing cucumber-rails <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.0.4<span style="color: #7a0874; font-weight: bold;">&#41;</span> Invalid gemspec <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">@</span>cws<span style="color: #000000; font-weight: bold;">/</span>specifications<span style="color: #000000; font-weight: bold;">/</span>cucumber-rails-1.0.4.gemspec<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Illformed requirement <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;#&lt;Syck::DefaultKey:0x00000104b82a40&gt; 0.7.2&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Installing database_cleaner <span style="color: #7a0874; font-weight: bold;">&#40;</span>0.6.7<span style="color: #7a0874; font-weight: bold;">&#41;</span> Invalid gemspec <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">@</span>cws<span style="color: #000000; font-weight: bold;">/</span>specifications<span style="color: #000000; font-weight: bold;">/</span>cucumber-rails-1.0.4.gemspec<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Illformed requirement <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;#&lt;Syck::DefaultKey:0x00000104b82a40&gt; 0.7.2&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Installing orm_adapter <span style="color: #7a0874; font-weight: bold;">&#40;</span>0.0.5<span style="color: #7a0874; font-weight: bold;">&#41;</span> Invalid gemspec <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">@</span>cws<span style="color: #000000; font-weight: bold;">/</span>specifications<span style="color: #000000; font-weight: bold;">/</span>cucumber-rails-1.0.4.gemspec<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Illformed requirement <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;#&lt;Syck::DefaultKey:0x00000104b82a40&gt; 0.7.2&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Installing warden <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.0.5<span style="color: #7a0874; font-weight: bold;">&#41;</span> Invalid gemspec <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">@</span>cws<span style="color: #000000; font-weight: bold;">/</span>specifications<span style="color: #000000; font-weight: bold;">/</span>cucumber-rails-1.0.4.gemspec<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Illformed requirement <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;#&lt;Syck::DefaultKey:0x00000104b82a40&gt; 0.7.2&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Installing devise <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.4.5<span style="color: #7a0874; font-weight: bold;">&#41;</span> Invalid gemspec <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">@</span>cws<span style="color: #000000; font-weight: bold;">/</span>specifications<span style="color: #000000; font-weight: bold;">/</span>cucumber-rails-1.0.4.gemspec<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Illformed requirement <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;#&lt;Syck::DefaultKey:0x00000104b82a40&gt; 0.7.2&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Installing meta_programming <span style="color: #7a0874; font-weight: bold;">&#40;</span>0.2.2<span style="color: #7a0874; font-weight: bold;">&#41;</span> Invalid gemspec <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">@</span>cws<span style="color: #000000; font-weight: bold;">/</span>specifications<span style="color: #000000; font-weight: bold;">/</span>cucumber-rails-1.0.4.gemspec<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Illformed requirement <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;#&lt;Syck::DefaultKey:0x00000104b82a40&gt; 0.7.2&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Ok, avoid the PITA moment by reading <a href="https://github.com/cucumber/cucumber/issues/136">this.</a> And make the changes to the Gemfile like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">group <span style="color:#ff3333; font-weight:bold;">:development</span>, <span style="color:#ff3333; font-weight:bold;">:test</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  gem <span style="color:#996600;">'capybara'</span>
  gem <span style="color:#996600;">'cucumber'</span>, <span style="color:#996600;">&quot;1.0.6&quot;</span>
  gem <span style="color:#996600;">'cucumber-rails'</span>, <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;https://github.com/cucumber/cucumber-rails.git&quot;</span>
  gem <span style="color:#996600;">'database_cleaner'</span>
  gem <span style="color:#996600;">'rspec-rails'</span>
  gem <span style="color:#996600;">'autotest'</span>
  gem <span style="color:#996600;">'spork'</span>
  gem <span style="color:#996600;">'launchy'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Now, I understand why the commit message is like this:  <em>I EAT YAML AND RUBYGEMS FOR toot&#8230;</em></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/09/invalid-gemspec-on-what/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rvm + cron + thinking_sphinx</title>
		<link>/wordpress/2011/08/rvm-cron-thinking_sphinx/</link>
		<comments>/wordpress/2011/08/rvm-cron-thinking_sphinx/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 11:35:13 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[rais3]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">/wordpress/?p=1022</guid>
		<description><![CDATA[1. Want to change crontab&#8217;s editor? export EDITOR=vim 2. crontab -e PATH=/sbin:/bin:/usr/sbin:/usr/bin 30 * * * * /home/rupert/bin/rvm-shell 'ruby-1.9.2-p180@travelspotsinasia' -c 'RAILS_ENV=production rake -f /srv/rails/travelspotsinasia/Rakefile thinking_sphinx:rebuild' &#62; $HOME/travelspotsinasia.index.log 3. Didn&#8217;t work the first time. Argh. robin:~% mail Heirloom mailx version 12.4 7/29/08. Type ? for help. &#34;/var/mail/rupert&#34;: 2 messages &#62;O 1 Cron Daemon Mon Aug 22 [...]]]></description>
			<content:encoded><![CDATA[<p>1. Want to change crontab&#8217;s editor?</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">EDITOR</span>=<span style="color: #c20cb9; font-weight: bold;">vim</span></pre></div></div>

<p>2. crontab -e</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #000000;">30</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>  <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rvm-shell <span style="color: #ff0000;">'ruby-1.9.2-p180@travelspotsinasia'</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'RAILS_ENV=production rake -f /srv/rails/travelspotsinasia/Rakefile thinking_sphinx:rebuild'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>travelspotsinasia.index.log</pre></div></div>

<p>3. Didn&#8217;t work the first time. Argh.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">robin:~<span style="color: #000000; font-weight: bold;">%</span> mail 
Heirloom mailx version <span style="color: #000000;">12.4</span> <span style="color: #000000;">7</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>08.  Type ? <span style="color: #000000; font-weight: bold;">for</span> help.
<span style="color: #ff0000;">&quot;/var/mail/rupert&quot;</span>: <span style="color: #000000;">2</span> messages
<span style="color: #000000; font-weight: bold;">&gt;</span>O  <span style="color: #000000;">1</span> Cron Daemon        Mon Aug <span style="color: #000000;">22</span> <span style="color: #000000;">21</span>:08   <span style="color: #000000;">32</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1314</span>  Cron <span style="color: #000000; font-weight: bold;">&lt;</span>rupert<span style="color: #000000; font-weight: bold;">@</span>robin<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rvm-shell <span style="color: #ff0000;">'ruby-1.9.2-p180@travelspotsinasia'</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'RAILS_ENV=producti
&nbsp;
Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
  * bin_path
  * searchd_binary_name
  * indexer_binary_name
&lt;/mail&gt;</span></pre></div></div>

<p>4. Quick fix</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sphinx<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>indexer indexer
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sphinx<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>indextool indextool
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sphinx<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>search search
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sphinx<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>searchd searchd
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sphinx<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>spelldump spelldump</pre></div></div>

<p>5. Test by adjusting the date on cron. Wait for cron to kick in. Check the log file.<br />
Awesome.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">robin:~<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-f</span> travelspotsinasia.index.log 
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>rupert<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Stopped search daemon <span style="color: #7a0874; font-weight: bold;">&#40;</span>pid <span style="color: #000000;">16831</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>.
Generating Configuration to <span style="color: #000000; font-weight: bold;">/</span>srv<span style="color: #000000; font-weight: bold;">/</span>rails<span style="color: #000000; font-weight: bold;">/</span>travelspotsinasia<span style="color: #000000; font-weight: bold;">/</span>config<span style="color: #000000; font-weight: bold;">/</span>production.sphinx.conf
Sphinx 0.9.9-release <span style="color: #7a0874; font-weight: bold;">&#40;</span>r2117<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">2001</span>-<span style="color: #000000;">2009</span>, Andrew Aksyonoff
&nbsp;
using config <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #ff0000;">'/srv/rails/travelspotsinasia/config/production.sphinx.conf'</span>...
indexing index <span style="color: #ff0000;">'poi_core'</span>...
collected <span style="color: #000000;">10700</span> docs, <span style="color: #000000;">1.1</span> MB
sorted <span style="color: #000000;">0.2</span> Mhits, <span style="color: #000000;">100.0</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">done</span>
total <span style="color: #000000;">10700</span> docs, <span style="color: #000000;">1106049</span> bytes
total <span style="color: #000000;">0.363</span> sec, <span style="color: #000000;">3042131</span> bytes<span style="color: #000000; font-weight: bold;">/</span>sec, <span style="color: #000000;">29429.80</span> docs<span style="color: #000000; font-weight: bold;">/</span>sec
distributed index <span style="color: #ff0000;">'poi'</span> can not be directly indexed; skipping.
total <span style="color: #000000;">2</span> reads, <span style="color: #000000;">0.001</span> sec, <span style="color: #000000;">592.8</span> kb<span style="color: #000000; font-weight: bold;">/</span>call avg, <span style="color: #000000;">0.8</span> msec<span style="color: #000000; font-weight: bold;">/</span>call avg
total <span style="color: #000000;">7</span> writes, <span style="color: #000000;">0.005</span> sec, <span style="color: #000000;">393.1</span> kb<span style="color: #000000; font-weight: bold;">/</span>call avg, <span style="color: #000000;">0.7</span> msec<span style="color: #000000; font-weight: bold;">/</span>call avg
Started successfully <span style="color: #7a0874; font-weight: bold;">&#40;</span>pid <span style="color: #000000;">17764</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>.</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/08/rvm-cron-thinking_sphinx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing a table_name to a postgres plpgsql function</title>
		<link>/wordpress/2011/08/passing-a-table_name-to-a-postgres-plpgsql-function/</link>
		<comments>/wordpress/2011/08/passing-a-table_name-to-a-postgres-plpgsql-function/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 04:32:04 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=1011</guid>
		<description><![CDATA[Using a table_name in a function. The parameter p_schema_name will be passed as a string to the sql string statement processed by EXECUTE. Possible gotchas I encountered here was the FOUND variable is useless after an EXECUTE statement. EXECUTE 'UPDATE...&#34;; IF found THEN --this is not set when we use EXECUTE. END IF; CREATE OR [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Using a table_name in a function.</strong><br />
The parameter p_schema_name will be passed as a string to the sql string statement processed by EXECUTE. Possible gotchas I encountered here was the FOUND variable is useless after an EXECUTE statement.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">EXECUTE <span style="color: #ff0000;">'UPDATE...&quot;;
IF found THEN --this is not set when we use EXECUTE. 
END IF;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> dfms<span style="color: #66cc66;">.</span>upsert_ncm_execution<span style="color: #66cc66;">&#40;</span>p_schema_name text<span style="color: #66cc66;">,</span> p_fleet_id integer<span style="color: #66cc66;">,</span> p_ncm_number integer<span style="color: #66cc66;">,</span> p_version text<span style="color: #66cc66;">,</span> p_hostname text<span style="color: #66cc66;">,</span> p_process_id integer<span style="color: #66cc66;">,</span> p_execution_id integer<span style="color: #66cc66;">&#41;</span>
  RETURNS integer <span style="color: #993333; font-weight: bold;">AS</span>
$BODY$
DECLARE
  record_found <span style="color: #993333; font-weight: bold;">BOOLEAN</span>;
  execution_id INTEGER;
BEGIN
    EXECUTE <span style="color: #ff0000;">'SELECT count(*) FROM '</span> <span style="color: #66cc66;">||</span> p_schema_name <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">'.ncm_executions WHERE fleet_id = $1 AND ncm_number = $2'</span> <span style="color: #993333; font-weight: bold;">INTO</span> record_found <span style="color: #993333; font-weight: bold;">USING</span> p_fleet_id<span style="color: #66cc66;">,</span> p_ncm_number;
    <span style="color: #993333; font-weight: bold;">IF</span> record_found THEN
      EXECUTE <span style="color: #ff0000;">'UPDATE '</span> <span style="color: #66cc66;">||</span> p_schema_name <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">'.ncm_executions SET execution_id = execution_id + 1 WHERE fleet_id = $1 AND ncm_number = $2'</span> <span style="color: #993333; font-weight: bold;">USING</span> p_fleet_id<span style="color: #66cc66;">,</span> p_ncm_number;
    ELSE
      BEGIN
        EXECUTE <span style="color: #ff0000;">'INSERT INTO '</span> <span style="color: #66cc66;">||</span> p_schema_name <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">'.ncm_executions(fleet_id, ncm_number, version, hostname, process_id, execution_id) VALUES($1, $2, $3, $4, $5, $6)'</span> <span style="color: #993333; font-weight: bold;">USING</span> p_fleet_id<span style="color: #66cc66;">,</span> p_ncm_number<span style="color: #66cc66;">,</span> p_version<span style="color: #66cc66;">,</span> p_hostname<span style="color: #66cc66;">,</span> p_process_id<span style="color: #66cc66;">,</span> p_execution_id;
      EXCEPTION WHEN unique_violation THEN
        <span style="color: #808080; font-style: italic;">-- do nothing</span>
      END;
    END <span style="color: #993333; font-weight: bold;">IF</span>;
&nbsp;
    EXECUTE <span style="color: #ff0000;">'SELECT execution_id FROM '</span> <span style="color: #66cc66;">||</span> p_schema_name <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">'.ncm_executions WHERE fleet_id = $1 AND ncm_number = $2'</span> <span style="color: #993333; font-weight: bold;">INTO</span> execution_id <span style="color: #993333; font-weight: bold;">USING</span> p_fleet_id<span style="color: #66cc66;">,</span> p_ncm_number;
&nbsp;
    <span style="color: #993333; font-weight: bold;">RETURN</span> execution_id;
END;
$BODY$
  <span style="color: #993333; font-weight: bold;">LANGUAGE</span> plpgsql VOLATILE
  COST <span style="color: #cc66cc;">100</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/08/passing-a-table_name-to-a-postgres-plpgsql-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>how to use a schema name in mysql2psql</title>
		<link>/wordpress/2011/08/migrating-from-mysql-to-postgres/</link>
		<comments>/wordpress/2011/08/migrating-from-mysql-to-postgres/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 02:07:23 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=1009</guid>
		<description><![CDATA[Below is a summary of my experiences with migrating from MySQL to Postgres using mysql2psql &#8211; https://github.com/maxlapshin/mysql2postgres %gem install mysql2psql To migrate a &#8220;tsa&#8221; database from mysql to postgres, create a tsa.yml mysql: hostname: localhost port: 3306 socket: /tmp/mysql.sock username: dbadmin password: password database: tsa &#160; destination: # if file is given, output goes to [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a summary of my experiences with migrating from MySQL to Postgres using <strong>mysql2psql &#8211; <a href="https://github.com/maxlapshin/mysql2postgres">https://github.com/maxlapshin/mysql2postgres</a></strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span>gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql2psql</pre></div></div>

<p>To migrate a &#8220;tsa&#8221; database from mysql to postgres, create a tsa.yml</p>

<div class="wp_syntax"><div class="code"><pre class="yml" style="font-family:monospace;">mysql:
 hostname: localhost
 port: 3306 
 socket: /tmp/mysql.sock
 username: dbadmin 
 password: password
 database: tsa
&nbsp;
destination:
 # if file is given, output goes to file, else postgres
 #file: tsa.dump
 postgres:
  hostname: localhost
  port: 5432 
  database: tsa:hotels #database_name:schema_name
  username: dbadmin
  password: password
&nbsp;
# if tables is given, only the listed tables will be converted.  leave empty to convert all tables.
#tables:
#- table1
#- table2
# if exclude_tables is given, exclude the listed tables from the conversion.
#exclude_tables:
#- table3
#- table4
&nbsp;
# if supress_data is true, only the schema definition will be exported/migrated, and not the data
supress_data: false
&nbsp;
# if supress_ddl is true, only the data will be exported/imported, and not the schema
supress_ddl: false
&nbsp;
# if force_truncate is true, forces a table truncate before table loading
force_truncate: false</pre></div></div>

<p>Run.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span>mysql2psql tsa.yml</pre></div></div>

<p>References:<br />
<a href="http://en.wikibooks.org/wiki/Converting_MySQL_to_PostgreSQL">http://en.wikibooks.org/wiki/Converting_MySQL_to_PostgreSQL</a></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/08/migrating-from-mysql-to-postgres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VIM cheatsheet</title>
		<link>/wordpress/2011/05/vim-cheatsheet/</link>
		<comments>/wordpress/2011/05/vim-cheatsheet/#comments</comments>
		<pubDate>Sat, 07 May 2011 07:03:18 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">/wordpress/?p=999</guid>
		<description><![CDATA[set nocompatible set nu set expandtab &#160; &#34;this will change tab to spaces set ts=2 set shiftwidth=2 set expandtab &#160; set hlsearch syntax on &#160; &#34;Use TAB to complete when typing words, else inserts TABs as usual. &#34;Uses dictionary and source files to find matching words to complete. &#160; &#34;See help completion for source, &#34;Note: [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">set nocompatible
set nu
set expandtab
&nbsp;
&quot;this will change tab to spaces
set ts=2 
set shiftwidth=2
set expandtab
&nbsp;
set hlsearch
syntax on
&nbsp;
&quot;Use TAB to complete when typing words, else inserts TABs as usual.
&quot;Uses dictionary and source files to find matching words to complete.
&nbsp;
&quot;See help completion for source,
&quot;Note: usual completion is on &lt;C-n&gt; but more trouble to press all the time.
&quot;Never type the same word twice and maybe learn a new spellings!
&quot;Use the Linux dictionary when spelling is in doubt.
&quot;Window users can copy the file to their machine.
function! Tab_Or_Complete()
  if col('.')&gt;1 &amp;&amp; strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
    return &quot;\&lt;C-N&gt;&quot;
  else 
    return &quot;\&lt;Tab&gt;&quot;
  endif
endfunction
:inoremap &lt;Tab&gt; &lt;C-R&gt;=Tab_Or_Complete()&lt;CR&gt;
:set dictionary=&quot;/usr/dict/words&quot;
&nbsp;
set numberwidth=5
set cmdheight=2
&quot;To map: imap ;f foobar =&gt; Type f; foobar will be inserted
&nbsp;
&quot;RSPEC Where ! is execute command. % is the current file
&quot;:!rspec %
&nbsp;
&quot;Map RSPEC test to ,t
&quot;:map ,t :w\|!rspec %&lt;cr&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2011/05/vim-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

