多個圖書館共同一套 Koha

毛慶禎 2009.4.8

第一個方法:
To make a custom search page:

(ie: “I want my students to only search my branch as default”)

Edit c:\~\OPAC\cgi-bin\koha\opac- search.pl

Save a copy as PINEopac-search.pl

Edit line 202 (template_name) to “PINEopac-search.tmpl”

Edit c:\~\OPAC\htdocs\opac-tmpl\ css\en\opac-search.tmpl

Save a copy as PINEopac-search.tmpl

Edit line 87 to read

<option value=“PINE”>Pine</option

Point browsers to http://<site>/cgi-bin/koha/ PINEopac-search.tmpl


另一個方法:
有人採用這種方式: 為每個圖書館建獨立的資料庫及設定檔。

Modify the /etc/network/interfaces file to bind multiple ip addresses to the ethernet interface. After much trial and error I wound up with this:


  1. This file describes the network interfaces available on your system
  2. and how to activate them. For more information, see interfaces(5).

  1. The loopback network interface
auto lo eth1 eth1:0 eth1:1
iface lo inet loopback


  1. The primary network interface
allow-hotplug eth1
iface eth1 inet static
address 192.168.1.133
netmask 255.255.255.0
gateway 192.168.1.10

iface eth1:0 inet static
address 192.168.1.139
netmask 255.255.255.0
gateway 192.168.21.10

iface eth1:1 inet static
address 192.168.1.140
netmask 255.255.255.0
gateway 192.168.1.10



This creates three static addresses on the same interface eth1.

Using phpmyadmin or the MySQL command line, login as kohaadmin and create the new database.

You need to dump the structure of the koha database and then import it into the new databases. To dump the database use mysqldump . At the command line, create a new directory and cd into it. Then enter:

mysqldump -u kohaadmin -p koha > kohaout.sql

You enter the password for kohaadmin, and this creates an sql file of the koha database.

Create the new databases using phpmyadmin or the mysql command line - example below. Start the mysql command line utility with:

mysql -u kohaadmin -p

After you enter your password, this gives you a mysql prompt. Then enter:

show databases; to see the list of databases. To create one enter:
create database <new db name>;

Then change to that dataabase:
use <new DB name>;

This command will import all the koha structure into the new database:

source kohaout.sql;

quit gets you out of the MySql utility and back to the command line.

Next you copy the config files. Change to the /etc/koha directory, and copy the koha-conf.xml and koha-httpd-conf files using the new name of your database. So if your database is named "book", you now have book-conf.xml and book-httpd.conf. Edit the book-conf.xml file, and change the name of the database. You should find this near the end of the file under the <config> section. Edit the book-httpd.conf file and make the following changes:

Edit the VirtualHost entry and change the name to one of the IP addresses you bound to the network interface - using a different address for each configuration/database. So your entry looks like <VirtualHost 192.168.1.139:50180> for the OPAC and <VirtualHost 192.168.1.139:50188> for the staff client. The IP addresses need to be in the interfaces config file, and the ports (after the :) are from the address range 50000 - 63535. These are unassigned ports in the internet scheme, and since they will be used only on the internal network can be whatever you like. The normal koha ports are the standard http port 80 for the OPAC and 8080 for the staff client. Further down in each VirtualHost section find the SetEnv KOHA_CONF declaration. Change the file to the new one, in our example "/etc/koha/book-conf.xml". You need to change this in two places, one for each VirtualHost section.

Change to the /etc/apache2 directory and edit the ports.conf file. Add the new ports you just put into the VirtualHost directives 50180 and 50188 in our example. If you want to use the default koha database, also add 8080 - the default staff client port.

You need to add symbolic links for the httpd.conf file and enable the site, so as above you do:

ln -s /etc/koha/book-httpd.conf /etc/apache2/sites-available/book
a2ensite koha

Then restart Apache - /etc/init.d/apache2 reload
If you have done all your edits correctly, apache will reload without any errors.

Browse to the new IP address - i.e. 192.168.1.139:50180 and you should see the koha opac screen. Browse to the staff client - 192.168.21.139:50188 and you should get that screen. Login as kohaadmin.

For each new database you should create a new library in the staff client, with the IP address that goes with the library filled in. DON’T turn on IndependentBranches, it causes other problems and had to be turned off. It is not needed anyway with the different catalogs running on different virtual servers.

That should get you multiple databases, with appropriate defaults when connecting to the staff client or the opac.