Friday, August 26, 2011

Installing Sequel on Ubuntu (11.04)

Installed sequel on my Ubuntu (11.04).

$ sudo gem install sequel
Successfully installed sequel-3.26.0
1 gem installed
Installing ri documentation for sequel-3.26.0...
Installing RDoc documentation for sequel-3.26.0...
$ sequel -v
sequel 3.26.0
$ irb
irb(main):001:0> require 'sequel'
=> true
irb(main):002:0> exit

Sunday, August 21, 2011

Installing Shotgun (Ruby Gem) on Ubuntu (11.04)

Installed shotgun on my Ubuntu (11.04).

1. Resources.

http://ruby.about.com/od/sinatra/a/sinatra5.htm

2. Installation.

$ sudo gem install shotgun
Successfully installed shotgun-0.9
1 gem installed
Installing ri documentation for shotgun-0.9...
Installing RDoc documentation for shotgun-0.9...
$ irb
irb(main):001:0> require 'shotgun'   # check the installation
=> true
irb(main):002:0> exit

Installing Sinatra on Ubuntu (11.04)

I installed sinatra, a lightweight web framework, on my Ubuntu (11.04).

1. Resources

Sinatra Ruby: http://www.sinatrarb.com/

2. Installation.

$ sudo gem install sinatra
Successfully installed tilt-1.3.2        # what is this?
Successfully installed sinatra-1.2.6
2 gems installed
Installing ri documentation for tilt-1.3.2...
Installing ri documentation for sinatra-1.2.6...
Installing RDoc documentation for tilt-1.3.2...
Installing RDoc documentation for sinatra-1.2.6...
$ irb
irb(main):001:0> require 'sinatra'      # check installation
=> true
irb(main):002:0> exit

3. What is Tilt?

The sinatra installer installed tilt. What is tilt?
According to the tilt site, it is "a thin interface over a bunch of different Ruby template engines in an attempt to make their usage as generic possible." It seems to support a very large number of template engines, including ERB, Haml, Erubis, Maruku, Radius, RedCloth, BlueCloth, etc.

Installing SQLite3 for Ruby on Ubuntu 11.4

Install SQL commandline interface and interface library for Ruby 1.9.1


1. Resources.

SQLite Home Page: http://www.sqlite.org/

2. Install SQLite3 Libraries and a commandline interface.

Open Synaptic Package Manager
Find and install the following:
-- sqlite3
-- libsqlite3-ruby1.9.1
-- libsqlite3-dev



3.Test sqlite3 commandline interface.

$ sqlite3 --version
3.7.4

4. Install sqlite3 gem.

Note that sqlite3-ruby is now obsolete. The sqlite3-ruby is now called "sqlite3". The sqlite3-ruby is now a dummy gem that depends on sqlite3. (See here.)

$ sudo gem install sqlite3
Building native extensions.  This could take a while...
Successfully installed sqlite3-1.3.4
1 gem installed
Installing ri documentation for sqlite3-1.3.4...
Installing RDoc documentation for sqlite3-1.3.4...
Test the gem installation.
$ irb
irb(main):001:0> require 'sqlite3'
=> true
irb(main):002:0> exit


Sunday, August 14, 2011

Running a Rack app (Ramaze) with Nginx/Unicorn on Ubuntu (11.04)

I want to setup a Rack app on a virtual host on my Ubuntu 11.04 for my tiny intranet. I am already running multiple virtual hosts (www.domain1.com and www.domain2.com) on my Ubuntu. This time, I want to add another virtual host (www.domain3.com) that invokes a Rack application.



1. Requirements.

Ubuntu - a Linux distribution
Ruby - a scripting language
Nginx - a web server that handles multiple virtual hosts
Unicorn - web server to be used to runs behind Nginx
Ramaze - a Rack web framework ("Mini Rails")


2. Resources.

Nginx: http://wiki.nginx.org/
Unicorn: http://unicorn.bogomips.org/
Ramaze: http://ramaze.net/
Silpsen: Setting up Unicorn with Nginx
slicehost: Ubuntu Intrepid - Nginx, rails and mongrels
slicehost: Ubuntu Intrepid - Nginx, rails and thin
Tom Kersten: Setting up Ubuntu with Nginx, Unicorn, ree, rv
Maxime Rousseaux-Bridle blog: Running Ramaze with Unicorn, Nginx and God


3. Create a virtual host.
My ultimate goal is to create a virtual host (www.domain3.com) to run my Rack app (Ramaze). But first I create a normal virtual host (www.domain3.com), without running any web app. Later I will create a web app, which will take over the control of incoming requests.

The first step to create a virtual host is to crate a directory structure and place an index.html file in its public folder.
$ mkdir ~/public_html/domain3.com
$ mkdir ~/public_html/domain3.com/{public,private,log,backup}
$ gedit ~/public_html/domain3.com/public/index.html   # create home index.html file
It's content looks like this:
<html>
  <head>
    <title>domain3.com</title>
  </head>
  <body>
    <h1>domain3.com</h1>
  </body>
</html>
Then I create a normal virtual host file for Nginx. Later I will modify it to redirect its requests to my Rack (Ramaze) app.
$ sudo gedit /etc/nginx/sites-available/domain3.com
Here is it's content.
server {
            listen   80;
            server_name  www.domain3.com;
            rewrite ^/(.*) http://domain3.com/$1 permanent;
           }

server {
            listen   80;
            server_name domain3.com;

            access_log /home/socrateos/public_html/domain3.com/log/access.log;
            error_log /home/socrateos/public_html/domain3.com/log/error.log;

            location / {
                        root   /home/socrateos/public_html/domain3.com/public/;
                        index  index.html;
                        }
            }
Now enable the host, by creating a symlink file into /etc/nginx/sites-enabled directory.
$ sudo ln -s /etc/nginx/sites-available/domain3.com /etc/nginx/sites-enabled/domain3.com
Finally update the /etc/hosts file by adding a new domain name. (My tiny intranet does not need/use DNS.) I just manually edit hosts file in each PC.
127.0.1.1 domain1.com
127.0.1.1 www.domain1.com
127.0.1.1 domain2.com
127.0.1.1 www.domain2.com
127.0.1.1 domain3.com          # new domain added to be used for Ramaze app
127.0.1.1 www.domain3.com      # new domain added to be used for Ramaze app
I added similar entries to C:\Windows\System32\drivers\etc\hosts on my Windows Visita.
192.168.12.13 domain1.com
192.168.12.13 www.domain1.com
192.168.12.13 domain2.com
192.168.12.13 www.domain2.com  
192.168.12.13 domain3.com      # new domain added to be used for Ramaze app
192.168.12.13 www.domain3.com  # new domain added to be used for Ramaze app
Restart my Nginx server.
$ sudo /etc/init.d/nginx stop
Stopping nginx: nginx.
$ sudo /etc/init.d/nginx start
Starting nginx: nginx.
Now test http://www.domain3.com with my browser.
The result looks like this as expected. So my new virtual host is working.
















4. Create a Rack App (Ramaze)

I now build a Rack (Ramaze) app. Then do a quick test run with Unicorn server, without going through Nginx.
$ cd ~/public_html/      
$ mkdir apps/          # a parent directory for all my web apps
$ cd apps/
$ ramaze create app1   # create a Ramaze app
The application has been generated and saved in app1
$ cd app1/
$ mkdir tmp            
$ mkdir tmp/pids       # for unicorn master pid
$ mkdir log            # for nginx and unicorn logs
$ unicorn              # a quick test run with unicorn server
I, [2011-08-08T00:08:11.149051 #3759]  INFO -- : listening on addr=0.0.0.0:8080 fd=3
I, [2011-08-08T00:08:11.149263 #3759]  INFO -- : worker=0 spawning...
I, [2011-08-08T00:08:11.149838 #3759]  INFO -- : master process ready
I, [2011-08-08T00:08:11.150249 #3761]  INFO -- : worker=0 spawned pid=3761
I, [2011-08-08T00:08:11.150372 #3761]  INFO -- : Refreshing Gem list
I, [2011-08-08T00:08:11.480209 #3761]  INFO -- : worker=0 ready
Here is the result from http://localhost:8080, directly accessing Unicorn server. Later, after I setup Unicorn to run behind Nginx, I will access our app from http://www.domain3.com, where my nginx server transfers control to Unicorn server, which actually serves our web app.


















5. Make Unicorn run behind Nginx

At this point, I have two web servers running independently: Nginx (for a few virtual domains) at port 80 and Unicorn (for Ramaze app) at port 8080. I am now going to modify the configuration of one of nginx's virtual domains (domain3.com) so that Ngix will transfer control to Unicorn if web requests are for this the domain. In other words, Unicorn will be working as a server behind the Nginx server.
sudo gedit /etc/nginx/sites-available/domain3.com    # open the domain3.com (conf) file for editing.
Here is the modified contents. This is based on slicehost's "Ubuntu Intrepid - Nginx, rails and thin".
upstream backend {
        server 127.0.0.1:8080;
    }

server {
            listen   80;
            server_name  www.domain3.com;
            rewrite ^/(.*) http://domain3.com/$1 permanent;
           }


server {
            listen   80;
            server_name domain3.com;

            access_log /home/socrateos/public_html/apps/app1/log/access.log;
            error_log /home/socrateos/public_html/apps/app1/log/error.log;

            root   /home/socrateos/public_html/apps/app1/public/;
            index  index.html;

            location / {
                          proxy_set_header  X-Real-IP  $remote_addr;
                          proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                          proxy_set_header Host $http_host;
                          proxy_redirect off;

                          if (-f $request_filename/index.html) {
                                           rewrite (.*) $1/index.html break;
                          }

                          if (-f $request_filename.html) {
                                           rewrite (.*) $1.html break;
                          }

                          if (!-f $request_filename) {
                                           proxy_pass http://backend;
                                           break;
                          }
            }

}

Restart Nginx.
$ sudo /etc/init.d/nginx stop
Stopping nginx: nginx.
$ sudo /etc/init.d/nginx status
 * could not access PID file for nginx
$ sudo /etc/init.d/nginx start
Starting nginx: nginx.
Then go to http://www.domain3.com. And Voila! We are now seeing a Rack app running under Unicorn server behind a Nginx web server.

















6. Daemonize Unicorn


The last step is to run Unicorn as a daemon and start it when Ubuntu starts up. To do this, first, I create a new conf file for Unicorn. I will name it unicorn.conf and place it in app's root directory.
gedit ~/public_html/apps/app1/unicorn.conf
The following is its contents. It is based on http://unicorn.bogomips.org/examples/unicorn.conf.rb and "Running Ramaze with Unicorn, Nginx and God" by Maxime Rousseaux-Bridle. For a detailed information, see Unicorn::Configurator.

# unicorn.conf
# (ruby code)
# Based on the following examples: 
# http://unicorn.bogomips.org/examples/unicorn.conf.rb
# http://blog.xambr.com/2010/01/16/running-ramaze-with-unicorn-nginx-and-god/


APP_ROOT = "/home/socrateos/public_html/apps/app1"

worker_processes 4
working_directory APP_ROOT

# listen on both a Unix domain socket and a TCP port
listen "{APP_ROOT}/tmp/unicorn.sock", :backlog => 64
listen 8080, :tcp_nopush => true

# Location of master process PID file
pid "#{APP_ROOT}/tmp/pids/unicorn-master.pid"

# Location of stderr/stdout logs
stderr_path "#{APP_ROOT}/log/unicorn.stderr.log"
stdout_path "#{APP_ROOT}/log/unicorn.stdout.log"

# combine REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true

Next, I create an init script file unicorn and placed it in /etx/init.d/ directory to launch Unicorn as a daemon.
#! /bin/sh

# File: /etc/init.d/unicorn

### BEGIN INIT INFO
# Provides:          unicorn
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the unicorn web server
# Description:       starts unicorn
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/var/lib/gems/1.9.1/bin/unicorn
DAEMON_OPTS="-c /home/socrateos/public_html/apps/app1/unicorn.conf -E production -D"
NAME=unicorn
DESC="Unicorn app for app1"
PID=/home/socrateos/public_html/apps/app1/tmp/pids/unicorn-master.pid

case "$1" in
  start)
 echo -n "Starting $DESC: "
 $DAEMON $DAEMON_OPTS
 echo "$NAME."
 ;;
  stop)
 echo -n "Stopping $DESC: "
        kill -QUIT `cat $PID`
 echo "$NAME."
 ;;
  restart)
 echo -n "Restarting $DESC: "
        kill -QUIT `cat $PID`
 sleep 1
 $DAEMON $DAEMON_OPTS
 echo "$NAME."
 ;;
  reload)
        echo -n "Reloading $DESC configuration: "
        kill -HUP `cat $PID`
        echo "$NAME."
        ;;
  *)
 echo "Usage: $NAME {start|stop|restart|reload}" >&2
 exit 1
 ;;
esac

exit 0

Then make sure to start it on start up.
$ sudo update-rc.d -f unicorn defaults
 Adding system startup for /etc/init.d/unicorn ...
   /etc/rc0.d/K20unicorn -> ../init.d/unicorn
   /etc/rc1.d/K20unicorn -> ../init.d/unicorn
   /etc/rc6.d/K20unicorn -> ../init.d/unicorn
   /etc/rc2.d/S20unicorn -> ../init.d/unicorn
   /etc/rc3.d/S20unicorn -> ../init.d/unicorn
   /etc/rc4.d/S20unicorn -> ../init.d/unicorn
   /etc/rc5.d/S20unicorn -> ../init.d/unicorn

7. Test

I rebooted the machine to check if Unicorn started automatically.
$ ps aux | grep unicorn
root      1151  0.6  0.2  14604 10900 ?        Sl   23:47   0:00 unicorn master -c /home/socrateos/public_html/apps/app1/unicorn.conf -E production -D                                    
root      1192  0.0  0.2  14604  9088 ?        Sl   23:47   0:00 unicorn worker[0] -c /home/socrateos/public_html/apps/app1/unicorn.conf -E production -D                                 
root      1195  0.0  0.2  14604  9088 ?        Sl   23:47   0:00 unicorn worker[1] -c /home/socrateos/public_html/apps/app1/unicorn.conf -E production -D                                 
root      1198  0.0  0.2  14604  9088 ?        Sl   23:47   0:00 unicorn worker[2] -c /home/socrateos/public_html/apps/app1/unicorn.conf -E production -D                                 
root      1201  0.0  0.2  14604  9092 ?        Sl   23:47   0:00 unicorn worker[3] -c /home/socrateos/public_html/apps/app1/unicorn.conf -E production -D                                 
1001      1820  0.0  0.0   5128   860 pts/0    S+   23:48   0:00 grep --color=auto unicorn
Yes!
Finally, go to http:\\www.domain3.com to see if I can see my Ramaze app.
The answer is YES.





Sunday, August 7, 2011

Setting up Private Virtual Hosts for Nginx on Ubuntu (11.04)

I am setting up private vitrual hosts for Nginx on my Ubuntu. I am following slicehost blog (see Resources section below).

1. Resources.
slicehost "Nginx Virtual Hosts #1"
slicehost "Nginx Virtual Hosts #2"

2. Build Directory Structure.
$ cd ~   # in my home directory
$ mkdir public_html
$ mkdir public_html/domain1.com  # first virtual host home directory
$ mkdir public_html/domain1.com/{public,private,log,backup} # and its sub-directoires
$ mkdir public_html/domain2.com  # second virtual host home directory
$ mkdir public_html/domain2.com/{public,private,log,backup} # and its sub-directories
It looks like this.






















3.Create Default Home Pages (index.html) for Each
$ gedit public_html/domain1.com/public/index.html
It's content is something like this:
<html>
  <head>
    <title>domain1.com</title>
  </head>
  <body>
    <h1>domain1.com</h1>
  </body>
</html>
Likewise,
$ gedit public_html/domain2.com/public/index.html
It's content is something like this:
<html>
  <head>
    <title>domain2.com</title>
  </head>
  <body>
    <h1>domain2.com</h1>
  </body>
</html>

4. Create vhost files.
$ sudo gedit /etc/nginx/sites-available/domain1.com
I copied and modified this from here at slicehost.
server {

            listen   80;
            server_name  www.domain1.com;
            rewrite ^/(.*) http://domain1.com/$1 permanent;

           }


server {

            listen   80;
            server_name domain1.com;

            access_log /home/socrateos/public_html/domain1.com/log/access.log;
            error_log /home/socrateos/public_html/domain1.com/log/error.log;

            location / {

                        root   /home/socrateos/public_html/domain1.com/public/;
                        index  index.html;

                        }

            }
The second one for domain2.com is similar.

5. Enable these vhosts.
By creating symlink files onto sites-enabled directory, the vhosts gets enabled.
$ sudo ln -s /etc/nginx/sites-available/domain1.com /etc/nginx/sites-enabled/domain1.com
$ sudo ln -s /etc/nginx/sites-available/domain2.com /etc/nginx/sites-enabled/domain2.com

6. Finally Edit Hosts file.
My tiny intranet does not use/need DNS. I will just manually update hosts files on few machines.
I added the following entries to /etc/hosts file on this (Ubuntu) machine (192.168.12.13).
127.0.1.1 domain1.com
127.0.1.1 www.domain1.com
127.0.1.1 domain2.com
127.0.1.1 www.domain2.com
I added similar entries to C:\Windows\System32\drivers\etc\hosts on my Windows Visita.
192.168.12.13 domain1.com
192.168.12.13 www.domain1.com
192.168.12.13 domain2.com
192.168.12.13 www.domain2.com
Type in "www.domain1.com" on my browser, and the result looks like below. However, it did not display correctly at first: it kept displaying the (Nginx) default index.html until I finally deleted the symlink file default from the /etc/nginx/sites-enabled/. Also I had a little problem displaying domain2.com page from the Windows machine at frist: it ketp displaying a page from the internet where there is a real domain called "domain2.com". But after repeating refreshing and stopping and starting IE, it started to display my domain2.com which actually resides on my Ubuntu.

Note that it is important to remove any entry from the hosts files if you need to access an internet site with the same domain name.

Installing members

I installed members, a program that displays all users who belong to a specified group.

1. Install.
Go to Synaptic. Search and install members.

2. Test.
Display all users who belong to group admin.
$ members admin
socrateos
$ 
Currently, I am the only member of admin.

Saturday, August 6, 2011

Installing Ramaze on Ubuntu (11.04)

I installed Ramaze (a lightweight web frame work. "RailsLite") on my Ubuntu 11.04.

1. Resources.
Ramaze Home: http://ramaze.net/
My Previous Installation on Ubuntu: http://socrateos.blogspot.com/2011/03/installing-ramaze.html

2. Install.
$ sudo gem install ramaze
[sudo] password for socrateos: 
Successfully installed innate-2011.04
Successfully installed ramaze-2011.07.25
2 gems installed
Installing ri documentation for innate-2011.04...
Installing ri documentation for ramaze-2011.07.25...
Installing RDoc documentation for innate-2011.04...
Installing RDoc documentation for ramaze-2011.07.25...
                   
$ ramaze -v    # be sure to have /var/lib/gems/1.9.1/bin in your PATH
2011.07.25

$ irb
irb(main):001:0> require 'ramaze'
=> true
irb(main):002:0> 

3. Create a Ramaze app.
$ cd work/ruby/ramaze
$ ramaze create myapp
The application has been generated and saved in myapp
$ cd myapp
$ ls
app.rb  config.ru  controller  layout  model  public  spec  start.rb  view
$ ramaze start
[2011-08-06 07:51:42] INFO  WEBrick 1.3.1
[2011-08-06 07:51:42] INFO  ruby 1.9.2 (2010-08-18) [i686-linux]
[2011-08-06 07:51:42] INFO  WEBrick::HTTPServer#start: pid=6063 port=7000

4. The Result (with Webrick) at http://localhost:7000.




















5. Run it with Unicorn instead of Webrick. (See Unicorn Installation)
$ cd work/ruby/ramaze/myapp
$ unicorn
I, [2011-08-06T11:33:11.738433 #1976]  INFO -- : listening on addr=0.0.0.0:8080 fd=3
I, [2011-08-06T11:33:11.738779 #1976]  INFO -- : worker=0 spawning...
I, [2011-08-06T11:33:11.739553 #1976]  INFO -- : master process ready
I, [2011-08-06T11:33:11.740215 #1978]  INFO -- : worker=0 spawned pid=1978
I, [2011-08-06T11:33:11.740420 #1978]  INFO -- : Refreshing Gem list
I, [2011-08-06T11:33:12.628489 #1978]  INFO -- : worker=0 ready

6. The Result (with Unicorn) at http://localhost:8080.
Great. It just works!

Friday, August 5, 2011

Installing Unicorn on Ubuntu (11.04)

Installed Unicorn.

1. Resources.
Unicorn: http://unicorn.bogomips.org/
Sleekd: http://sleekd.com/general/configuring-nginx-and-unicorn/

2. Install Unicorn
$ sudo gem install unicorn
Building native extensions.  This could take a while...
Building native extensions.  This could take a while...
Building native extensions.  This could take a while...
Successfully installed rack-1.3.2
Successfully installed kgio-2.6.0
Successfully installed raindrops-0.7.0
Successfully installed unicorn-4.0.1
4 gems installed
Installing ri documentation for rack-1.3.2...
Installing ri documentation for kgio-2.6.0...
Installing ri documentation for raindrops-0.7
.0...
Installing ri documentation for unicorn-4.0.1...
Installing RDoc documentation for rack-1.3.2...
Installing RDoc documentation for kgio-2.6.0...
Installing RDoc documentation for raindrops-0.7.0...
Installing RDoc documentation for unicorn-4.0.1...

3. Check Installation
$ irb
irb(main):001:0> require "unicorn"
=> true
irb(main):002:0>

4. Test Run a Rack App (Ramaze)
$ cd work/ruby/ramaze/myapp          # my ramaze app
$ unicorn
I, [2011-08-06T11:33:11.738433 #1976]  INFO -- : listening on addr=0.0.0.0:8080 fd=3
I, [2011-08-06T11:33:11.738779 #1976]  INFO -- : worker=0 spawning...
I, [2011-08-06T11:33:11.739553 #1976]  INFO -- : master process ready
I, [2011-08-06T11:33:11.740215 #1978]  INFO -- : worker=0 spawned pid=1978
I, [2011-08-06T11:33:11.740420 #1978]  INFO -- : Refreshing Gem list
I, [2011-08-06T11:33:12.628489 #1978]  INFO -- : worker=0 ready

5. The Result at http://localhost:8080.

Installing Nginx on Ubuntu (11.04)

I installed nginx on my Ubuntu (11.04), using Synaptic.

1. Resouces.
Nginx: http://wiki.nginx.org/
Sleekd: http://sleekd.com/general/configuring-nginx-and-unicorn/
Slicehost: http://articles.slicehost.com/nginx

2. Installation.
Search for nginx in Synaptic and install it.
It installs 3 packages, nginx, nginx-common, nginx-full.

3. Start the Nginx HTTP Server.
$ sudo /etc/init.d/nginx start      # start server
Starting nginx: nginx.
$ sudo /etc/init.d/nginx status     # check status
 * nginx is running

4. Test
http://localhost    # browser url
And the result is:













5. Check Installation

(1) Check the running processes.
$ ps aux | grep nginx
root      1253  0.0  0.0  10128   908 ?        Ss   19:43   0:00 nginx: master process /usr/sbin/nginx
www-data  1254  0.0  0.0  10280  1272 ?        S    19:43   0:00 nginx: worker process 
www-data  1255  0.0  0.0  10280  1272 ?        S    19:43   0:00 nginx: worker process
www-data  1257  0.0  0.0  10280  1272 ?        S    19:43   0:00 nginx: worker process
www-data  1258  0.0  0.0  10280  1272 ?        S    19:43   0:00 nginx: worker process
1001      2879  0.0  0.0   5128   856 pts/0    S+   21:52   0:00 grep --color=auto nginx
It looks like the installer created a new user www-data.

(2) Let's check this user.
$ finger www-data
Login: www-data          Name: www-data
Directory: /var/www      Shell: /bin/sh
Never logged in.
No mail.
No Plan.
It turned out that "the default web server user on Debian based systems is www-data" according to this site: slicehost. The installer also created a new group www-data, to which the user www-data belongs.
$ members www-data      # list all users who belong to group www-data.
www-data


(3) Get some more information about this installation with -V option.
$ nginx -V
nginx version: nginx/0.8.54
TLS SNI support enabled
configure arguments:
 --conf-path=/etc/nginx/nginx.conf                  # <==== Here is the path to nginx.conf.
 --error-log-path=/var/log/nginx/error.log
 --http-client-body-temp-path=/var/lib/nginx/body
 --http-fastcgi-temp-path=/var/lib/nginx/fastcgi
 --http-log-path=/var/log/nginx/access.log
 --http-proxy-temp-path=/var/lib/nginx/proxy
 --http-scgi-temp-path=/var/lib/nginx/scgi
 --http-uwsgi-temp-path=/var/lib/nginx/uwsgi
 --lock-path=/var/lock/nginx.lock
 --pid-path=/var/run/nginx.pid
 --with-debug
 --with-http_addition_module
 --with-http_dav_module
 --with-http_geoip_module
 --with-http_gzip_static_module
 --with-http_image_filter_module
 --with-http_realip_module
 --with-http_stub_status_module>
 --with-http_ssl_module
 --with-http_sub_module
 --with-http_xslt_module
 --with-ipv6
 --with-sha1=/usr/include/openssl
 --with-md5=/usr/include/openssl
 --with-mail
 --with-mail_ssl_module
 --add-module=/build/buildd/nginx-0.8.54/debian/modules/nginx-upstream-fair

6. Configuration Files.
Let's look at some configuration files.

(1) /etc/nginx/nginx.conf
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
 worker_connections 768;
 # multi_accept on;
}

http {

 ##
 # Basic Settings
 ##

 sendfile on;
 tcp_nopush on;
 tcp_nodelay on;
 keepalive_timeout 65;
 types_hash_max_size 2048;
 # server_tokens off;

 # server_names_hash_bucket_size 64;
 # server_name_in_redirect off;

 include /etc/nginx/mime.types;
 default_type application/octet-stream;

 ##
 # Logging Settings
 ##

 access_log /var/log/nginx/access.log;
 error_log /var/log/nginx/error.log;

 ##
 # Gzip Settings
 ##

 gzip on;
 gzip_disable "msie6";

 # gzip_vary on;
 # gzip_proxied any;
 # gzip_comp_level 6;
 # gzip_buffers 16 8k;
 # gzip_http_version 1.1;
 # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

 ##
 # Virtual Host Configs
 ##

 include /etc/nginx/conf.d/*.conf;
 include /etc/nginx/sites-enabled/*;
}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
# server {
#  listen     localhost:110;
#  protocol   pop3;
#  proxy      on;
# }
# 
# server {
#  listen     localhost:143;
#  protocol   imap;
#  proxy      on;
# }
#}

(2) /etc/nginx/sites-available/default

# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

server {
 #listen   80; ## listen for ipv4; this line is default and implied
 #listen   [::]:80 default ipv6only=on; ## listen for ipv6

 root /usr/share/nginx/www;
 index index.html index.htm;

 # Make site accessible from http://localhost/
 server_name localhost;

 location / {
  # First attempt to serve request as file, then
  # as directory, then fall back to index.html
  try_files $uri $uri/ /index.html;
 }

 location /doc {
  root /usr/share;
  autoindex on;
  allow 127.0.0.1;
  deny all;
 }

 location /images {
  root /usr/share;
  autoindex off;
 }

 #error_page 404 /404.html;

 # redirect server error pages to the static page /50x.html
 #
 #error_page 500 502 503 504 /50x.html;
 #location = /50x.html {
 # root /usr/share/nginx/www;
 #}

 # proxy the PHP scripts to Apache listening on 127.0.0.1:80
 #
 #location ~ \.php$ {
 # proxy_pass http://127.0.0.1;
 #}

 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 #
 #location ~ \.php$ {
 # fastcgi_pass 127.0.0.1:9000;
 # fastcgi_index index.php;
 # include fastcgi_params;
 #}

 # deny access to .htaccess files, if Apache's document root
 # concurs with nginx's one
 #
 #location ~ /\.ht {
 # deny all;
 #}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# root html;
# index index.html index.htm;
#
# location / {
#  try_files $uri $uri/ /index.html;
# }
#}


# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
#
# root html;
# index index.html index.htm;
#
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
#
# ssl_session_timeout 5m;
#
# ssl_protocols SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
# ssl_prefer_server_ciphers on;
#
# location / {
#  try_files $uri $uri/ /index.html;
# }
#}

OK, according to this conf file, the root directory for the default site is /usr/share/nginx/www.
And its home page file is index.html. Let's make some change.
$ cd /usr/share/nginx/www
$ ls
50x.html  index.html
$ sudo gedit index.html
I made a change to the welcome text from "Welcome to nginx!" to "Welcome to My Nginx!" with blue color.
And here is the result.