Difference between revisions of "User:Rfs/Installing wobble motions"

From FreekiWiki
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
Install necessary packages:
+
==Install necessary packages:==
  sudo apt-get install ruby rubygems postgresql-8.1 libpgsql-ruby
+
 
(Your version numbers may vary, depending upon your distro. Right now installing ruby pulls 1.8, though it seems 1.9 is also available. I went with 1.8.)
+
  sudo apt-get install ruby rubygems postgresql-8.1 libpgsql-ruby subversion rake
 +
 
 +
or
 +
 
 +
  apt-get install ruby rubygems postgresql-8.1 libpgsql-ruby subversion rake rails irb libapache2-mod-ruby
 +
 
 +
(Your version numbers may vary, depending upon your distro. I am assuming debian etch. Right now installing ruby pulls 1.8, though it seems 1.9 is also available. I went with 1.8.)
  
  
Line 16: Line 22:
 
  rfs@boq:~/wobble/motions/trunk$ cat config/database.yml
 
  rfs@boq:~/wobble/motions/trunk$ cat config/database.yml
  
 
+
==Database stuff==
 
Create a user for the database:
 
Create a user for the database:
 
  rfs@boq:~/wobble/motions/trunk$ sudo su - postgres
 
  rfs@boq:~/wobble/motions/trunk$ sudo su - postgres
Line 39: Line 45:
 
  template1=#  
 
  template1=#  
  
 +
Ensure that the user can correctly access the database:
 +
psql -U USERNAME_GOES_HERE -h localhost template1
 +
 +
Or make sure by fixing /etc/postgresql/YOUR_PSQL_VERSION/pg_hba.conf:
 +
man pg_hba.conf
  
 
Create the databases (empty for now):
 
Create the databases (empty for now):
Line 53: Line 64:
 
(If you have a dump of the database, you can use that to populate it with real or usable data.
 
(If you have a dump of the database, you can use that to populate it with real or usable data.
  
 +
==Server stuff==
 +
===development===
 +
You're likely using WEBrick during development:
  
 
Start the server:
 
Start the server:
Line 62: Line 76:
 
  [2007-10-08 10:19:56] INFO  ruby 1.8.5 (2006-08-25) [i486-linux]
 
  [2007-10-08 10:19:56] INFO  ruby 1.8.5 (2006-08-25) [i486-linux]
 
  [2007-10-08 10:19:56] INFO  WEBrick::HTTPServer#start: pid=7392 port=3000
 
  [2007-10-08 10:19:56] INFO  WEBrick::HTTPServer#start: pid=7392 port=3000
 
  
 
Using a browser, go to:
 
Using a browser, go to:
 
  http://localhost:3000
 
  http://localhost:3000
  
 +
Click on a link, which will take you to a log in page and log in.
 +
 +
===production under apache2===
 +
*move the motions directory somewhere under /var/www/ (as root)
 +
*from the new directory:
 +
**chgrp www-data -R tmp log
 +
**chmod g+w -R tmp log
 +
*copy a chunk of config into /etc/apache2/sites-available/default (or wherever) something like this:
  
Click on a link, which will take you to a log in page and log in.
+
    <Directory /var/www/motions/public>
 +
        Options ExecCGI FollowSymLinks
 +
        AddHandler cgi-script .cgi
 +
        AllowOverride all
 +
        Order allow,deny
 +
        Allow from all
 +
    </Directory>
  
 +
==Notes==
 
Note: One problem I had was my database.yml file was set to look at a custom port for postgresql. Check /etc/services to see where postgresql is listening:
 
Note: One problem I had was my database.yml file was set to look at a custom port for postgresql. Check /etc/services to see where postgresql is listening:
 
  rfs@boq:~/wobble/motions/trunk$ grep postgresql /etc/services  
 
  rfs@boq:~/wobble/motions/trunk$ grep postgresql /etc/services  

Latest revision as of 14:31, 16 July 2008

Install necessary packages:

sudo apt-get install ruby rubygems postgresql-8.1 libpgsql-ruby subversion rake

or

 apt-get install ruby rubygems postgresql-8.1 libpgsql-ruby subversion rake rails irb libapache2-mod-ruby

(Your version numbers may vary, depending upon your distro. I am assuming debian etch. Right now installing ruby pulls 1.8, though it seems 1.9 is also available. I went with 1.8.)


Trying to start the server, I got a message that said to do this as well:

sudo gem install -v=1.1.6 rails

(This required hitting ENTER a few times to accept the default answer -- Yes -- to install some dependencies.)


Get the application(s) from the svn server:

svn co svn+ssh://svn.freegeek.org/svn/wobble/motions/trunk motions/trunk


Check the configuration file for the username and password. (Edit these to suit yourself.)

rfs@boq:~/wobble/motions/trunk$ cat config/database.yml

Database stuff

Create a user for the database:

rfs@boq:~/wobble/motions/trunk$ sudo su - postgres
postgres@boq:~$ createuser USERNAME_GOES_HERE
Shall the new role be a superuser? (y/n) y
CREATE ROLE
postgres@boq:~$ 


Set the user's password:

rfs@boq:~/wobble/motions/trunk$ psql template1
Welcome to psql 8.2.5, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
      \h for help with SQL commands
      \? for help with psql commands
      \g or terminate with semicolon to execute query
      \q to quit

template1=# ALTER USER USERNAME_GOES_HERE password 'PUT_THE_PASSWORD_HERE';
ALTER ROLE
template1=# 

Ensure that the user can correctly access the database:

psql -U USERNAME_GOES_HERE -h localhost template1

Or make sure by fixing /etc/postgresql/YOUR_PSQL_VERSION/pg_hba.conf:

man pg_hba.conf

Create the databases (empty for now):

rfs@boq:~/wobble/motions/trunk$ createdb motions_test
CREATE DATABASE
rfs@boq:~/wobble/motions/trunk$ createdb motions_development
CREATE DATABASE
rfs@boq:~/wobble/motions/trunk$ createdb motions_production
CREATE DATABASE


Populate the database:

rfs@boq:~/wobble/motions/trunk$ rake db:migrate

(If you have a dump of the database, you can use that to populate it with real or usable data.

Server stuff

development

You're likely using WEBrick during development:

Start the server:

rfs@boq:~/wobble/motions/trunk$ ./script/server 
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-10-08 10:19:56] INFO  WEBrick 1.3.1
[2007-10-08 10:19:56] INFO  ruby 1.8.5 (2006-08-25) [i486-linux]
[2007-10-08 10:19:56] INFO  WEBrick::HTTPServer#start: pid=7392 port=3000

Using a browser, go to:

http://localhost:3000

Click on a link, which will take you to a log in page and log in.

production under apache2

  • move the motions directory somewhere under /var/www/ (as root)
  • from the new directory:
    • chgrp www-data -R tmp log
    • chmod g+w -R tmp log
  • copy a chunk of config into /etc/apache2/sites-available/default (or wherever) something like this:
   <Directory /var/www/motions/public>
       Options ExecCGI FollowSymLinks
       AddHandler cgi-script .cgi
       AllowOverride all
       Order allow,deny
       Allow from all
   </Directory>

Notes

Note: One problem I had was my database.yml file was set to look at a custom port for postgresql. Check /etc/services to see where postgresql is listening:

rfs@boq:~/wobble/motions/trunk$ grep postgresql /etc/services 
postgresql      5432/tcp        postgres        # PostgreSQL Database
postgresql      5432/udp        postgres

If postgresql is listening on the standard port (5432), you don't need the port: lines in database.yml. If it is listening on a non-standard port, then you need to specify which port that is in database.yml.