forked from SynthSys/seek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINSTALL-PRODUCTION
172 lines (101 loc) · 6 KB
/
INSTALL-PRODUCTION
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
= Installing SEEK in a production environment
This page contains some extra notes about setting up SEEK for production (i.e. for real use rather than for development).
By reading and following these extra notes, you will more performance out of SEEK, and reduce the ongoing maintenance.
If you wish to run under a sub URI (e.g. <host>/seek) then please read and follow {Installing under a sub URI}[link:doc/INSTALL-ON-A-SUBURI.html] at the end
of the installation.
== Before you install SEEK
This will make sure some of the rake tasks affect the appropriate database.
To save time later there are also some additional packages to install:
sudo apt-get install apache2-mpm-prefork apache2-prefork-dev libapr1-dev libaprutil1-dev libcurl4-openssl-dev
You will need to install SEEK as the www-data user. First, to make the installation simpler, give this user a dedicated home directory:
sudo /etc/init.d/apache2 stop
sudo usermod -d /home/www-data www-data
sudo usermod -s /bin/bash www-data
sudo mkdir /home/www-data
sudo chown www-data /home/www-data
sudo /etc/init.d/apache2 start
We recommend installing SEEK in /srv/rails/seek - first you need to create this and grant permissions to www-data
sudo mkdir -p /srv/rails
sudo chown www-data /srv/rails
Now switch to the www-data user
sudo su - www-data
cd /srv/rails
Before following the standard INSTALL guide you need to set an environment variable to indicate that you intend to setup and run SEEK as production.
export RAILS_ENV=production
you will need to reset this variable if you close your shell and start a new session
You can now follow the overall {Installation Guide}[link:doc/INSTALL.html], and then return to this page for some additional steps to get SEEK running together with Apache,
and also automating the required services.
If you have problems with requiring a sudo password during the RVM steps - first setup RVM and ruby-1.9.3 as a user with sudo access, and repeat the steps as the www-data user. This means the required
packages should then be installed. At the time of writing this guide this shouldn't be necessary.
== After you have installed SEEK
== Compiling Assets
Assets - such as images, javascript and stylesheets, need to be precompiled - which means minifying them, grouping some together into a single file, and compressing. These then
get placed into <em>public/assets</em>. To compile them run the following command. This can take some time, so be patient
bundle exec rake assets:precompile
=== Serving SEEK through Apache
First you need to setup {Passenger Phusion}[https://www.phusionpassenger.com/] .Still as the www-data user, run the command:
bundle exec passenger-install-apache2-module
This will compile a module for Apache, and at the end present you with some lines that need adding to /etc/apache2/http.conf.
These will look something like the following, but the paths will most likely be different:
LoadModule passenger_module /home/www-data/.rvm/gems/ruby-1.9.3-p448@seek/gems/passenger-4.0.7/buildout/apache2/mod_passenger.so
PassengerRoot /home/www-data/.rvm/gems/ruby-1.9.3-p448@seek/gems/passenger-4.0.7
PassengerDefaultRuby /home/www-data/.rvm/wrappers/ruby-1.9.3-p448@seek/ruby
You will need to be a user that has sudo permissions, and edit this file:
sudo nano /etc/apache2/http.conf
Now create a virtual host definition for SEEK:
sudo nano /etc/apache2/sites-available/seek
which looks like (if you have registered a DNS for your site, then set ServerName appropriately):
<VirtualHost *:80>
ServerName www.yourhost.com
DocumentRoot /srv/rails/seek/public
<Directory /srv/rails/seek/public>
# This relaxes Apache security settings.
Allow from all
# MultiViews must be turned off.
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</Directory>
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</LocationMatch>
</VirtualHost>
The LocationMatch block tells Apache to serve up the assets (images, CSS, Javascript) with a long expiry time, leading to better performance since these
items will be cached. You may need to enable the <em>headers</em> and <em>expires</em> modules for Apache, so run:
sudo a2enmod headers
sudo a2enmod expires
Now enable the SEEK site, and disable the default that is installed with Apache, and restart:
sudo a2ensite seek
sudo a2dissite default
sudo service apache2 restart
If you now visit http://localhost (note there is no 3000 port) - you should see SEEK.
If you get a 403 forbidden error, and are running a version of Apache > 2.4, then you need to uncomment the <em>Require all granted</em> in the Directory definition.
If you wish to restart SEEK, maybe after an upgrade, without restarting Apache you can do so by running (as www-data)
touch /srv/rails/seek/tmp/restart.txt
=== Setting up the services
The following steps show how to setup sunspot:solr search, delayed_job and soffice to run as a service, and automatically start and shutdown when you restart the server.
==== Search Service
Create the file /etc/init.d/solr-seek and copy the contents of https://gist.github.com/3143434 into it.
Then run
sudo chmod +x /etc/init.d/solr-seek
sudo update-rc.d solr-seek defaults
start it up with:
sudo /etc/init.d/solr-seek start
==== Delayed Job Background Service
Create the file /etc/init.d/delayed_job-seek and copy the contents of https://gist.github.com/e4219ec7cb161129f1c7 into it.
The run:
sudo chmod +x /etc/init.d/delayed_job-seek
sudo update-rc.d delayed_job-seek defaults
start it up with:
sudo /etc/init.d/delayed_job-seek start
=== The LibreOffice Soffice service
Create the file /etc/init.d/soffice and copy the contents of https://gist.github.com/3787679 into it.
The run:
sudo chmod +x /etc/init.d/soffice
sudo update-rc.d soffice defaults
start it up with:
sudo /etc/init.d/soffice start