Merge remote branch 'kc/master' into new/enh/bug_5917
[koha.git] / INSTALL.debian
1 =============================
2 Installation Guide for Installing Koha on Debian Lenny with MySQL 5
3 =============================
4
5 Some parts copyright 2010 Chris Nighswonger
6
7 Feedback/bug reports: Koha Developer's List:
8 http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
9
10 This document last modified: October 8, 2010
11
12 Installation Instructions
13 =============================
14
15 All commands can be performed as a system user with sudo privileges,
16 as indicated or by running the command directly as root.
17
18 1. Prepare System and Install Dependencies
19
20 1.1 Install Debian Lenny via Businesscard CD
21
22     See http://www.debian.org/releases/lenny/debian-installer/
23
24 1.2 Set up Indexdata apt sources for Yaz and Zebra packages
25
26 Edit your /etc/apt/sources.list file and add the following:
27
28     # Index Data
29     deb http://ftp.indexdata.dk/debian lenny main
30     deb-src http://ftp.indexdata.dk/debian lenny main
31
32 The Index Data packages are signed with a key you can install as follows:
33
34     $ wget -O- http://ftp.indexdata.dk/debian/indexdata.asc | sudo apt-key add -
35
36 Finally, update your apt sources:
37     $ sudo apt-get update
38
39 1.3 Get Koha
40 Choose one of these options:
41
42 1.3.1 Option A: Download Koha via Git (optional)
43
44     $ sudo apt-get install git-core git-email
45     $ git clone git://git.koha-community.org/koha.git koha
46     $ cd koha
47     $ git checkout -b myinstall origin
48
49 Note: for more information about Git, please see the Koha Git Usage Guide:
50
51     http://wiki.koha-community.org/wiki/Version_Control_Using_Git
52
53 1.3.2 Option B: Download Koha from http://download.koha-community.org
54
55 Find the latest Koha stable version on http://download.koha-community.org
56 and get it:
57
58     $ wget <URL> found on download.koha-community.org
59
60 1.4 Install additional Debian dependencies
61
62 IMPORTANT:  You should only use CPAN for Perl dependencies which are NOT
63             available from the package maintainer. You have been warned!
64
65 Run shell script installing all necessary Debian packages, MySQL Server,
66 Zebra and all Debian packaged Perl module required by Koha:
67
68     $ sudo install_misc/apt-get-debian-lenny.sh
69
70 1.5 Install Perl dependencies that aren't packaged into Debian Lenny
71 sources
72
73 Run the following command:
74
75     $ sudo cpan Algorithm::CheckDigits SMS::Send HTTP::OAI IPC::Cmd \
76       Memoize::Memcached PDF::API2::Simple PDF::Table Storable Test::More \
77       Locale::Currency::Format DateTime Lingua::Stem::Snowball Text::CSV::Encoded \
78       UNIVERSAL::require YAML Authen::CAS::Client
79
80 Note: you may need to run CPAN initialization if you've not run cpan
81 before:
82
83     /etc/perl/CPAN/Config.pm initialized.
84
85     CPAN is the world-wide archive of perl resources. It consists of about
86     100 sites that all replicate the same contents all around the globe.
87     Many countries have at least one CPAN site already. The resources
88     found on CPAN are easily accessible with the CPAN.pm module. If you
89     want to use CPAN.pm, you have to configure it properly.
90     
91     If you do not want to enter a dialog now, you can answer 'no' to this
92     question and I'll try to autoconfigure. (Note: you can revisit this
93     dialog anytime later by typing 'o conf init' at the cpan prompt.)
94     
95     Are you ready for manual configuration? [yes]
96
97 When the configuration is completed CPAN will install the Perl modules.
98
99 2. Configuration of dependencies
100
101 2.1 Create the Koha database
102
103  Create the database and user with associated privileges (information inside <> brackets is
104  data you assign specifically to your installation. Do not include the <>'s when entering the commands):
105
106     $ mysqladmin -uroot -p<password> create <kohadatabasename>
107     $ mysql -uroot -p<password>
108
109     Welcome to the MySQL monitor.  Commands end with ; or \g.
110     Your MySQL connection id is 22
111     Server version: 5.0.51a-24 (Debian)
112
113     Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
114
115     mysql> grant all on <kohadatabasename>.* to '<kohadatabaseuser>'@'localhost' identified by '<kohadatabaseuserpassword>';
116     Query OK, 0 rows affected (0.00 sec)
117
118     mysql> flush privileges;
119     Query OK, 0 rows affected (0.00 sec)
120
121     mysql> quit
122
123 You may want to document the database name, the database username, and the database password you just set.
124 Step 3 will require them.
125
126 2.2 Test your SAX Parser and correct where necessary
127
128 You must be sure you're using the XML::LibXML SAX parser, not Expat or
129 PurePerl, both of which have outstanding bugs with pre-composed characters.
130 You can test your SAX parser by running:
131
132     $ cd koha
133     $ misc/sax_parser_print.pl 
134
135 You should see something like:
136
137     XML::LibXML::SAX::Parser=HASH(0x81fe220)
138
139 If you are configured to use PurePerl or Expat, the script will say you have a problem and 
140 you'll need to edit your ini file to correct it.
141
142 The file is typically located at:
143
144     /etc/perl/XML/SAX/ParserDetails.ini
145
146 The correct parser entry will need to be moved to the bottom of the file.
147 The following is the entry you are looking for:
148
149     [XML::LibXML::SAX::Parser]
150         http://xml.org/sax/features/namespaces = 1
151
152 2.3 Create your Koha system user (if you haven't created one already)
153
154     $ sudo adduser koha
155
156 You can substitute any username for "koha," just be sure to write it down, you will need to know what it is in step 3.
157
158 3. Run the Koha installer
159
160     $ perl Makefile.PL
161       ( answer questions )
162     $ make
163     $ make test
164     $ sudo make install
165
166 3.1 Export the environment variables
167 Make install will tell you what the proper path for these environment variables is.
168 In case you missed it at the end of make install, here are some examples:
169
170 Example (for standard install):
171     $ export KOHA_CONF=/etc/koha/koha-conf.xml
172     $ export PERL5LIB=/usr/share/koha/lib
173
174 Example (for dev install. These paths are set during Makefile.PL.):
175     $ export KOHA_CONF=/path/to/your/koha-conf.xml
176     $ export PERL5LIB=/path/to/koha/lib
177
178 4. Configure and start Apache
179     $ sudo ln -s /etc/koha/koha-httpd.conf /etc/apache2/sites-available/koha
180 (note that the path to koha-httpd.conf may be different if you chose a dev install)
181
182 Add the following lines to /etc/apache2/ports.conf:
183
184     Listen 80
185     Listen 8080
186
187 Run the following commands:
188
189     $ sudo a2enmod rewrite deflate
190     $ sudo a2ensite koha
191     $ sudo apache2ctl restart
192
193 Note: you may still see the usual Apache default site if your VirtualHost
194       configuration isn't correct.  If Koha is the only web application running on the server,
195       the command "sudo a2dissite default" may be a quick fix. For servers running other sites
196       alongside Koha, see the Apache HTTPD manual section on virtual hosts for full
197       instructions (http://httpd.apache.org/docs/2.0/vhosts/).
198
199 5. Run the Web Installer, populate the database, initial configuration of settings
200
201 Point your browser to http://<servername>:8080/
202
203 Note: <servername> is (usually) the IP of your server, or localhost (if you are connecting
204       from the same machine Koha is installed on. You can verify the location by checking 
205       the VirtualHost settings for both the opac and intranet virtual hosts in koha-httpd.conf
206
207 Koha will redirect you to the Web Installer where you can continue the setup. You will be prompted to enter in your DATABASE username and password. It is through this interface 
208 that 
209 you can install the sample data for libraries, patrons, and much more.
210
211 Be aware that removing sample data at a later time (when you may want to take the 
212 server into production) may not be easy, and if your intent is to take this 
213 install from testing to production, go with minimal sample data (no patrons or bibliographic records).
214
215 6. Configure and start Zebra
216
217 Note: it's recommended that you daemonize the Zebra process and add it to your
218       startup profile. For a non-production test/development installation, running
219       Zebra from the command line can be useful. Pick one of the options below (or roll your own).
220
221 Note: it's also recommended that you create a Koha system user, which you will
222       have specified during the install process. Alternatively, Zebra can be
223       configured to run as the root user.
224
225 Option 1: run the Zebra processes from the command line (manual indexing):
226
227 6.1.1 Zebra Search Server
228
229 This process send responses to search requests sent by Koha or
230 Z39.50/SRU/SRW clients.
231
232     $ sudo -u <kohauser> zebrasrv -f /etc/koha/koha-conf.xml
233     (note that the path to koha-conf.xml may be different if you chose a dev install, and that
234     <kohauser> refers to the user you set up in step 2.3)
235
236 Note: the user you run Zebra as will be the only user with write permission
237       on the Zebra index; in development mode, you may wish to use your
238       system user.
239
240
241 6.1.2 Zebra Indexer
242
243 Added/updated/deleted records in Koha MySQL database must be indexed
244 into Zebra. A specific script must be launched each time a bibliographic
245 or an authority record is edited.
246
247     $ sudo -u <kohauser> misc/migration_tools/rebuild_zebra.pl -z -b -a
248
249 Note: This script should be run as the kohauser (the default is 'koha', but
250 this is the user you set up in step 2.3).
251
252 Option 2: run the Zebra process as a daemon (automatic indexing):
253
254 Note: References to <script_dir> refer to the directory where
255       Koha's command-line scripts are installed, the path
256       is /usr/share/koha/bin/ by default in a standard install.
257
258 6.2.1 Zebra Search Server
259
260     $ sudo ln -s <script_dir>/koha-zebra-ctl.sh  /etc/init.d/koha-zebra-daemon
261     (Note: <script_dir> is /usr/share/koha/bin/ by default in a standard install)
262     $ sudo update-rc.d koha-zebra-daemon defaults
263
264     $ sudo <script_dir>/koha-zebra-ctl.sh start
265     (Note: <script_dir> is /usr/share/koha/bin/ by default in a standard install)
266
267
268 6.2.2 Zebra Indexer
269
270 Add an entry in Koha user crontab to process scheduled added/updated/deleted records
271 indexing by Zebra. <script_dir>cronjobs/crontab.example contains examples for these cron jobs (and many more).
272
273 NOTE: The cronjobs should be setup under the kohauser (the default is 'koha', but
274 this is the user you set up in step 2.3).
275
276 Edit the crontab for the koha user by running
277     $ sudo -u <kohauser> crontab -e
278
279 For Zebra indexing, you are looking for the example that begins with
280     
281     # ZEBRA INDEX UPDATES with -z option, incremental index updates throughout the day
282     # for both authorities and bibs
283
284 It may be easiest to copy/paste the example into your own crontab and modify as necessary.
285
286
287 7. What next?
288
289     Once the installer has completed, you can import and index MARC records from the
290     command line thusly (Note: you can also use the 'Stage MARC records for import' from
291     the Tools area of Koha's Staff Client to import a batch of MARC records):
292
293     $ export KOHA_CONF=/usr/share/koha/etc/koha-conf.xml
294       (note: use the correct path to your koha-conf.xml)
295
296 7.1 Import:
297
298 Bibliographic data in MARC21 format
299
300     $ misc/migration_tools/bulkmarcimport.pl -file /path/to/marc.iso2709
301
302 Authority data in MARC21 format
303
304     $ misc/migration_tools/bulkmarcimport.pl -a -file /path/to/auth.iso2709
305
306 7.2 Fast Index:
307     $ misc/migration_tools/rebuild_zebra.pl -b -w
308
309     Once the indexing has completed, you will be able to search for records in your system.
310     NOTE: This script should be run as the kohauser (the default is 'koha', this is the user we set up in step 2.3).
311
312 7.3 Schedule regular index updates
313     You need to run rebuild_zebra.pl -b -a -z as a regular cron job in orde to pick up new bibs
314     and items as you add them. Check misc/cronjobs/crontab.example for usage examples. See 7.0 above.
315     NOTE: This job should be setup under the kohauser (the default is 'koha', this is the user we set up in step 2.3).
316
317 7.4 To enable public Z39.50/SRU servers, you'll need to edit your koha-conf.xml and
318     change the <listen> options to listen on a TCP port; then restart the zebra daemon.
319
320 UPGRADE
321 =======
322 If you are upgrading from a previous installation of Koha 3, you can
323 use the following:
324
325  ./koha_perl_deps.pl -u -m # to identify new Perl dependencies
326  perl Makefile.PL --prev-install-log /path/to/koha-install-log
327  make
328  make test
329  sudo make upgrade
330
331 Uninstall Instructions
332 =============================
333 1) Stop Services:
334    $ sudo a2dissite koha
335    $ sudo rm /etc/apache2/sites-available/koha
336    $ sudo apache2ctl restart
337
338    $ sudo update-rc.d koha-zebra-daemon remove
339    $ sudo rm /etc/init.d/koha-zebra-daemon
340
341 2) Remove Database and Indexes
342
343    # MySQL
344    $ mysql -u<kohauser> -p<kohapassword>
345    > drop database koha;
346
347    # Zebra Indexes
348    $ zebraidx -c <prefix>/etc/zebradb/zebra-biblios.cfg -g iso2709 -d biblios init
349    $ zebraidx -c <prefix>/etc/zebradb/zebra-authorities.cfg -g iso2709 -d authorities init
350
351 3) Remove Koha Install Directories and Configuration Files
352    Don't forget about any crontab entries
353
354 Tested on the following operating environments
355 ==============================================
356 - Debian Lenny 5.0
357
358 Other Notes
359 =====================
360 This file is part of Koha
361
362 Koha is free software; you can redistribute it and/or modify it under the
363 terms of the GNU General Public License as published by the Free Software
364 Foundation; either version 2 of the License, or (at your option) any later
365 version.
366
367 Koha is distributed in the hope that it will be useful, but WITHOUT ANY
368 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
369 A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
370 You should have received a copy of the GNU General Public License along with
371 Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
372 Suite 330, Boston, MA  02111-1307 USA
373