Installing the Tapestry application » History » Version 40
Ward Vandewege, 03/02/2014 09:27 AM
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 | 39 | Ward Vandewege | Copy @config/environments/development.rb.example@ to @config/environments/development.rb@ and edit it. You will probably want to update the ActionMailer::Base.smtp_settings section. |
98 | 14 | Tom Clegg | |
99 | 39 | Ward Vandewege | Create a new file @config/config.yml and add a 'development' section to override a few of the defaults configured in @config/config.defaults.yml. You should override these values to get started: |
100 | 1 | Tom Clegg | |
101 | 40 | Ward Vandewege | <pre> |
102 | 39 | Ward Vandewege | root_url |
103 | root_url_scheme |
||
104 | 40 | Ward Vandewege | </pre> |
105 | 39 | Ward Vandewege | |
106 | For a test/development setup, your @config/config.yml file could look like this: |
||
107 | |||
108 | <pre> |
||
109 | development: |
||
110 | root_url: 'hostname.of.your.machine' |
||
111 | root_url_scheme: 'http://' |
||
112 | </pre> |
||
113 | |||
114 | For a production setup, you are going to want to override most other variables defined in @config/config.defaults.yml. |
||
115 | |||
116 | 30 | Tom Clegg | Generate a secret token with something like |
117 | |||
118 | * @ruby -e 'puts rand(2**256).to_s(36)'@ |
||
119 | * @head -c1234567 /dev/urandom | sha256sum@ |
||
120 | * @pwgen 64 1@ |
||
121 | |||
122 | Put the secret token in @config/initializers/secret_token.rb@ like this |
||
123 | |||
124 | 31 | Tom Clegg | Tapestry::Application.configure do |
125 | 30 | Tom Clegg | config.secret_token = "40ih46sqyihsiupgwce5u2oirflnor3atgmvzaqeqng42dwa0o" |
126 | 31 | Tom Clegg | end |
127 | 30 | Tom Clegg | |
128 | 1 | Tom Clegg | Set up the database: |
129 | 19 | Madeleine Ball | |
130 | 18 | Madeleine Ball | rake db:setup |
131 | 1 | Tom Clegg | rake db:schema:load |
132 | 19 | Madeleine Ball | |
133 | 33 | Tom Clegg | Seed the database with a default set of enrollment steps: |
134 | |||
135 | rake db:seed_enrollment_steps |
||
136 | |||
137 | 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): |
138 | 1 | Tom Clegg | |
139 | sudo mkdir -p /data/ROOT_URL |
||
140 | 30 | Tom Clegg | sudo chown -R USERNAME:USERNAME /data/ROOT_URL |
141 | 25 | Tom Clegg | |
142 | 35 | Ward Vandewege | Set up cron jobs -- |
143 | |||
144 | 1. populate NextHex table regularly (daily is probably ok): |
||
145 | |||
146 | PATH=/usr/local/bin:/usr/bin:/bin |
||
147 | 38 0 * * * root (cd /var/www/tapestry/current/script; ./populate_next_hex.rb production 2>/dev/null) |
||
148 | |||
149 | 2. Optionally: @/etc/cron.d/tapestry-get-blog-feed@ |
||
150 | 28 | Tom Clegg | |
151 | 26 | Tom Clegg | PATH=/usr/local/bin:/usr/bin:/bin |
152 | 0 * * * * www-data cd /var/www/tapestry/current/script && ./get-blog-feed.rb development http://blog.personalgenomes.org/feed/ |
||
153 | |||
154 | To enable large uploads with warehouse storage: |
||
155 | |||
156 | * @sudo apt-get install runit fuse-utils@ |
||
157 | * @sudo mkdir -p /etc/service/whmount/log/main@ |
||
158 | 37 | Tom Clegg | * @sudo usermod -a -G fuse www-data@ |
159 | 26 | Tom Clegg | * Set up supervised whmount service: |
160 | |||
161 | <pre> |
||
162 | sudo tee /etc/service/whmount/run <<EOF >/dev/null |
||
163 | #!/bin/sh |
||
164 | modprobe fuse |
||
165 | mkdir -p /warehouse |
||
166 | chown www-data:www-data /warehouse |
||
167 | 36 | Tom Clegg | sudo -u www-data fusermount -u /warehouse |
168 | exec sudo -u www-data whmount --no-detach --threaded / /warehouse 2>&1 |
||
169 | EOF |
||
170 | 26 | Tom Clegg | sudo chmod +t /etc/service/whmount |
171 | sudo chmod +x /etc/service/whmount/run |
||
172 | 1 | Tom Clegg | |
173 | sudo tee /etc/service/whmount/log/run <<EOF >/dev/null |
||
174 | 36 | Tom Clegg | #!/bin/sh |
175 | 1 | Tom Clegg | exec svlogd -tt main |
176 | EOF |
||
177 | sudo chmod +x /etc/service/whmount/log/run |
||
178 | </pre> |
||
179 | |||
180 | 39 | Ward Vandewege | * Make sure config/config.yml matches your Apache and filesystem mount points: |
181 | 1 | Tom Clegg | |
182 | <pre> |
||
183 | 39 | Ward Vandewege | warehouse_web_root: "/warehouse" # Apache alias pointing to whmount target |
184 | warehouse_fs_root: "/warehouse" # whmount target |
||
185 | 1 | Tom Clegg | </pre> |
186 | 33 | Tom Clegg | |
187 | h1. Updating |
||
188 | |||
189 | Pull the latest source tree. |
||
190 | |||
191 | git pull |
||
192 | |||
193 | Install/update gem package dependencies. |
||
194 | |||
195 | bundle install |
||
196 | |||
197 | Bring your database up to the latest release. |
||
198 | |||
199 | rake db:migrate |
||
200 | |||
201 | Tell passenger to reload everything. |
||
202 | |||
203 | mkdir -p tmp |
||
204 | touch tmp/restart.txt |