Tuesday, July 21, 2009

Integrated Library Systems and LAMP

Time to take a look at some small ILS for the LAMP platform. We start with phyMylibrary which is a located at http://sourceforge.net/projects/phpmylibrary/ and is designed for small or personal collections. According to the project page:

The program consist of cataloging, circulation, and the webpac module. The programs also has an import export feature. The program strictly follow the USMARC standard for adding materials.

The latest version is 2.2.1-3 which we download on a windows machine to start. The idea will be to later move it to the portable apps and to the linux environment.

We xtract the phpMylibrary folder and view the README file which has lots of change notes. There is also an installation folder which has an index.php but not instructions, maybe you just copy it to your web root and run the php program. But it will need a mysql database and mysql user, no? Anyway we proceed. This is a windows box running wampserver so we copy the phpMylibrary to c:\wamp\www and open a browser to http:\\localhost\phpmylibrary\installation

The only minor issue is that magic quotes is set to off in the php.ini file but we proceed anyway. Ah, the mysql database configuration page wants the hostname, the mysql user/password and the database name. One assumes these have to be set up BEFORE running this install script but with no documentation in a README or any information on this page you have to guess what to do. The page also has a NEXT but no BACK buttons so it may not be possible to return to this page if you proceed.

Todo Tomorrow

Create the phpmylibrary database along a phpmylibrary user and re-do the install

ok we are now on the dell min 9 with ubuntu and i copied the openbiblio folder to the sd card rather than the ssd drive. The htdocs folder is in /opt/lampp so we need to tell apache to use /media/kingston/openbiblio as a virtual directory. The idea is to create a library system on a removable disk and to be able to swap in pre-setup applications on sd cards. This makes the netbook a very portable demo machine.

The first thing to do is to tell apache we want to use virtual directories. With linux xampp the httpd.conf file is in /opt/lampp/etc which is different from the mac and win versions and since it is not owned by gnickers we cannot edit from the gui.

Open terminal and cd to /opt/lampp/etc and then do sudo pico httpd.conf but drats no pico installed. Turns out pico is not included in the distro so we run the package manager and find nano, a gpl pico clone.

sudo nano httpd.conf

works. The line we want to uncomment is:

#Include conf/extra/httpd-vhosts.conf


which is way down the file. Everything else is entered in the file httpd-vhosts.conf, which will be located in the extra folder.

tomorrow


We are now on a windows USB stick running portableapps. The openbiblio docs say that php.ini must enable sessions. The version of portable apps/xampp we are running uses /apache/bin to store php.ini but this is changed to the php directory in the more recent versions.

So we edit php.ini and set up a few things:

- turn magic quotes on
- turn display errors off
- file uploads are on and set to upload_tmp_dir = "\xampp\tmp" (make sure tmp exists!)
- session.save_path = "\xampp\tmp"

This was setup before when we were testing out php programming and although session files were saved:

PMA_token |s:32:"bae7b084a2d2f1fdceb62dbd04a96119";PMA_Config|O:10:"PMA_Config":10:{s:14:"default_source";s:30:"./libraries/config.default.php";s:8:"settings";a:170:
{s:14:"PmaAbsoluteUri";s:28:"http://localhost/phpmyadmin/";s:28:"PmaNoRelation_DisableWarning";b:0;s:21:"SuhosinDisableWarning"

we had problems implementing session variables in php. This may have been due to our lack of understanding of php and sessions, so we press on and SAVE the changes.

Set up the Database

Next comes the mysql part. Since we are on a windows machine the fast way is to open a terminal window to our home folder and run the mysql command line client.

Microsoft Windows XP [Version 5.1.2600]
U:\>dir *.exe
Volume in drive U is K-Faculty
Directory of U:\

07/06/2007 02:24 PM 2,039,808 mysql.exe
07/06/2007 02:24 PM 2,035,712 mysqldump.exe
07/06/2007 02:24 PM 1,982,464 mysqlimport.exe
08/01/2003 06:27 PM 274,432 vnc.exe
4 File(s) 6,332,416 bytes
0 Dir(s) 14,276,997,120 bytes free

U:\>

Now all we do is type mysql -hlocalhost -uroot and we are logged into the mysql server running on the usb stick. (note the default xampp is no password for root, which is a security risk)

We first create a log file of our session:

mysql> \T openbiblio.txt
Logging to file 'openbiblio.txt'
mysql>

Next we create the empty database and test to see if the command was successful:

mysql> create database OpenBiblio;
Query OK, 1 row affected (0.28 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| blogs |
| books |
| catalog |
| cdcol |
| course_data |
| course_date |
| digital_library |
| joomla |
| mysql |
| openbiblio |
| perl |
| philosophy |
| phpmyadmin |
| test |
| webauth |
+--------------------+
16 rows in set (0.56 sec)

Next, you have to set up the openbiblio user for the php install program to use:

mysql> grant all privileges on OpenBiblio.* to
obiblio_user@localhost identified
by 'obiblio_password';
Query OK, 0 rows affected (0.00 sec)

Obviously, we should have changed the example in the documentation to something but this is just a demo. We stop the session logging with \t and exit mysql.

We have already copied the openbiblio folder to the htdocs folder on the usb stick so the next step is to edit the database_constants.php file in the openbiblio directory to set the username and password to whatever you set up in mysql.

define("OBIB_HOST", "localhost");
define("OBIB_DATABASE", "OpenBiblio");
define("OBIB_USERNAME", "openbiblio_user");
define("OBIB_PWD", "openbiblio_password");

Now to run the install program. Open a web browser and goto http://localhost/openbiblio/install/index.php which opens up the mysql database and starts the install. We get an error:

The connection to the database failed with the following error.
      Cannot connect to database server.: Access denied for user 'openbiblio_user'@'localhost' (using password: YES) -- FULL SQL: Connecting to database server...    
Please make sure the following has been done before running this install script.

This could be caused by a couple of things. First we make sure the mysql tables have been updated by logging back into the database server and flushing the priviledges to refresh the table.

U:\>mysql -hlocalhost -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.30-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)

Let's try the install program again to see if that was the cause. No joy. The second possibility is we set up the privileges incorrectly. Let's try making it from any host.

mysql> grant all privileges on OpenBiblio.* to obiblio@"%" identified by 'obiblio';
Query OK, 0 rows affected (0.00 sec)

Then we change the database_constants.php file to match and try to install again. No Joy. Let's confirm the user name/password is working on mysql.

U:\>mysql -hlocalhost -uobiblio -p
Enter password: *******
ERROR 1045 (28000): Access denied for user 'obiblio'@'localhost' (using password: YES)

Ah - the problem is we can't connect. We can fix the host connect problem later but for a quick hack let's just try root which can connect to localhost. We edit the database_constants.php file to change user to root with no password and refesh the install.php page. It works, so the problem for the obiblio user is it denied access to localhost.

We select English as the language and place a tick mark in the Install Sample Data. In a flash it is done and we get:

Database connection is good.
Building OpenBiblio tables, please wait...

OpenBiblio tables have been created successfully!
start using OpenBiblio

We click on the link and viola, we now have an integrated library system in our pocket!

Welcome to OpenBiblio

Use the navigation tabs at the top of each page to access the following library administration sections.

TabDescription
Circulation

Use this tab to manage your member records.
  • Member administration (new, search, edit, delete)
  • Member bibliography checkout, holds, account, and history
  • Bibliography checkin and shelving cart list
Cataloging



Use this tab to manage your bibliography records.
  • Bibliography administration (new, search, edit, delete)
Admin

Use this tab to manage staff and administrative records.
  • Staff administration (new, edit, password, delete)
  • General library settings
  • Library collection list
  • Library material type list
  • Library theme editor
Reports



Use this tab to run reports on your library data.
  • Report.
  • Labels.
ToDo List

- customize for a library like the Springfield Public Library
- import more MARC records to make it realistic
- integrate with Joomla!

1 comment:

gnickers said...

one last task - delete the htdocs\openbiblio\install folder