Installing the Tapestry application » History » Version 37
Tom Clegg, 08/12/2013 01:52 PM
1 | 20 | Tom Clegg | h1. Installing the Tapestry application |
---|---|---|---|
2 | 1 | Tom Clegg | |
3 | 33 | Tom Clegg | * ...or skip down to the [[Installing the Tapestry application#Updating|section about Updating]] |
4 | |||
5 | 27 | Ward Vandewege | The recommended ruby stack for Tapestry is Ruby Enterprise Edition (1.8.7), installed via rvm. |
6 | |||
7 | 29 | Tom Clegg | Install rvm and REE: |
8 | 1 | Tom Clegg | |
9 | 29 | Tom Clegg | <pre> |
10 | sudo -i |
||
11 | # curl -L https://get.rvm.io | sudo bash -s stable |
||
12 | # exit |
||
13 | sudo -i |
||
14 | # rvm install ree |
||
15 | # exit |
||
16 | </pre> |
||
17 | 1 | Tom Clegg | |
18 | 29 | Tom Clegg | Start a new login shell. Make sure RVM is working and @ruby -v@ identifies itself as REE 1.8.7. |
19 | 1 | Tom Clegg | |
20 | 29 | Tom Clegg | rvm use ree |
21 | ruby -v |
||
22 | 1 | Tom Clegg | |
23 | 29 | Tom Clegg | → *@ruby 1.8.7 (2012-02-08 MBARI 8/0x6770 on patchlevel 358) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2012.02@* |
24 | |||
25 | 1 | Tom Clegg | Install rails. |
26 | |||
27 | 29 | Tom Clegg | <pre> |
28 | sudo -i |
||
29 | # rvm use ree |
||
30 | # gem install rails |
||
31 | # gem install passenger |
||
32 | # passenger-install-apache2-module |
||
33 | </pre> |
||
34 | 1 | Tom Clegg | |
35 | 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@. |
36 | 1 | Tom Clegg | |
37 | 23 | Tom Clegg | <pre> |
38 | 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 |
39 | PassengerRoot /usr/local/rvm/gems/ree-1.8.7-2012.02/gems/passenger-3.0.17 |
||
40 | PassengerRuby /usr/local/rvm/wrappers/ree-1.8.7-2012.02/ruby |
||
41 | |||
42 | PassengerUser YOUR_USERNAME_HERE |
||
43 | 22 | Tom Clegg | RackEnv "development" |
44 | </pre> |
||
45 | |||
46 | 1 | Tom Clegg | Install some prerequisites for gems. |
47 | 28 | Tom Clegg | |
48 | 1 | Tom Clegg | sudo apt-get install libxslt-dev libxml2-dev |
49 | 28 | Tom Clegg | |
50 | 1 | Tom Clegg | Get a copy of the source tree -- e.g., in /var/www/tapestry |
51 | 28 | Tom Clegg | |
52 | <pre> |
||
53 | cd /var/www |
||
54 | sudo chmod a+w,+t . |
||
55 | git clone git://git.clinicalfuture.com/tapestry.git |
||
56 | sudo chmod go-w,-t . |
||
57 | cd tapestry && git submodule init && git submodule update |
||
58 | 12 | Ward Vandewege | </pre> |
59 | |||
60 | 3 | Tom Clegg | Then execute: |
61 | 2 | Tom Clegg | |
62 | 29 | Tom Clegg | bundle install |
63 | 1 | Tom Clegg | |
64 | Point a virtualhost to the @public@ dir in your git repo |
||
65 | |||
66 | 21 | Tom Clegg | <pre> |
67 | 28 | Tom Clegg | <VirtualHost *:80> |
68 | ServerName tapestry.example.org |
||
69 | 1 | Tom Clegg | DocumentRoot /var/www/tapestry/public |
70 | <Directory /var/www/tapestry/public> |
||
71 | AllowOverride all |
||
72 | 26 | Tom Clegg | Options -MultiViews |
73 | </Directory> |
||
74 | Alias /warehouse /warehouse |
||
75 | <Directory /warehouse> |
||
76 | 32 | Ward Vandewege | # This is important; downloads from /warehouse take a long time |
77 | # and we do not want to tie up passenger processes with those. |
||
78 | PassengerEnabled off |
||
79 | 26 | Tom Clegg | Options None |
80 | AllowOverride None |
||
81 | Order allow,deny |
||
82 | 1 | Tom Clegg | allow from all |
83 | </Directory> |
||
84 | 4 | Tom Clegg | </VirtualHost> |
85 | 14 | Tom Clegg | </pre> |
86 | 1 | Tom Clegg | |
87 | 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: |
88 | |||
89 | development: |
||
90 | 15 | Tom Clegg | adapter: mysql |
91 | server: localhost |
||
92 | 14 | Tom Clegg | database: mypg |
93 | username: mypg |
||
94 | password: c16fbe415d29 |
||
95 | 18 | Madeleine Ball | timeout: 5000 |
96 | 16 | Tom Clegg | |
97 | 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): |
98 | 14 | Tom Clegg | |
99 | ROOT_URL = 'your.vhost.name' |
||
100 | 1 | Tom Clegg | |
101 | 30 | Tom Clegg | Generate a secret token with something like |
102 | |||
103 | * @ruby -e 'puts rand(2**256).to_s(36)'@ |
||
104 | * @head -c1234567 /dev/urandom | sha256sum@ |
||
105 | * @pwgen 64 1@ |
||
106 | |||
107 | Put the secret token in @config/initializers/secret_token.rb@ like this |
||
108 | |||
109 | 31 | Tom Clegg | Tapestry::Application.configure do |
110 | 30 | Tom Clegg | config.secret_token = "40ih46sqyihsiupgwce5u2oirflnor3atgmvzaqeqng42dwa0o" |
111 | 31 | Tom Clegg | end |
112 | 30 | Tom Clegg | |
113 | 1 | Tom Clegg | Set up the database: |
114 | 19 | Madeleine Ball | |
115 | 18 | Madeleine Ball | rake db:setup |
116 | 1 | Tom Clegg | rake db:schema:load |
117 | 19 | Madeleine Ball | |
118 | 33 | Tom Clegg | Seed the database with a default set of enrollment steps: |
119 | |||
120 | rake db:seed_enrollment_steps |
||
121 | |||
122 | 25 | Tom Clegg | 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): |
123 | 1 | Tom Clegg | |
124 | sudo mkdir -p /data/ROOT_URL |
||
125 | 30 | Tom Clegg | sudo chown -R USERNAME:USERNAME /data/ROOT_URL |
126 | 25 | Tom Clegg | |
127 | 35 | Ward Vandewege | Set up cron jobs -- |
128 | |||
129 | 1. populate NextHex table regularly (daily is probably ok): |
||
130 | |||
131 | PATH=/usr/local/bin:/usr/bin:/bin |
||
132 | 38 0 * * * root (cd /var/www/tapestry/current/script; ./populate_next_hex.rb production 2>/dev/null) |
||
133 | |||
134 | 2. Optionally: @/etc/cron.d/tapestry-get-blog-feed@ |
||
135 | 28 | Tom Clegg | |
136 | 26 | Tom Clegg | PATH=/usr/local/bin:/usr/bin:/bin |
137 | 0 * * * * www-data cd /var/www/tapestry/current/script && ./get-blog-feed.rb development http://blog.personalgenomes.org/feed/ |
||
138 | |||
139 | To enable large uploads with warehouse storage: |
||
140 | |||
141 | * @sudo apt-get install runit fuse-utils@ |
||
142 | * @sudo mkdir -p /etc/service/whmount/log/main@ |
||
143 | 37 | Tom Clegg | * @sudo usermod -a -G fuse www-data@ |
144 | 26 | Tom Clegg | * Set up supervised whmount service: |
145 | |||
146 | <pre> |
||
147 | sudo tee /etc/service/whmount/run <<EOF >/dev/null |
||
148 | #!/bin/sh |
||
149 | modprobe fuse |
||
150 | mkdir -p /warehouse |
||
151 | chown www-data:www-data /warehouse |
||
152 | sudo -u www-data fusermount -u /warehouse |
||
153 | 34 | Tom Clegg | exec sudo -u www-data whmount --no-detach --threaded / /warehouse |
154 | 26 | Tom Clegg | EOF |
155 | 36 | Tom Clegg | sudo chmod +t /etc/service/whmount |
156 | sudo chmod +x /etc/service/whmount/run |
||
157 | |||
158 | 26 | Tom Clegg | sudo tee /etc/service/whmount/log/run <<EOF >/dev/null |
159 | #!/bin/sh |
||
160 | 1 | Tom Clegg | exec svlogd -tt main |
161 | EOF |
||
162 | 36 | Tom Clegg | sudo chmod +x /etc/service/whmount/log/run |
163 | 1 | Tom Clegg | </pre> |
164 | |||
165 | * Make sure config/environments/development.rb matches your Apache and filesystem mount points: |
||
166 | |||
167 | <pre> |
||
168 | WAREHOUSE_WEB_ROOT = "/warehouse" # Apache alias pointing to whmount target |
||
169 | WAREHOUSE_FS_ROOT = "/warehouse" # whmount target |
||
170 | </pre> |
||
171 | 33 | Tom Clegg | |
172 | h1. Updating |
||
173 | |||
174 | Pull the latest source tree. |
||
175 | |||
176 | git pull |
||
177 | |||
178 | Install/update gem package dependencies. |
||
179 | |||
180 | bundle install |
||
181 | |||
182 | Bring your database up to the latest release. |
||
183 | |||
184 | rake db:migrate |
||
185 | |||
186 | Tell passenger to reload everything. |
||
187 | |||
188 | mkdir -p tmp |
||
189 | touch tmp/restart.txt |