a7c187ace8e20f72b5fb6a33b8340c72927ab57f
[kohadocs.git] / en / source / 16_sopac.rst
1 .. include:: images.rst
2
3 SOPAC2 Installation
4 ===================
5
6 `Introduction <#sopacintro>`__
7 ------------------------------
8
9 This is an installation guide for SOPAC2 and its Koha connector. It has
10 been tested on Debian Lenny and Ubuntu Jaunty with Drupal 6.12 and Koha
11 3.0.x. It does not cover the installation of Koha and Drupal, only
12 SOPAC, its dependencies and the connector.
13
14 `Installation of Locum and Insurge <#sopacinstall>`__
15 -----------------------------------------------------
16
17 Locum and Insurge are the two libraries used primarily by SOPAC. They
18 serve as a layer of abstraction to the data. Insurge manages the social
19 aspect (tags, reviews, ratings), while Locum manages the connection to
20 the ILS via the connector. Both libraries use a different database from
21 that of Drupal.
22
23 `Dependencies <#sopacdepend>`__
24 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25
26 There are no packages for Debian MDB2 yet, you can install it via pear:
27
28 ::
29
30     # apt-get install php-pear
31     # pear install MDB2
32     # pear install MDB2#mysql
33
34 `Download <#sopacdownload>`__
35 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36
37 Download the Locum and Insurge libraries from SVN:
38
39 ::
40
41     # cd /usr/local/lib
42     # svn co http://dobby.darienlibrary.org/svn/locum/trunk/ locum
43     # svn co http://dobby.darienlibrary.org/svn/insurge/trunk/ insurge
44
45 `Creation of the Database <#sopaccreatedb>`__
46 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47
48 ::
49
50     $ mysql -u root
51     mysql> create database scas;
52     mysql> grant all privileges on scas.* to scas_user@'localhost' identified by 'scas_pass';
53     mysql> flush privileges;
54     mysql> exit
55
56 `Sync DSN <#sopacdsn>`__
57 ~~~~~~~~~~~~~~~~~~~~~~~~
58
59 This file will provide the connection information to a DB libraries:
60
61 ::
62
63     # nano /usr/local/etc/locum_insurge_dsn.php
64
65 It should contain:
66
67 ::
68
69     <?php
70     $dsn = 'mysql://scas_user:scas_pass@localhost/scas';
71
72 `Installation of Insurge <#sopacinstallinsurge>`__
73 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74
75 If you customize the name of the database, remember to edit the sql
76 file:
77
78 ::
79
80     # nano /usr/local/lib/insurge/sql/scas_insurge.sql
81
82 Import Insurge:
83
84 ::
85
86     $ mysql -u root -p < /usr/local/lib/insurge/sql/scas_insurge.sql
87
88 Configure Insurge:
89
90 ::
91
92     # nano /usr/local/lib/insurge/config/insurge.ini
93
94 The variables in insurge.ini are empty. The default values are too long
95 and cause MySQL errors.
96
97 Here is a sample of insurge.ini
98
99 ::
100
101     ; This is the Locum configuration file
102     ; General configuration options for your installation of Insurge.
103     [insurge_config]
104     dsn_file = "/usr/local/etc/locum_insurge_dsn.php"
105     ; This is where you configure your repository membership information.
106     ;
107     ; parent_server is the server name of the repository parent server you have been
108     ; told to use.
109     ; group_id = The group ID you have been given by your repository admin.
110     ; These configuration points are OPTIONAL and are only necessary if you are
111     ; participating in a repository relationship.
112     [repository_info]
113     parent_server = ""
114     group_id = ""
115     group_key = ""
116
117 `Installation of Locum <#sopacinstallocum>`__
118 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119
120 The same procedure applies to Locum
121
122 ::
123
124     # nano /usr/local/lib/locum/sql/scas_locum.sql
125     # mysql < /usr/local/lib/locum/sql/scas_locum.sql
126     # nano /usr/local/lib/locum/sql/locum_init.sql
127     # mysql < /usr/local/lib/locum/sql/locum_init.sql
128     # nano /usr/local/lib/locum/config/locum.ini
129     # mkdir /usr/local/var
130     # mkdir /usr/local/var/log
131
132 Configure the DSN:
133
134 ::
135
136     [locum_config]
137     dsn_file = "/usr/local/etc/locum_insurge_dsn.php"
138
139 And the information for your Koha installation:
140
141 ::
142
143     [ils_config]
144     ils = "koha";
145     ils_version = "30x"
146     ils_server = "localhost"
147     ils_harvest_port = "80"
148
149 The rest depends on your Koha configuration.
150
151 `Installation of Koha Connector <#sopackoha>`__
152 -----------------------------------------------
153
154 Download the Koha connector using SVN:
155
156 ::
157
158     # cd /usr/local/lib/locum/connectors/
159     # svn co http://dobby.darienlibrary.org/svn/connectors/koha/ locum_koha_30x
160
161 `Harvest Records <#sopacharvest>`__
162 -----------------------------------
163
164 Now that the connector is in place, we will be able to launch
165 harvest.php, a tool that will reap Locum DB Koha and fill the locum.
166
167 Start by configuring harvest.php:
168
169 ::
170
171     # nano /usr/local/lib/locum/tools/harvest.php
172
173 Here are the variables you must change:
174
175 ::
176
177     $first_record = 1;
178     $last_record = 30;
179
180 These are the minimum and maximum biblionumbers from your Koha install.
181
182 Then start the harvest:
183
184 ::
185
186     # chmod +x /usr/local/lib/locum/tools/harvest.php
187     $ /usr/local/lib/locum/tools/harvest.php
188
189 `Installation of Sphinx <#sopacphinx>`__
190 ----------------------------------------
191
192 Sphinx is the indexer for the database used by Locum and Insurge.
193
194 `Dependencies <#sphinxdepend>`__
195 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
196
197 There is no Debian package for Sphinx so you'll have to compile the
198 source directly:
199
200 ::
201
202     # apt-get install g++ make libmysql++-dev
203
204 `Download and Compile <#sphinxdownload>`__
205 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
206
207 ::
208
209     $ wget http://sphinxsearch.com/downloads/sphinx-0.9.8.tar.gz
210     $ tar zxvf sphinx-0.9.8.tar.gz
211     $ cd sphinx-0.9.8
212     $ ./configure --prefix=/usr/local/sphinx
213     $ make
214     # make install
215     # mkdir /usr/local/sphinx
216     # mkdir /usr/local/sphinx/lib
217     # cp api/sphinxapi.php /usr/local/sphinx/lib/
218     $ rm -R sphinx-0.9.8*
219
220 `Creation of User and Group <#sphinxuser>`__
221 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
222
223 Creating a Sphinx user and change the owner:
224
225 ::
226
227     # adduser sphinx
228     # addgroup sphinx
229     # usermod -G sphinx sphinx
230     # mkdir /usr/local/sphinx/var/run
231     # chown -R sphinx.sphinx /usr/local/sphinx/var
232
233 `The Sphinx daemon <#demonsphinx>`__
234 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
236 Download:
237
238 ::
239
240     # cd /etc/init.d
241     # wget http://www.thesocialopac.net/sites/thesocialopac.net/files/sphinx
242     # chmod +x /etc/init.d/sphinx
243
244 Add Sphinx to the default boot services:
245
246 ::
247
248     # update-rc.d sphinx defaults
249
250 `Configuration <#sphinxconfig>`__
251 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
252
253 Copy the configuration file supplied with the source of Sphinx before
254 the change:
255
256 ::
257
258     # cp /usr/local/lib/locum/sphinx/sphinx.conf /usr/local/sphinx/etc/
259     # sed 's/locum_db_user/scas_user/g' /usr/local/sphinx/etc/sphinx.conf > tmpfile;
260     mv tmpfile /usr/local/sphinx/etc/sphinx.conf
261     # sed 's/locum_db_pass/scas_pass/g' /usr/local/sphinx/etc/sphinx.conf > tmpfile; mv tmpfile /usr/local/sphinx/etc/sphinx.conf
262
263 And if you personalize the name of the database:
264
265 ::
266
267     # sed 's/scas/MY_DB/g' /usr/local/sphinx/etc/sphinx.conf > tmpfile; mv tmpfile /usr/local/sphinx/etc/sphinx.conf
268
269 `Indexing documents <#sphinxindexing>`__
270 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
271
272 Indexing is necessary if you want to use the search features of SOPAC.
273
274 You must first complete the Insurge table index
275
276 ::
277
278     # chmod +x /usr/local/lib/insurge/tools/update-index.php
279     $ /usr/local/lib/insurge/tools/update-index.php
280
281 Then start indexing Sphinx
282
283 ::
284
285     $ /usr/local/sphinx/bin/indexer --all
286
287 Finally, we must start the daemon:
288
289 ::
290
291     # /etc/init.d/sphinx start
292
293 When the daemon is running, you can update the index with:
294
295 ::
296
297     $ /usr/local/sphinx/bin/indexer --all --rotate
298
299 `Installation of SOPAC2 <#installsopac>`__
300 ------------------------------------------
301
302 Now to the SOPAC software itself:
303
304 `Download <#downloadsopac>`__
305 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
306
307 Download from SVN:
308
309 ::
310
311     $ cd /chemin/vers/drupal/sites/all/
312     $ mkdir modules
313     $ cd modules/
314     $ svn co http://dobby.darienlibrary.org/svn/sopac/trunk/ sopac
315
316 `Installation <#sopacinstallation>`__
317 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318
319 In Drupal's administration settings, activate the module. Also, enable
320 the dependencies:
321
322 -  Profile
323
324 -  PHP Filter
325
326 -  Path
327
328 The Drupal menu should now list these entries.
329
330 `Configuration <#configsopac>`__
331 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332
333 Then go into the settings of SOPAC.
334
335 -  Configure the paths to the Locum and Insurge libraries
336
337 -  Choose a URL prefix SOPAC, in my "catalog". Create a node with
338    content like:
339
340 ::
341
342     <?php
343     print sopac_search_form('both');
344     print theme('pages_catalog');
345
346 -  Check the Input Format "PHP Code"
347
348 -  Check Move to front page
349
350 -  In URL path settings, set the SOPAC URL prefix you have chosen.
351
352 Go to the root of Drupal, a search form will appear.
353
354 Remember to empty Drupal's cache when something does not work.
355
356 Drupal offers a few blocks, which are not configured by default. You
357 must specify on which page they should appear.