Sep 24 2009

Installing Sinatra on Site5

Category: ruby,tutorialgiordano scalzo @ 11:28 am

I think Rails is a wonderful framework that boosts the success of Ruby, but sometimes is a a little overkill.
Enter Sinatra, a microframework in Ruby, aims to create simple web applications.

As mentioned in a previous post, I own a shared access on a Site5, so I began to search any documentation to install a simple Sinatra app on Site5.
I didn’t find a lot of documentation, but a post gave some hints in the right direction.

First of all, it need to install locally Sinatra gem configuring GEM_PATH and GEM_HOME.
Then we need to create a subdomain, i.e. sinatra.scalzo.biz, where we’ll implement Sinatra’s app. For an unknown reason, I’d to configure a subdirectory as document root:

Domain Configuration

The htaccess directory contains the file .htaccess that enables Phusion Passenger:

PassengerEnabled on
RackBaseURI /

In parent directory we write the Phusion Passenger configuration, config.ru:

ENV['GEM_PATH'] = "/home/USER/gems:/usr/lib/ruby/gems/1.8"
ENV['GEM_HOME'] = "/home/USER/gems"
require 'rubygems'
require 'sinatra'

require 'app'
run Sinatra.application

and our Sinatra application (I call it app):

get '/' do
  "Hello World!"
end
get '/hi' do
  "Hi World!"
end

That’s it!
Now we can call the urls ‘http://sinatra.scalzo.biz/‘ and ‘http://sinatra.scalzo.biz/hi‘.

Technorati Tags: , ,

Tags: , ,


Aug 28 2009

Private git repositories on Site5

Category: tutorialgiordano scalzo @ 4:51 pm

It happens I have a shared host on Site5 and it happens most of kool koders are moving to git.
I’m not a so kool koder, but I think git deserve a try.

I know Github offers a wonderful service for open source projects, and I tried it for a bunch of pet works, but something is better to keep private, so, some month ago, I tried to set up a git repository on my Site5 account without success.

Some day ago, I bumped into a couple of posts and, finally, I reached my goal.

Set up a password-less connection

git communication is based on ssh, but a password request each ‘git push’ or ‘git pull’ can be annoying in day-by-day working, so the first thing is to make our connection trusted by the server.
In this post, we can find detailed instructions for a Linux system:

user@localhost:~$ ssh-keygen -t dsa
user@localhost:~$ scp ~/.ssh/id_dsa.pub remoteuser@remotehost:
user@localhost:~$ ssh remoteuser@remotehost:
[remoteuser@remotehost ~]$ cat id_dsa.pub >> .ssh/authorized_keys

For other OS, Google is your friend.

Create a repository on Site5

Some month ago, all Site5‘s servers migrated to the last version of git , but if you can’t find it installed, you can open a ticket: Site5‘s support is always friendly and quick.
Now we can create our repository:

[remoteuser@remotehost ~]$ mkdir -p git/repo.git
[remoteuser@remotehost ~]$ cd git/repo.git
[remoteuser@remotehost ~]$ git --bare init
[remoteuser@remotehost ~]$ exit

and create our local repository:

user@host:~$ mkdir git
user@host:~$ cd git
user@host:~$ git clone ssh://remoteuser@remotehost/~/git/repo.git

user@host:~$ echo 'Here we go' > README
user@host:~$ git add .
user@host:~$ git commit
user@host:~$ git push

Fixing “fatal: no matching remote head”-error

After that, when I tried to push my modifies I got an “fatal: no matching remote head” error… fortunately I wasn’t alone with that problem.
First of all we need create an empty local repository then tell git that the “origin” of the local repository is the remote repository

user@host:~$ cd repo
user@host:~$ git init
user@host:~$ echo 'Here we go' > README
user@host:~$ git add .
user@host:~$ git commit -ma ''
user@host:~$ git push
user@host:~$ git remote add origin ssh://remotehost/~/git/repo.git

Then we have to connect the upstream “origin” with the current local branch:

vi .git/config

and adding the following at the bottom:

[branch "master"]
  remote = origin
  merge = refs/heads/master

Finally we have to synchronize remote with local repository:

git push origin master

After that

git push

and

git pull

should work without problem

Conclusion

When discovered all necessary steps, any new repository installation goes smooth; in this post I tried to be complete and gather all the necessary informations.
If you are new to git in this page you will find some useful links.

Technorati Tags: , , ,

Tags: , , ,