-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathREADME_DEVELOPMENT_INSTALL
337 lines (309 loc) · 11.4 KB
/
README_DEVELOPMENT_INSTALL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#
# This is a log of the installation of a development server 20 May 2012.
# I used a fresh "nano" virtual machine at 6sync.com with 256MB ram.
#
# Started: 14:30
# Ended: 14:58
#
# ubuntu 11.10 (64bit)
# ruby 1.9.3-p194
# rubygems 1.8.24
# rails 2.1.1
# apache2 2.2.20
# mysql 5.1.62
# passenger 3.0.12
#
################################################################################
# Initial set up.
local> ssh root@80.77.87.179
# (asks for intial root password)
root> passwd
# (asks for new root password twice)
root> apt-get update
root> apt-get upgrade
root> apt-get install tcsh mlocate man vim lynx telnet emacs wget \
build-essential bison libyaml-dev libxslt-dev
# Create account for yourself. ("-G sudo" gives you ability to run any command via "sudo" command)
root> useradd -m -G sudo -s /bin/tcsh jason
root> passwd jason
# (asks for your password)
root> logout
# Password-less ssh.
local> ssh-keygen -t rsa # (if not already done)
local> ssh-copy-id -i ~/.ssh/id_rsa.pub 80.77.87.179
# (asks for your password again)
# Set up your user account however you like.
local> ssh 80.77.87.179
jason> vi .tcshrc
alias root sudo
alias cls clear
alias cd.. cd ..
alias dirf ls -alF
alias dirt ls -alFrt
alias md mkdir
alias rd rmdir
alias del rm
alias mv mv -i
alias cp cp -i
alias grep grep -s
alias +x chmod a+x
alias -x chmod a-x
jason> vi .vimrc
syntax off
set nohlsearch
set ts=2
set sw=2
set et
set nowrap
jason> vi .login
setenv TZ 'Eastern Time (US & Canada)'
setenv RAILS_ENV development
setenv RAKE_TEST_LOADER /usr/local/lib/ruby/1.9.3/rake/rake_test_loader.rb
jason> source .login
jason> source .tcshrc
# Install most of the modules that we will need (except ruby).
jason> sudo apt-get install apache2 libapache2-mod-passenger \
mysql-server mysql-client libmysqlclient-dev \
subversion subversion-tools \
libcurl4-openssl-dev libssl-dev libopenssl-ruby \
apache2-prefork-dev libapr1-dev libaprutil1-dev
# (asks for root password for mysql)
# Build and install ruby from source to get good version.
jason> mkdir build
jason> cd build
jason> wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.bz2
jason> tar -xjf ruby*.bz2
jason> cd ruby-1.9.3-p194
jason> ./configure --with-ruby-version=1.9.3
jason> sudo make install
jason> rehash
jason> cd
# Ditto for rubygems.
jason> cd ~/build
jason> wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz
jason> tar -xzf rubygems*.tgz
jason> cd rubygems-1.8.24
jason> sudo ruby setup.rb --prefix=/usr/local --verbose
jason> rehash
jason> cd
# Now we can install ruby gems properly.
jason> sudo gem install rails --verbose --no-rdoc --no-ri
jason> sudo gem install mysql --verbose --no-rdoc --no-ri
jason> sudo gem install trilogy --verbose --no-rdoc --no-ri
jason> sudo gem install test-unit --verbose --no-rdoc --no-ri
jason> sudo gem install RedCloth --verbose --no-rdoc --no-ri
jason> sudo gem install sparql --verbose --no-rdoc --no-ri
# (mysql-2.8.1) <-- needed by rake test:db:prepare, see script/run_tests
# (test-unit-2.4.8)
# (RedCloth-4.2.9)
# sparql installs all of these:
# addressable-2.2.8
# rdf-0.3.5.2
# builder-3.0.0
# sxp-0.0.14
# json_pure-1.7.3
# net-http-persistent-2.7
# sparql-client-0.1.1.1
# nokogiri-1.5.4
# backports-2.6.1
# rdf-xsd-0.3.7
# sparql-0.3.0
# Install passenger.
jason> sudo gem install passenger --verbose --no-rdoc --no-ri
# (fastthread-1.0.7)
# (daemon_controller-1.0.0)
# (rack-1.4.1)
# (passenger-3.0.12)
jason> rehash
jason> sudo passenger-install-apache2-module
# Pay attention to output at end and make sure values below are right.
jason> sudo vi /etc/apache2/mods-available/passenger.conf
# Change root to /usr/local/lib/ruby/gems/1.9.3/gems/passenger-3.0.12
# Change ruby to /usr/local/bin/ruby
jason> sudo vi /etc/apache2/mods-available/passenger.load
# Change to /usr/local/lib/ruby/gems/1.9.3/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
jason> sudo service apache2 stop
jason> sudo service apache2 start
# (For some reason reload and restart don't always work here.)
# Install ImageMagick. (might only need imagemagick, not the other dev pkgs or rmagick)
jason> sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev libjpeg-dev libjpeg-progs
jason> sudo gem install rmagick --verbose --no-rdoc --no-ri
# (rmagick-2.13.1)
# Install MO rails app.
jason> mkdir mo
jason> cd mo
jason> git clone https://github.com/MushroomObserver/mushroom-observer.git
jason> mkdir log public/images/{thumb,320,640,960,1280,orig}
jason> touch tmp/restart.txt
jason> vi config/consts-site.rb
unless TESTING
DOMAIN = 'localhost.localdomain'
IMAGE_DOMAIN = 'http://images.digitalmycology.com'
end
# Install our programs for resizing and rotating JPEG images.
jason> sudo gcc script/jpegresize.c -ljpeg -lm -O2 -o /usr/local/bin/jpegresize
jason> sudo gcc script/jpegexiforient.c -o /usr/local/bin/jpegexiforient
jason> sudo cp script/exifautotran.sh /usr/local/bin/exifautotran
jason> sudo chmod 755 /usr/local/bin/exifautotran
# Configure apache.
jason> sudo vi /etc/apache2/sites-available/mo
<VirtualHost *:80>
ServerName 80.77.87.179
DocumentRoot /home/jason/mo/public
RailsEnv development
SetEnv TZ 'Eastern Time (US & Canada)'
# This was necessary for my local installation on Fedora Core 13.
# RailsBaseURI /
<Directory /home/jason/mo/public>
Options FollowSymLinks
AllowOverride limit
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
# Redirect all image requests to the image server.
RewriteRule ^/images/thumb/(.*)$ http://images.digitalmycology.com/thumb/$1 [QSA]
RewriteRule ^/images/320/(.*)$ http://images.digitalmycology.com/320/$1 [QSA]
RewriteRule ^/images/640/(.*)$ http://images.digitalmycology.com/640/$1 [QSA]
RewriteRule ^/images/960/(.*)$ http://images.digitalmycology.com/960/$1 [QSA]
RewriteRule ^/images/1280/(.*)$ http://images.digitalmycology.com/1280/$1 [QSA]
RewriteRule ^/images/orig/(.*)$ http://images.digitalmycology.com/orig/$1 [QSA]
</VirtualHost>
jason> sudo a2dissite default
jason> sudo a2ensite mo
jason> sudo a2enmod rewrite
jason> sudo a2enmod headers
jason> sudo service apache2 reload
# Create database.
jason> mysql -u root -p
CREATE DATABASE mo_development;
CREATE DATABASE mo_test;
CREATE DATABASE cache_development;
CREATE USER 'mo'@'localhost' IDENTIFIED BY 'xxx';
# Command used to reset password if needed later:
# SET PASSWORD FOR 'mo'@'localhost' = PASSWORD('xxx');
GRANT ALL PRIVILEGES ON mo_development.* TO 'mo'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON mo_test.* TO 'mo'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON cache_development.* TO 'mo'@'localhost' WITH GRANT OPTION;
mo> cp config/database.yml-template config/database.yml
mo> vi config/database.yml
shared:
adapter: mysql2
# Default (works for MacOS X)
# socket: /tmp/mysql.sock
# For Ubuntu/Debian
socket: /var/run/mysqld/mysqld.sock
# For Fedora
# socket: /var/lib/mysql/mysql.sock
# Connect on a TCP socket. If omitted, the adapter will connect on the
# domain socket given by socket instead.
#host: localhost
#port: 3306
# For mysql >= 5.7.5
# Do not require SELECT list to include ORDER BY columns in DISTINCT queries,
# And do not not require ORDER BY to include the DISTINCT column.
variables:
sql_mode: TRADITIONAL
development:
primary:
database: mo_development
username: mo
password: mo
cache:
database: cache_development
username: mo
password: mo
host: localhost
migrations_paths: "db/cache/migrate"
test:
database: mo_test
username: mo
password: mo
mo> cd db
mo> scp jason@mushroomobserver.org:/var/web/mushroom-observer/db/checkpoint.gz .
mo> gunzip checkpoint.gz
mo> mysql -u mo -pxxx mo_development -e "source checkpoint"
mo> cd ..
# Test it using webrick:
mo> script/server
mo> lynx http://localhost:3000
# Test it using passenger:
# Point external browser at http://80.77.87.179
# Run unit tests:
mo> script/run_tests
# NOTE: language files have become problematic sometimes. Usually it manifests
# as obscure character encoding errors in app/model/language_exporter.pm. Some
# or all of the following steps might help clean up the problem.
mo> rm config/locales/*.{yml,txt}
mo> git checkout config/locales/en.txt
mo> rake lang # <--- this in particular helped Han on 20120913
mo> rake lang:update
# NOTE: 2024/02/09 The `create database` section above contains the steps to
# create and use the new solid_cache db. If your development install is already
# running however, do the following to set it up:
#
# 1. Check out <main> to get the `solid_cache` gem, new configs and migrations
# 2. Run `bundle`
# 3. You have to manually change your `config/database.yml`, since that file is
# not checked in to git. The relevant change regards _nesting_ db configs:
#
# development:
# primary:
# database: mo_development
# username: mo
# password: mo
# cache:
# database: cache_development
# username: mo
# password: mo
# host: 127.0.0.1
# migrations_paths: "db/cache/migrate"
#
# Your main db config should now be nested under `primary`, and the cache db
# config under `cache`. Both can use the same mysql user/pw, there are no
# further config changes necessary.
#
# 4. `sudo mysql`, create the new db and grant user 'mo' privileges in the new
# cache db. With a default setup, you should be able to sudo into mysql using
# your current user password - on a Mac, your user password - or get in with
# `mysql -u root` and no password.
#
# $: sudo mysql (or mysql -u root)
#
# Joe had trouble here. If you have ever set up a different password for
# mysql `root`, the first order of business is reestablishing access to
# myql as `root`. You will either have to find it or figure out how to
# reset that password. It's something like:
#
# $: brew services stop mysql
# $: sudo mysqld_safe --skip-grant-tables --skip-networking
# mysql -u root
# mysql> USE mysql;
# mysql> flush privileges;
# mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEWPASSWORD';
# mysql> flush privileges;
# mysql> quit;
# $: brew services restart mysql
# $: mysql -u root -p # now enter your root password
#
# Then, you should be in a mysql console:
#
# mysql> create database cache_development;
# mysql> show databases; # to check that it's there
# mysql> grant all privileges on cache_development.* to 'mo'@'localhost' with grant option;
# mysql> flush privileges;
# mysql> quit;
#
# 5. Run `rails db:create` locally. Don’t worry, this will NOT re-create any
# existing databases, only add the new `cache_development` db, using the
# new cache migrations that are on the main branch under `db/cache/migrate`.
# 6. Run `rails db:migrate`, to set up the tables in the cache db properly
# 7. run `rails s` and observe the log when loading the home page of the site.
# You should find log messages saying `solid_cache` is writing to the cache
# db and reading from it.
#
# References:
# https://github.com/rails/solid_cache?tab=readme-ov-file#using-a-dedicated-cache-database
# https://aungzanbaw.medium.com/how-to-reset-root-user-password-in-mysql-8-0-a5c328d098a8
# https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
#