Tag Archives: lighttpd

Installing WP on arch, and migrating from blogger

So I’ve migrated my blog from blogger to wordpress, with the advent of google+ this could have been a premature move, but wordpress is just *nicer*.

Some major points about this migration.

  1. From Google’s servers to my own
  2. Want to have support for multiple wordpresses
  3. WordPress gets things via FTP (eurgh)

So, point 1 and 2.

I made a directory in /srv for the numerous wordpresses, and then created a mysql database ready for the blogs (WP lets you have multiple blogs on the same database, by having different prefixes). Due to wanting to have multiple users and having the FTP features, I decided that this prefix would define the internal blog name. So for example, lets make a blog with the prefix ex.

  1. create the directory exwordpress
  2. make sure the directory is owned by the http
  3. set permissions to 775, via sudo chmod -R 775 .
  4. grab the wordpress tarball and extract
  5. configure any traffic for your blog domain to go to /srv/[wordpress directory]/exwordpress/

Load up your page, and configure the wordpress to point to your database, and voila, your basic wordpress set up is done.

Now, I wanted to import my blogger content, so on the dashboard, tools, import, blogger … ahh I need to install a plug-in. Oh, it needs ftp access to my server …

On to point 3

I used vsFTP, which required some fiddling with PAM. There is a sample config on the wiki page which works out of the box. If you want to test just ftp to your server using your virtual user credentials and try and create a temporary directory. If you can, job done.

So, I finally get the blogger content imported, which is fine, but for a few minor issues.

  • Every title, and the content, is preceded by a single “>”
    • Hey, if it is open source, I’ll see if I can find a fix …
  • tags are converted to categories
    • Which isn’t that much of an issue with the tag<->category converter

So, conversion done, just a pity that the only way to fix the conversion bug was to manually edit my posts.

Rails 3 and lighttpd

This was performed on Archlinux with lighttpd 1.4.28 and rails 3.0.3

Prerequisites

Required packages:

  • lighttpd,
  • fcgi,
  • ruby,
  • and their dependencies…

 

Ruby Setup

Required gems:

  • fcgi,
  • bundler

(if you are behind a proxy, the magic gem command is :

# gem install GEM -r -p "http://[PROXY_URL]:[PROXY_PORT]"

)

Once you have that you need to create a “dispatch.fcgi” script to do all the rails magic. I found an example one at http://stackoverflow.com/questions/3296206/rails-3-and-fcgi .

#!/usr/bin/ruby

require 'rubygems'require 'fcgi'

require_relative '../config/environment'

class Rack::PathInfoRewriter  

  def initialize(app)    
    @app = app  
  end

  def call(env)    
    env.delete('SCRIPT_NAME')    
    parts = env['REQUEST_URI'].split('?')    
    env['PATH_INFO'] = parts[0]    
    env['QUERY_STRING'] = parts[1].to_s    
    @app.call(env)  
  end
end

Rack::Handler::FastCGI.run  Rack::PathInfoRewriter.new(YOUR_APP_NAME::Application)

Running a “bundle install” from your app root will make sure all the necessary gems are available for local use. Follow these instructions and run “ruby public/dispatch.fcgi”, if you get no errors, voila!

Lighttpd Setup

Now, to set up lighttpd you need to merge this with your config:

server.modules   += ( "mod_fastcgi", "mod_rewrite" )

$HTTP["host"] == "localhost" {        

  server.document-root       =   "/path/to/your/app/public/"

  server.dir-listing         =   "disable"        
  server.error-handler-404   =   "/dispatch.fcgi"

  fastcgi.server             =   ( 
                                   ".fcgi" => ( 
                                     "localhost" => (
                                       "min-procs" => 1,
                                       "max-procs" => 1,
                                       "socket" => "/tmp/ruby-beholder.socket",                
                                       "bin-path" => "/path/to/your/app/public/dispatch.fcgi",                
                                       "bin-environment" => ( "RAILS_ENV" => "development" )        
                                       ) 
                                     ) 
                                   )
}

A quick “sudo /etc/rc.d/lighttpd restart” and a check of the error logs will tell you if it has worked