INSTALL 6.01 KB
= Noosfero installation instructions

Noosfero is written in Ruby with the "Rails framework":http://www.rubyonrails.org,
so the process of setting it up is pretty similar to other Rails applications.

Below we have the instructions for installing Noosfero dependencies and setting
up a production environment. If you have problems with the setup, please feel
free to ask questions in the development mailing list.

== Requirements

You need to install some packages Noosfero depends on.  On Debian GNU/Linux or
Debian-based systems, all of these packages are available through the Debian
archive. You can install them with the following command:

 # aptitude install ruby rake libgettext-ruby1.8 libsqlite3-ruby rcov librmagick-ruby libredcloth-ruby libwill-paginate-ruby iso-codes libfeedparser-ruby libferret-ruby libdaemons-ruby mongrel mongrel-cluster tango-icon-theme

On other systems, they may or may not be available through your regular package
management system. Below are the links to their homepages.

* Ruby: http://www.ruby-lang.org/
* Rake: http://rake.rubyforge.org/
* Ruby-GetText: http://www.yotabanana.com/hiki/ruby-gettext.html?ruby-gettext (at least version 1.9.0)
* Ruby-sqlite3: http://rubyforge.org/projects/sqlite-ruby
* rcov: http://eigenclass.org/hiki/rcov
* Ferret: http://ferret.davebalmain.com/trac
* RMagick: http://rmagick.rubyforge.org/
* RedCloth: http://redcloth.org/
* will_paginate: http://github.com/mislav/will_paginate/wikis
* iso-codes: http://pkg-isocodes.alioth.debian.org/
* feedparser: http://packages.debian.org/sid/libfeedparser-ruby
* Daemons - http://daemons.rubyforge.org/
* Mongrel: http://mongrel.rubyforge.org/
* tango-icon-theme: http://tango.freedesktop.org/Tango_Icon_Library

If you manage to install Noosfero successfully, please feel free to contact the
Noosfero development mailing with the instructions for doing so, and we'll
include it here.

=== Setting up a production environment

NOTE: these instructions are for seting up a *production* environment. If you
are going to do Noosfero development, you don't need to do these steps. See the
HACKING file instead.

* install memcached. Study whether you need to raise the ammount of memory it uses for caching, depending on the demand you expect for your site.
* enter the directory where you unpacked noosfero
* copy config/ferret_server.yml.dist to config/ferret_server.yml
* create the mongrel configuration file: `mongrel_rails cluster::configure`
** then edit config/mongrel_cluster.yml to suit your environment. Make sure your apache configuration matches the mongrel cluster configuration, specially in respect to the ports and numbers of mongrel instances.
* create needed temporary directories:
  mkdir tmp
  mkdir tmp/pids
  mkdir log
* create database (example using PostgreSQL, YMMV)

  root user
  =========
  # sudo apt-get install postgresql libpgsql-ruby
  # su - postgres

  postgres user
  =============
  postgres@HOST:~$ createuser noosfero
  Shall the new role be a superuser? (y/n) n
  Shall the new role be allowed to create databases? (y/n) y
  Shall the new role be allowed to create more new roles? (y/n) n

  noosfero_user
  =============
  createdb noosfero_production
  createdb noosfero_development
  createdb noosfero_test

* configure database access in config/database.yml

* test database access:
** first create the development database
   rake db:schema:load
** if everything goes right, then create the production database:
   RAILS_ENV=production rake db:schema:load

* create sample data:
  RAILS_ENV=production rake db:populate

* Add the domain name you will be using for your noosfero site to the list of
  environment domain, like this:

  ./script/runner "Environment.default.domains << Domain.new(:name => 'your.domain.com')"

  (of course, replace your.domain.com with your real domain)

* compile the translations:
  rake makemo

* start the server:
  ./script/production start

* to stop the server:

  ./script/production stop

* to restart the server:

  ./script/production restart

* enable the following apache modules:

  deflate
  expires
  proxy
  proxy_balancer
  proxy_http
  rewrite

  On Debian GNU/Linux system, these modules can be enabled with the following
  command line, as root:

  a2enmod deflate expires proxy proxy_balancer proxy_http rewrite

  In other systems the way by which you enable apache modules may be different.

* Configure apache web server as a reverse proxy. You can use the template
  below, replacing /path/to/noosfero with the directory in which your noosfero
  installation is, your.domain.com with the domain name of your noosfero site.
  We are assuming that you are running two mongrel instances on ports 4000 and
  4001. If your setup is different you'll need to adjust <Proxy> section. If
  you don't understand something in the configuration, please refer to the
  apache documentation.

  <VirtualHost *:80>
    ServerName your.domain.com

    DocumentRoot "/path/to/noosfero/public"
    <Directory "/path/to/noosfero/public">
      Options FollowSymLinks
      AllowOverride None
      Order Allow,Deny
      Allow from all
    </Directory>

    RewriteEngine On

    # Rewrite index to check for static index.html
    RewriteRule ^/$ /index.html [QSA]

    # Rewrite to check for Rails cached page
    RewriteRule ^([^.]+)$ $1.html [QSA]

    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule ^.*$ balancer://noosfero%{REQUEST_URI} [P,QSA,L]

    ErrorDocument 503 /503.html

    ErrorLog /var/log/apache2/noosfero.log
    LogLevel warn
    CustomLog /var/log/apache2/noosfero.access.log combined

    Include /path/to/noosfero/etc/noosfero/apache/cache.conf

  </VirtualHost>

  <Proxy balancer://noosfero>
    BalancerMember http://127.0.0.1:4000
    BalancerMember http://127.0.0.1:4001
    Order Allow,Deny
    Allow from All
  </Proxy>

  The cache.conf file included in the end of the <VirtualHost> section is
  important, since it will tell apache to pass expiration and cache headers to
  clients so that the site feels faster for users. Do we need to say that using
  that configuration is strongly recommended?