Skip to content

Instantly share code, notes, and snippets.

@remino
Forked from MicahChalmer/.htaccess
Created November 17, 2015 03:07

Revisions

  1. @MicahChalmer MicahChalmer revised this gist Oct 6, 2014. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions dreamhost_rbenv_setup.sh
    Original file line number Diff line number Diff line change
    @@ -26,8 +26,10 @@ eval "$(~/.rbenv/bin/rbenv init -)"
    # Decide which version of Ruby we're going to install and use.
    NEW_RUBY_VERSION=1.9.3-p327

    # Using that as the temp space, build and install ruby 1.9.3
    TMPDIR=~/.rbenv/BUILD_TEMP rbenv install $NEW_RUBY_VERSION
    # Using that as the temp space, build and install ruby 1.9.3.
    # The MAKE_OPTS=-j2 part is to limit make to 2 simultaneous jobs,
    # so that DreamHost won't kill the build of ruby.
    TMPDIR=~/.rbenv/BUILD_TEMP MAKE_OPTS=-j2 rbenv install $NEW_RUBY_VERSION

    # Now everything is set up properly, you should be able to set your
    # directory to use the new ruby:
  2. @MicahChalmer MicahChalmer revised this gist Jun 19, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions dreamhost_rbenv_setup.sh
    Original file line number Diff line number Diff line change
    @@ -41,3 +41,6 @@ rbenv rehash

    # Then use it to install the rest of your gems:
    bundle install

    # Create the "log" dir in for the file containing the stderr of your dispatch.fcgi script:
    mkdir -p log
  3. @MicahChalmer MicahChalmer revised this gist Jun 14, 2013. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion dreamhost_rbenv_setup.sh
    Original file line number Diff line number Diff line change
    @@ -33,8 +33,11 @@ TMPDIR=~/.rbenv/BUILD_TEMP rbenv install $NEW_RUBY_VERSION
    # directory to use the new ruby:
    rbenv local $NEW_RUBY_VERSION

    # Bundler doesn't come with ruby, so install it first:
    # Bundler isn't included with ruby, so install it first:
    gem install bundler

    # Make sure rbenv picks up the newly installed bundler:
    rbenv rehash

    # Then use it to install the rest of your gems:
    bundle install
  4. @MicahChalmer MicahChalmer revised this gist Jan 13, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion dreamhost_rbenv_setup.sh
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,9 @@ mkdir ~/.rbenv/BUILD_TEMP
    unset GEM_HOME
    unset GEM_PATH

    # Let rbenv set up its paths. You probably want this in your .bashrc as well.
    # Add rbenv to PATH and let it set itself up.
    # You probably want these two lines in your .bashrc as well:
    export PATH=~/.rbenv/bin:"$PATH"
    eval "$(~/.rbenv/bin/rbenv init -)"

    # Decide which version of Ruby we're going to install and use.
  5. @MicahChalmer MicahChalmer revised this gist Dec 17, 2012. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions dreamhost_rbenv_setup.sh
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    # also be the directory configured as "web directory" for your domain
    # in the DreamHost panel.


    # Install rbenv and ruby-build
    git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
    git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
    @@ -20,12 +21,15 @@ unset GEM_PATH
    # Let rbenv set up its paths. You probably want this in your .bashrc as well.
    eval "$(~/.rbenv/bin/rbenv init -)"

    # Decide which version of Ruby we're going to install and use.
    NEW_RUBY_VERSION=1.9.3-p327

    # Using that as the temp space, build and install ruby 1.9.3
    TMPDIR=~/.rbenv/BUILD_TEMP rbenv install 1.9.3-p327
    TMPDIR=~/.rbenv/BUILD_TEMP rbenv install $NEW_RUBY_VERSION

    # Now everything is set up properly, you should be able to set your
    # directory to use the new ruby:
    rbenv local 1.9.3-p327
    rbenv local $NEW_RUBY_VERSION

    # Bundler doesn't come with ruby, so install it first:
    gem install bundler
  6. @MicahChalmer MicahChalmer created this gist Dec 17, 2012.
    13 changes: 13 additions & 0 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <IfModule mod_fastcgi.c>
    AddHandler fastcgi-script .fcgi
    </IfModule>
    <IfModule mod_fcgid.c>
    AddHandler fcgid-script .fcgi
    </IfModule>

    Options +FollowSymLinks +ExecCGI

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]
    8 changes: 8 additions & 0 deletions dispatch.fcgi
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    #!/bin/bash
    this_dir=`dirname $0`
    unset GEM_HOME
    unset GEM_PATH
    export PATH=~/.rbenv/bin:"$PATH"
    eval "$(~/.rbenv/bin/rbenv init -)"
    err_log_file="${this_dir}/log/dispatch_err.log"
    exec ~/.rbenv/shims/ruby "${this_dir}/dispatch_fcgi.rb" "$@" 2>>"${err_log_file}"
    27 changes: 27 additions & 0 deletions dispatch_fcgi.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    require 'rubygems'
    require 'bundler'
    Bundler.setup(:default, :fcgi)
    require 'rack'

    class Rack::PathInfoRewriter
    def initialize(app)
    @app = app
    end

    def call(env)
    env['SCRIPT_NAME'] = '' # Don't delete it--Rack::URLMap assumes it is not nil
    pathInfo, query = env['REQUEST_URI'].split('?', 2)
    env['PATH_INFO'] = pathInfo
    env['QUERY_STRING'] = query
    @app.call(env)
    end
    end

    app, options = Rack::Builder.parse_file('config.ru')
    wrappedApp = Rack::Builder.new do
    use Rack::ShowExceptions
    use Rack::PathInfoRewriter
    run app
    end

    Rack::Handler::FastCGI.run wrappedApp
    34 changes: 34 additions & 0 deletions dreamhost_rbenv_setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    # Initial setup for Ruby 1.9.3 on DreamHost shared hosting.
    # We assume you're already in your project's root directory, which should
    # also be the directory configured as "web directory" for your domain
    # in the DreamHost panel.

    # Install rbenv and ruby-build
    git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
    git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

    # Create temporary directory--DreamHost does not allow files in /tmp to be
    # executed, which makes the default not work
    mkdir ~/.rbenv/BUILD_TEMP

    # DreamHost will set your GEM_HOME and GEM_PATH for you, but this conflicts
    # with rbenv, so we unset them here. You'll want to do this in your .bashrc
    # on the dreamhost account.
    unset GEM_HOME
    unset GEM_PATH

    # Let rbenv set up its paths. You probably want this in your .bashrc as well.
    eval "$(~/.rbenv/bin/rbenv init -)"

    # Using that as the temp space, build and install ruby 1.9.3
    TMPDIR=~/.rbenv/BUILD_TEMP rbenv install 1.9.3-p327

    # Now everything is set up properly, you should be able to set your
    # directory to use the new ruby:
    rbenv local 1.9.3-p327

    # Bundler doesn't come with ruby, so install it first:
    gem install bundler

    # Then use it to install the rest of your gems:
    bundle install