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