Everyday Life and Technology

Monday, May 10, 2010

Install Koha 3.00.00 on Ubuntu 9.10

Preparing the system: [Ubuntu 9.10 Desktop Edition] 

I did all of the commands as (root) sudo.

  • sudo apt-get install zip unzip
  • sudo apt-get update
Create a new user with the name koha, password koha[up to you]
  • sudo adduser koha
Install LAMP Server and dselect [Both required]
  • sudo apt-get install lamp-server^

Take note of the mysql root password that you will put

  • sudo apt-get install dselect
Configure the Character Set of Apache2
  • sudo nano /etc/apache2/conf.d/charset

Add the two lines:

AddCharset UTF-8 .utf8

AddDefaultCharset UTF-8

Check your Ubuntu Local
  • locale

It should return something like LANG=en_US.UTF-8

Re-update your system
  • sudo apt-get update
Install and configure Yaz and Zebra [If you decide on using Zebra, recommended for large libraries]
  • sudo apt-get install yaz idzebra-2.0 idzebra-2.0-doc
Create a build directory, you will see why later
  • sudo mkdir /build
  • sudo chmod -R 777 /build
Installing Koha and required Koha packages

The dselect process will take a long time, as it will try and install all of the required koha packages listed under debian.packages

Select the following on dselect:

Choose [I]nstall and accept packages to be installed (hit return)

Choose [C]onfigure, [R]emove and [Q]uit in this order until dselect has completed and exists.

Opsi Error: Probably only for my side, but non the less, might be helpful for others.

Failed to fetch http://ae.archive.ubuntu.com/ubuntu/pool/main/g/gst-plugins-base0.10/gstreamer0.10-alsa_0.10.25-2ubuntu1.2_i386.deb 503 Service Unavailable

Failed to fetch http://ae.archive.ubuntu.com/ubuntu/pool/main/g/gst-plugins-base0.10/gstreamer0.10-plugins-base-apps_0.10.25-2ubuntu1.2_i386.deb 503 Service Unavailable

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Some errors occurred while unpacking. I'm going to configure the packages that were installed. This may result in duplicate errors or errors caused by missing dependencies. This is OK, only the errors above this message are important. Please fix them and run [I]nstall again

Press enter to continue.

Install the lovely Java:  Require for other packages.
  • sudo apt-get update
  • sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-plugin sun-java6-fonts
Lets run dselect again, to see if any other errors occur
  • cd /build/koha-3.00.00
  • sudo dpkg --set-selections < install_misc/debian.packages
  • sudo dselect

Select the following on dselect:

Choose [I]nstall and accept packages to be installed (hit return)

Choose [C]onfigure, [R]emove and [Q]uit in this order until dselect has completed and exists.

If all is good, you shall see something like:

Building dependency tree

Reading state information... Done

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. [All is good]

Configure CPAN in Ubuntu:
  • sudo cpan

If you are running cpan for the first time, it will request you to configure it.  Simply leave the defaults that cpan suggests.

    • cpan> o conf commit

This will commit the configurations you are have just made>

    • cpan>quit

You have just configured cpan and commited the changes, and existed.

-- Important: To ensure that all your CPAN configurations have been written and saved. 

sudo nano /etc/perl/CPAN/Config.pm

Add Zip/Unzip configuration to CPAN. 
  • sudo cpan
    • cpan> o conf unzip /usr/bin/unzip
    • cpan> o conf commit
    • cpan> quit

/usr/bin/unzip is where my unzip is located in Ubuntu

Install and Configure Perl Libraries for Koha – Part 1
    • sudo cpan MARC::Crosswalk::DublinCore GD \
      GD::Barcode::UPCE HTML::Scrubber\
      Algorithm::CheckDigits::M43_001Biblio::EndnoteStyle\
      Email::Date YAML PDF::Reuse PDF::Reuse::Barcode \
      Locale::Currency::Format

    As cpan is installing, it will ask you to pre-append other libraries/packages, simply say yes.  Please note, that this process will be long and you need to be monitoring it, as it will keep on asking to press yes.

    Configuring MySQL for Koha
    • mysqladmin -u root -p create koha

    Enter Password: your mysql root password

    koha is the name of my db in this case.

    • mysql -uroot –p

    Enter Password: your mysql root password

    Grant Permissions for MySQL Database:

    Now because this is a tutorial, I used simple passwords.  Of course on your production system, it is advised that you use difficult passwords.  Kindly don’t criticize :)

    koha is the database name.

    • mysql> grant all on koha.* to 'root'@'localhost' identified by 'rootpassword’;

      Query OK, 0 rows affected (0.00 sec)

    • mysql> grant all on koha.* to 'koha'@'localhost' identified by 'koha';

      Query OK, 0 rows affected (0.00 sec)

    • mysql> flush privileges;

      Query OK, 0 rows affected (0.00 sec)

    • mysql> quit;

      Bye

    Install and Configure Perl Libraries for Koha – Part 2
    • sudo cpan
      • cpan> force install HTTP:OAI IPC::Cmd JSON XML::Writer XML::SAX::Writer
      • cpan> quit
    Configuring the SAX Parser
    • cd /build/koha-3.00.00
    • sudo perl misc/sax_parser_print.pl

    This will print us the current SAX parser settings

    XML::SAX::Expat=HASH(0x9f7afe0) <--We don't want this so we have to fix it.

    • sudo nano /etc/perl/XML/SAX/ParserDetails.ini

    Copy these two lines to the end of the ParserDetails.ini file

    [XML::LibXML::SAX::Parser]

    http://xml.org/sax/features/namespaces = 1

    • sudo perl misc/sax_parser_print.pl

    If it worked, then it should print out something like XML::LibXML::SAX::Parser=HASH(0x8c10040)

    Install pre-requisite libraries for the Perl packages:
    Install and Configure Perl Libraries for Koha – Part 3
    • sudo cpan
      • cpan> force install DBD::mysql

    The force option is so to skip the Test suite which would require us to create a new database just for testing.  I don’t want to be bothered with that.  So force it.

        • cpan> install Algorithm::CheckDigits
        • cpan> install Biblio::EndnoteStyle
        • cpan> install Data::ICal
        • cpan> install GD
        • cpan> install HTML::Template::Pro
        • cpan> install MARC::Charset
        • cpan> install MARC::File::XML
        • cpan> install Net::Z3950::ZOOM
        • cpan> install SMS::Send
        • cpan> install Schedule::At
        • cpan> install XML::RSS
        • cpan> install CGI::Session::Serialize::yaml

    -- Important:   If during running the web installer, you get the error [Production mode, trapped fatal error”.  Then most likely you forgot to install CGI::Session::Serialize::yaml

        • cpan> quit
    Install Koha – Finally – Part 1
    • su
    • cd /build/koha-3.00.00
    • sudo perl Makefile.PL

    This is the printout of the installation: 

    For reference only!

    AUTH_INDEX_MODE dom

    DB_HOST localhost

    DB_NAME koha

    DB_PASS koha

    DB_PORT 3306

    DB_TYPE mysql

    DB_USER koha

    INSTALL_BASE /usr/share/koha

    INSTALL_MODE standard

    INSTALL_PAZPAR2 no

    INSTALL_SRU yes

    INSTALL_ZEBRA yes

    KOHA_GROUP koha

    KOHA_INSTALLED_VERSION 3.00.00.107

    KOHA_USER koha

    PATH_TO_ZEBRA /usr/bin

    RUN_DATABASE_TESTS yes

    TEST_DB_HOST localhost

    TEST_DB_NAME kohatest

    TEST_DB_PASS koha

    TEST_DB_TYPE mysql

    TEST_DB_USER koha

    ZEBRA_LANGUAGE en

    ZEBRA_MARC_FORMAT marc21

    ZEBRA_PASS zebrastripes

    ZEBRA_SRU_AUTHORITIES_POR9999

    ZEBRA_SRU_BIBLIOS_PORT 9998

    ZEBRA_SRU_HOST localhost

    ZEBRA_USER kohauser

    and in the following directories:

    DOC_DIR /usr/share/koha/doc

    INTRANET_CGI_DIR /usr/share/koha/intranet/cgi-bin

    INTRANET_TMPL_DIR /usr/share/koha/intranet/htdocs/intranet-tmpl

    INTRANET_WWW_DIR /usr/share/koha/intranet/htdocs

    KOHA_CONF_DIR /etc/koha

    LOG_DIR /var/log/koha

    MAN_DIR /usr/share/koha/man

    MISC_DIR /usr/share/koha/misc

    OPAC_CGI_DIR /usr/share/koha/opac/cgi-bin

    OPAC_TMPL_DIR /usr/share/koha/opac/htdocs/opac-tmpl

    OPAC_WWW_DIR /usr/share/koha/opac/htdocs

    PAZPAR2_CONF_DIR /etc/koha/pazpar2

    PERL_MODULE_DIR /usr/share/koha/lib

    SCRIPT_DIR /usr/share/koha/bin

    SCRIPT_NONDEV_DIR /usr/share/koha/bin

    ZEBRA_CONF_DIR /etc/koha/zebradb

    ZEBRA_DATA_DIR /var/lib/koha/zebradb

    ZEBRA_LOCK_DIR /var/lock/koha/zebradb

    ZEBRA_RUN_DIR /var/run/koha/zebradb

    To change any configuration setting, please run

    perl Makefile.PL again. To override one of the target

    directories, you can do so on the command line like this:

    perl Makefile.PL PERL_MODULE_DIR=/usr/share/perl/5.8

    You can also set different default values for parameters

    or override directory locations by using environment variables.

    For example:

    export DB_USER=my_koha

    perl Makefile.PL

    or

    DB_USER=my_koha DOC_DIR=/usr/local/info perl Makefile.PL

    If installing on a Win32 platform, be sure to use:

    'dmake -x MAXLINELENGTH=300000'

    Writing Makefile for koha

    -- Important: If you made a mistake, and want to change any configuration setting, please run the command again:

              sudo perl Makefile.PL 

    Install Koha – Finally – Part 2
    • su
    • cd /build/koha-3.00.00
    • sudo make
    • sudo make test

    All tests successful.

    Files=19, Tests=47, 2 wallclock secs ( 0.04 usr 0.14 sys + 1.24 cusr 1.03 csys = 2.45 CPU)

    Result: PASS

    • sudo make install

    It will take time to install.

    At the end it will look similar to this at the end.  I didn’t copy the whole print-out.

    …etc….etc..etc….

    Installing /usr/share/koha/man/man3/cataloguing::value_builder::unimarc_field_115a.3pm

    Installing /usr/share/koha/man/man3/C4::Reports.3pm

    Installing /usr/share/koha/man/man3/cataloguing::value_builder::unimarc_field_123i.3pm

    Installing /usr/share/koha/man/man3/acqui::neworderbiblio.3pm

    Koha's files have now been installed.

    In order to use Koha's command-line batch jobs,

    you should set the following environment variables:

    export KOHA_CONF=/etc/koha/koha-conf.xml

    export PERL5LIB=/usr/share/koha/lib

    For other post-installation tasks, please consult the README.

    Setting up Environmental Variables
    • su
    • export KOHA_CONF=/etc/koha/koha-conf.xml
    • export PERL5LIB=/usr/share/koha/lib
    Add Koha site to Apache and configure Apache2
    • sudo ln -s /etc/koha/koha-httpd.conf /etc/apache2/sites-available/koha

    [The location of apache2/sites-available might be different on your machine. To find where apache2 is located, do the command: find / -name apache2

    • sudo nano /etc/apache2/ports.conf
      • Comment out the NameVirtualHost *:80

    Put # in front of the line to comment it

      • Add Listen port 8080 and port 80

    The file will look like this:

    #NameVirtualHost *:80

      Listen 80

      Listen 8080

    <IfModule mod_ssl.c>

    # SSL name based virtual hosts are not yet supported, therefore no

    # NameVirtualHost statement here

    Listen 443

    </IfModule>

    Configure Apache and Restart
    • sudo a2enmod rewrite

    Enabling module rewrite.

    Run '/etc/init.d/apache2 restart' to activate new configuration!

    • sudo a2ensite koha

    Enabling site koha.

    Run '/etc/init.d/apache2 reload' to activate new configuration!

    • sudo apache2ctl restart
    Setting up and Configuring Zebra Server
    • sudo ln -s /usr/share/koha/bin/koha-zebra-ctl.sh /etc/init.d/koha-zebra-daemon
    • sudo update-rc.d koha-zebra-daemon defaults

    update-rc.d: warning: /etc/init.d/koha-zebra-daemon missing LSB information

    update-rc.d: see <http://wiki.debian.org/LSBInitScripts>

    Adding system startup for /etc/init.d/koha-zebra-daemon ...

    /etc/rc0.d/K20koha-zebra-daemon -> ../init.d/koha-zebra-daemon

    /etc/rc1.d/K20koha-zebra-daemon -> ../init.d/koha-zebra-daemon

    /etc/rc6.d/K20koha-zebra-daemon -> ../init.d/koha-zebra-daemon

    /etc/rc2.d/S20koha-zebra-daemon -> ../init.d/koha-zebra-daemon

    /etc/rc3.d/S20koha-zebra-daemon -> ../init.d/koha-zebra-daemon

    /etc/rc4.d/S20koha-zebra-daemon -> ../init.d/koha-zebra-daemon

    /etc/rc5.d/S20koha-zebra-daemon -> ../init.d/koha-zebra-daemon

    -- Important: /usr/share is the location of where I installed Koha during the previous steps.  It is the default for Production Systems. [Recommended]

    Setting up and configuring Zebraqueue
    • sudo ln -s /usr/share/koha/bin/koha-zebraqueue-ctl.sh /etc/init.d/koha-zebraqueue-daemon
    • sudo update-rc.d koha-zebraqueue-daemon defaults

    update-rc.d: warning: /etc/init.d/koha-zebraqueue-daemon missing LSB information

    update-rc.d: see <http://wiki.debian.org/LSBInitScripts>

    Adding system startup for /etc/init.d/koha-zebraqueue-daemon ...

    /etc/rc0.d/K20koha-zebraqueue-daemon -> ../init.d/koha-zebraqueue-daemon

    /etc/rc1.d/K20koha-zebraqueue-daemon -> ../init.d/koha-zebraqueue-daemon

    /etc/rc6.d/K20koha-zebraqueue-daemon -> ../init.d/koha-zebraqueue-daemon

    /etc/rc2.d/S20koha-zebraqueue-daemon -> ../init.d/koha-zebraqueue-daemon

    /etc/rc3.d/S20koha-zebraqueue-daemon -> ../init.d/koha-zebraqueue-daemon

    /etc/rc4.d/S20koha-zebraqueue-daemon -> ../init.d/koha-zebraqueue-daemon

    /etc/rc5.d/S20koha-zebraqueue-daemon -> ../init.d/koha-zebraqueue-daemon

    Reboot your computer
    • sudo reboot

    I am rebooting for the zebra server and zebraqueue daemon to start up.

    Maybe there is a better way.  I don’t know :)

    Running Koha Web Installer [Defaults]

    The web installer, and Koha Administrator View

    The public OPAC View

    • Username: koha  Password: koha

    If you don't know your username/password. Check koha-conf.xml.

    sudo nano /etc/koha/koha-conf.xml

    Look at the section under <config>

    <config>

    <db_scheme>mysql</db_scheme>

    <database>koha</database>

    <hostname>localhost</hostname>

    <port>3306</port>

    <user>koha</user>

    <pass>koha</pass>

    ...etc....

    ...etc....

    </config>

    During Web Installation, Select "MARC21", unless otherwise specified by your Library.

    As well, Choose "ZEBRA" indexing. You have to configure this. I have chosen Zebra because my system is a production system, and our Library has a a big catalog.

    You may choose "NoZebra", if you are doing dev-testing OR your catalog is small.

    Adding one Catalog and running Zebra:

    [Must be KOHA user]

      • Add a new record to Koha by searching Library of Congress
      • su koha
      • perl -I /usr/share/koha/lib /usr/share/koha/bin/migration_tools/rebuild_zebra.pl -a -b –r

    Option a: Authority Indexing

    Option b: Biblios Indexing

    Option r: Reseting the indexing from start

    Searching Koha for a record:

    If you did rebuild_zebra.pl and searched Koha for the record you added and you get 0 results.  You need to look at a few things.

    - Making sure that your zebra server and zebraqueue daemon are running:

    - Replace ${KOHA_USER} with your koha user.  In my case koha

      • sudo -u ${KOHA_USER} zebrasrv -f /etc/koha/koha-conf.xml
      • sudo -u ${KOHA_USER} ${SCRIPT_DIR}/zebraqueue_daemon.pl

    - Ensure that ownership is set to koha.  Zebradb must belong to your koha user

      • sudo chmod –R 777 /var/lock/koha
      • sudo chown –R koha:koha /var/lock/koha
      • sudo chmod –R 777 /var/lib/koha/
      • sudo chown –R koha:koha /var/lib/koha
    If you desperately need to reset your authority and biblios database:
    • su koha
    • zebraidx -c /etc/koha/zebradb/zebra-authorities-dom.cfg -g iso2709 –d authorities init
    • zebraidx -c /etc/koha/zebradb/zebra-biblios.cfg -g iso2709 -d biblios init
    References:

    Hope you find this tutorial helpful.

    Regards,

    Wednesday, April 28, 2010

    Uninstall and Install Postgresql 8.3

    sudo apt-get --purge remove postgresql | apt-get install postgresql-8.3
    Errors faced:

    Setting up postgresql-8.3 (8.3.5-0ubuntu8.10) ...
    * Starting PostgreSQL 8.3 database server * Insecure directory in $ENV{PATH} while running with -T switch at /usr/share/postgresql-common/PgCommon.pm line 654. [fail]

    invoke-rc.d: initscript postgresql-8.3, action "start" failed. dpkg: error processing postgresql-8.3 (--configure): subprocess post-installation script returned error exit status 255  Errors were encountered while processing: postgresql-8.3

    Resolution:

    • sudo dpkg –configure –a
    • sudo apt-get install –f
    • sudo apt-get update

    If the issue still persists, do the following.

    • sudo nano /usr/share/postgresql-common/PgCommon.pm and on the first top line , remove the –T from that line.
    • sudo apt-get –purge remove postgresql

    Now if you try to do sudo apt-get install postgresql-8.3 it should work fine.