Project

General

Profile

Installing the Tapestry application » History » Version 31

Tom Clegg, 09/25/2012 10:47 AM

1 20 Tom Clegg
h1. Installing the Tapestry application
2 1 Tom Clegg
3 27 Ward Vandewege
The recommended ruby stack for Tapestry is Ruby Enterprise Edition (1.8.7), installed via rvm.
4
5 29 Tom Clegg
Install rvm and REE:
6 1 Tom Clegg
7 29 Tom Clegg
<pre>
8
sudo -i
9
# curl -L https://get.rvm.io | sudo bash -s stable
10
# exit
11
sudo -i
12
# rvm install ree
13
# exit
14
</pre>
15 1 Tom Clegg
16 29 Tom Clegg
Start a new login shell.  Make sure RVM is working and @ruby -v@ identifies itself as REE 1.8.7.
17 1 Tom Clegg
18 29 Tom Clegg
 rvm use ree
19
ruby -v
20 1 Tom Clegg
21 29 Tom Clegg
&rarr; *@ruby 1.8.7 (2012-02-08 MBARI 8/0x6770 on patchlevel 358) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2012.02@*
22
23 1 Tom Clegg
Install rails.
24
25 29 Tom Clegg
<pre>
26
sudo -i
27
# rvm use ree
28
# gem install rails
29
# gem install passenger
30
# passenger-install-apache2-module
31
</pre>
32 1 Tom Clegg
33 29 Tom Clegg
Add three lines (provided by passenger-install-apache2-module) and two more lines (see below) to @/etc/apache2/conf.d/passenger.conf@.
34 1 Tom Clegg
35 23 Tom Clegg
<pre>
36 29 Tom Clegg
LoadModule passenger_module /usr/local/rvm/gems/ree-1.8.7-2012.02/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
37
PassengerRoot /usr/local/rvm/gems/ree-1.8.7-2012.02/gems/passenger-3.0.17
38
PassengerRuby /usr/local/rvm/wrappers/ree-1.8.7-2012.02/ruby
39
40
PassengerUser YOUR_USERNAME_HERE
41 22 Tom Clegg
RackEnv "development"
42
</pre>
43
44 1 Tom Clegg
Install some prerequisites for gems.
45 28 Tom Clegg
46 1 Tom Clegg
 sudo apt-get install libxslt-dev libxml2-dev
47 28 Tom Clegg
48 1 Tom Clegg
Get a copy of the source tree -- e.g., in /var/www/tapestry
49 28 Tom Clegg
50
<pre>
51
cd /var/www
52
sudo chmod a+w,+t .
53
git clone git://git.clinicalfuture.com/tapestry.git
54
sudo chmod go-w,-t .
55
cd tapestry && git submodule init && git submodule update
56 12 Ward Vandewege
</pre>
57
58 3 Tom Clegg
Then execute:
59 2 Tom Clegg
60 29 Tom Clegg
 bundle install
61 1 Tom Clegg
62
Point a virtualhost to the @public@ dir in your git repo
63
64 21 Tom Clegg
<pre>
65 28 Tom Clegg
<VirtualHost *:80>
66
   ServerName tapestry.example.org
67 1 Tom Clegg
   DocumentRoot /var/www/tapestry/public
68
   <Directory /var/www/tapestry/public>
69
         AllowOverride all
70 26 Tom Clegg
         Options -MultiViews
71
   </Directory>
72
   Alias /warehouse /warehouse
73
   <Directory /warehouse>
74
         Options None
75
         AllowOverride None
76
         Order allow,deny
77 1 Tom Clegg
         allow from all
78
   </Directory>
79 4 Tom Clegg
</VirtualHost>
80 14 Tom Clegg
</pre>
81 1 Tom Clegg
82 14 Tom Clegg
Copy @config/database.example@ to @config/database.yml@ and edit to suit. Make sure to select mysql as the database server.  Generate a password using @pwgen 12 1@ or @head -c12345 /dev/urandom|md5sum|head -c12;echo@.  For example:
83
84
 development:
85 15 Tom Clegg
  adapter: mysql
86
  server: localhost
87 14 Tom Clegg
  database: mypg
88
  username: mypg
89
  password: c16fbe415d29
90 18 Madeleine Ball
  timeout: 5000
91 16 Tom Clegg
92 18 Madeleine Ball
Copy @config/environments/development.rb.sample@ to @config/environments/development.rb@ and edit to suit.  In particular the ROOT_URL (you may skip the "http://" prefix):
93 14 Tom Clegg
94
 ROOT_URL = 'your.vhost.name'
95 1 Tom Clegg
96 30 Tom Clegg
Generate a secret token with something like
97
98
* @ruby -e 'puts rand(2**256).to_s(36)'@
99
* @head -c1234567 /dev/urandom | sha256sum@
100
* @pwgen 64 1@
101
102
Put the secret token in @config/initializers/secret_token.rb@ like this
103
104 31 Tom Clegg
 Tapestry::Application.configure do
105 30 Tom Clegg
 config.secret_token = "40ih46sqyihsiupgwce5u2oirflnor3atgmvzaqeqng42dwa0o"
106 31 Tom Clegg
end
107 30 Tom Clegg
108 1 Tom Clegg
Set up the database:
109 19 Madeleine Ball
110 18 Madeleine Ball
 rake db:setup
111 1 Tom Clegg
rake db:schema:load
112 19 Madeleine Ball
113 18 Madeleine Ball
Set up data directory (replace USERNAME with the user who owns the GIT directory this code is in, and ROOT_URL matching the one above):
114 19 Madeleine Ball
115 1 Tom Clegg
 sudo mkdir -p /data/ROOT_URL
116 8 Tom Clegg
sudo chown -R USERNAME:USERNAME /data/ROOT_URL
117 10 Ward Vandewege
118
After you do a git pull, you'll probably want to do
119 12 Ward Vandewege
120
  rake db:migrate
121
122
to bring your database up to the latest release.
123 25 Tom Clegg
124 1 Tom Clegg
If the Gemfile has changed, you will also have to run
125
126 30 Tom Clegg
  bundle install
127 25 Tom Clegg
128
Set up cron jobs -- for example, @/etc/cron.d/tapestry-get-blog-feed@
129 28 Tom Clegg
130 26 Tom Clegg
 PATH=/usr/local/bin:/usr/bin:/bin
131
0 * * * * www-data cd /var/www/tapestry/current/script && ./get-blog-feed.rb development http://blog.personalgenomes.org/feed/
132
133
To enable large uploads with warehouse storage:
134
135
* @sudo apt-get install runit fuse-utils@
136
* @sudo mkdir -p /etc/service/whmount/log/main@
137
* Set up supervised whmount service:
138
139
<pre>
140
sudo tee /etc/service/whmount/run <<EOF >/dev/null
141
#!/bin/sh
142
modprobe fuse
143
mkdir -p /warehouse
144
chown www-data:www-data /warehouse
145
sudo -u www-data fusermount -u /warehouse
146
exec sudo -u www-data whmount --no-detach / /warehouse
147
EOF
148
sudo tee /etc/service/whmount/log/run <<EOF >/dev/null
149
#!/bin/sh
150
exec svlogd -tt main
151
EOF
152
</pre>
153
154
* Make sure config/environments/development.rb matches your Apache and filesystem mount points:
155
156
<pre>
157
  WAREHOUSE_WEB_ROOT = "/warehouse" # Apache alias pointing to whmount target
158 1 Tom Clegg
  WAREHOUSE_FS_ROOT = "/warehouse" # whmount target
159
</pre>