Project

General

Profile

Installing the Tapestry application » History » Version 32

Ward Vandewege, 03/03/2013 03:23 PM
add important apache config line for warehouse downloads

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 32 Ward Vandewege
         # This is important; downloads from /warehouse take a long time
75
         # and we do not want to tie up passenger processes with those.
76
         PassengerEnabled off
77 26 Tom Clegg
         Options None
78
         AllowOverride None
79
         Order allow,deny
80 1 Tom Clegg
         allow from all
81
   </Directory>
82 4 Tom Clegg
</VirtualHost>
83 14 Tom Clegg
</pre>
84 1 Tom Clegg
85 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:
86
87
 development:
88 15 Tom Clegg
  adapter: mysql
89
  server: localhost
90 14 Tom Clegg
  database: mypg
91
  username: mypg
92
  password: c16fbe415d29
93 18 Madeleine Ball
  timeout: 5000
94 16 Tom Clegg
95 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):
96 14 Tom Clegg
97
 ROOT_URL = 'your.vhost.name'
98 1 Tom Clegg
99 30 Tom Clegg
Generate a secret token with something like
100
101
* @ruby -e 'puts rand(2**256).to_s(36)'@
102
* @head -c1234567 /dev/urandom | sha256sum@
103
* @pwgen 64 1@
104
105
Put the secret token in @config/initializers/secret_token.rb@ like this
106
107 31 Tom Clegg
 Tapestry::Application.configure do
108 30 Tom Clegg
 config.secret_token = "40ih46sqyihsiupgwce5u2oirflnor3atgmvzaqeqng42dwa0o"
109 31 Tom Clegg
end
110 30 Tom Clegg
111 1 Tom Clegg
Set up the database:
112 19 Madeleine Ball
113 18 Madeleine Ball
 rake db:setup
114 1 Tom Clegg
rake db:schema:load
115 19 Madeleine Ball
116 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):
117 19 Madeleine Ball
118 1 Tom Clegg
 sudo mkdir -p /data/ROOT_URL
119 8 Tom Clegg
sudo chown -R USERNAME:USERNAME /data/ROOT_URL
120 10 Ward Vandewege
121
After you do a git pull, you'll probably want to do
122 12 Ward Vandewege
123
  rake db:migrate
124
125
to bring your database up to the latest release.
126 25 Tom Clegg
127 1 Tom Clegg
If the Gemfile has changed, you will also have to run
128
129 30 Tom Clegg
  bundle install
130 25 Tom Clegg
131
Set up cron jobs -- for example, @/etc/cron.d/tapestry-get-blog-feed@
132 28 Tom Clegg
133 26 Tom Clegg
 PATH=/usr/local/bin:/usr/bin:/bin
134
0 * * * * www-data cd /var/www/tapestry/current/script && ./get-blog-feed.rb development http://blog.personalgenomes.org/feed/
135
136
To enable large uploads with warehouse storage:
137
138
* @sudo apt-get install runit fuse-utils@
139
* @sudo mkdir -p /etc/service/whmount/log/main@
140
* Set up supervised whmount service:
141
142
<pre>
143
sudo tee /etc/service/whmount/run <<EOF >/dev/null
144
#!/bin/sh
145
modprobe fuse
146
mkdir -p /warehouse
147
chown www-data:www-data /warehouse
148
sudo -u www-data fusermount -u /warehouse
149
exec sudo -u www-data whmount --no-detach / /warehouse
150
EOF
151
sudo tee /etc/service/whmount/log/run <<EOF >/dev/null
152
#!/bin/sh
153
exec svlogd -tt main
154
EOF
155
</pre>
156
157
* Make sure config/environments/development.rb matches your Apache and filesystem mount points:
158
159
<pre>
160
  WAREHOUSE_WEB_ROOT = "/warehouse" # Apache alias pointing to whmount target
161 1 Tom Clegg
  WAREHOUSE_FS_ROOT = "/warehouse" # whmount target
162
</pre>