Wednesday, May 16, 2012

Installing Dspace on GSDLKoha LiveCD Powered by Lubuntu 11.04

After testing the GSDLKoha LiveCD, I decided to install it in our development server - HP Proliant DL380 G7.

I am happy with it because it runs lots of library application software that I am testing and evaluating. However it lacks DSpace. I don't want to run and maintain two development servers, so I decided to install DSpace in this GSDLKoha instance.

The GSDLKoha LiveCd is running on Lubuntu 11.04 (Ubuntu variant using LXDE), so I followed the installation notes in the DuraSpace wiki on Installing DSpace 1.7.2 on Ubuntu. https://wiki.duraspace.org/display/DSPACE/Installing+DSpace+1.7+on+Ubuntu

The following is a modified version of that installation to address the bumps and mishaps along the way.

Installing Dspace on GSDLKoha LiveCD


Install the server stack of Tomcat (web server) and PostgreSQL (database)

sudo apt-get install tasksel

sudo tasksel

    Select the following packages (select and click spacebar)
    [*] PostgreSQL database
    [*] Tomcat Java server

Install the Compile / Build tools
sudo apt-get install ant maven2

Create the database user (dspace)

sudo su postgres
createuser -U postgres -d -A -P dspace
exit

Allow the database user (dspace) to connect to the database

sudo vi /etc/postgresql/9.1/main/pg_hba.conf

# Add this line to the configuration:
 local all dspace md5

sudo service postgresql restart

Create the dspace database

createdb -U dspace -E UNICODE dspace

Configure Tomcat to know about the DSpace webapps.
sudo vi /etc/tomcat6/server.xml

# Insert the following chunk of text just above the closing </Host>

<!-- Define a new context path for all DSpace web apps -->
<Context path="/xmlui" docBase="/dspace/webapps/xmlui" allowLinking="true"/>
<Context path="/sword" docBase="/dspace/webapps/sword" allowLinking="true"/>
<Context path="/oai"   docBase="/dspace/webapps/oai"   allowLinking="true"/>
<Context path="/jspui" docBase="/dspace/webapps/jspui" allowLinking="true"/>
<Context path="/lni"   docBase="/dspace/webapps/lni"   allowLinking="true"/>
<Context path="/solr"  docBase="/dspace/webapps/solr"  allowLinking="true"/>

Download and Install DSpace

Create the [dspace] directory.The [dspace] directory is where the running dspace code will reside.
sudo mkdir /dspace

Change the ownership and permissions of the [dspace] directory from the Ubuntu user (currently logged in) to the Tomcat user created by the installation process using taskskel.
To know/set/change the default tomcat user sudo vi /etc/tomcat6/tomcat-users.xml
chown -R <Ubuntu-user>:<tomcat-user> /dspace
chmod -R 775 /dspace

Download the Source Release
The source release allows you to customize every aspect of DSpace. This step downloads the compressed archive from SourceForge, and unpacks it in your current directory. The dspace-1.x.x-src-release directory is typically referred to as [dspace-src].

cd /dspace
wget http://sourceforge.net/projects/dspace/files/DSpace%20Stable/1.8.2/dspace-1.8.2-src-release.tar.bz2
tar -xvjf dspace-1.8.2-src-release.tar.bz2

edit DSpace configuration particularly the database user and password before compiling. You can also make other changes (email, port number ...)

sudo vi /dspace/config/dspace.cfg

##### Basic information ######

# DSpace installation directory
dspace.dir = /dspace

# DSpace host name - should match base URL.  Do not include port number
dspace.hostname = localhost

# DSpace base host URL.  Include port number etc.
dspace.baseUrl = http://localhost:8080

# DSpace base URL.  Include port number etc., but NOT trailing slash
# Change to xmlui if you wish to use the xmlui as the default, or remove
# "/jspui" and set webapp of your choice as the "ROOT" webapp in
# the servlet engine.
dspace.url = ${dspace.baseUrl}/xmlui

# Name of the site
dspace.name = DSpace at My University (name or Title of Your Repository)

##### Database settings #####

# Database name ("oracle", or "postgres")
db.name = postgres
#db.name = postgres
#db.name = oracle

# URL for connecting to database
db.url = jdbc:postgresql://localhost:5432/dspace
#db.url = jdbc:postgresql://localhost:5432/dspace

# JDBC Driver
db.driver = org.postgresql.Driver
#db.driver = org.postgresql.Driver

# Database username and password
db.username = dspace
db.password = (password you gave to dspace [database user])
#db.username = dspace
#db.password = dspace

Compile and Build DSpace

The source release that has been obtained is human readable source code, and must be compiled to machine code for the server to run it. "mvn package" compiles the source code, and "ant" will do all the work necessary to initialize the database with the DSpace schema, and copy all of the compiled machine code to a location where the web server can serve it.    ant fresh_install will populate the dspace database and [dspace] directory with new information. This will overwrite any existing installation of DSpace that you may have. For upgrades the better command to use would be ant update, as it doesn't alter the database or modify your assetstore.

cd dspace-1.8.2-src-release
mvn -U -e package (-e will show errors if there are any)

I encountered three errors that I have to fix before it can compile. There were files reported missing.
1) org.apache.zookeeper:zookeeper:jar:3.3.1
2) org.codehaus.woodstox:wstx-asl:jar:3.2.7
I tried downloading it from their website and installed it manually. It didn't work, I guess because of version incompatibilty. Apache zookeeper 3.3.1 is no longer avaiable on the website so I used another version, which resulted reading /compilation error during build.

I solved this by searching and downloading the files from a Maven repository http://mvnrepository.com/
wget http://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper/3.3.1/zookeeper-3.3.1.jar
wget http://repo1.maven.org/maven2/org/codehaus/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.jar

Then I installed it using Maven (note that in my case the downloaded file is in /dspace) change the path-to-file to point it to the right directory if you placed the download in a different directory
mvn install:install-file -DgroupId=org.apache.zookeeper -DartifactId=zookeeper -Dversion=3.3.1 -Dpackaging=jar -Dfile=/dspace/zookeeper-3.3.1.jar
mvn install:install-file -DgroupId=org.codehaus.woodstox -DartifactId=wstx-asl -Dversion=3.2.7 -Dpackaging=jar -Dfile=/dspace/wstx-asl-3.2.9.jar

Run this code to  check for any unresolved dependency (found another one missing)
mvn dependency:list

Misssing file
1) com.yahoo.platform.yui:yuicompressor:jar:2.3.6

To resolve download manually and install
wget http://repo1.maven.org/maven2/com/yahoo/platform/yui/yuicompressor/2.3.6/yuicompressor-2.3.6.jar
mvn install:install-file -DgroupId=com.yahoo.platform.yui -DartifactId=yuicompressor -Dversion=2.3.6 -Dpackaging=jar -Dfile=/dspace/yuicompressor-2.3.6.jar

Compile using Maven
mvn -U -e package

if successful compile you would see this at the terminal
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20 minutes 25 seconds
[INFO] Finished at: Thu May 17 11:21:57 PHT 2012
[INFO] Final Memory: 163M/466M
[INFO] ------------------------------------------------------------------------

Build using Ant
cd dspace/target/dspace-1.8.2-build.dir
sudo ant fresh_install

if successful
[echo]  The DSpace code has been installed, and the database initialized.
     [echo]
     [echo]  To complete installation, you should do the following:
     [echo]
     [echo]  * Setup your Web servlet container (e.g. Tomcat) to look for your
     [echo]    DSpace web applications in: /dspace/webapps/
     [echo]
     [echo]    OR, copy any web applications from /dspace/webapps/ to
     [echo]    the appropriate place for your servlet container.
     [echo]    (e.g. '$CATALINA_HOME/webapps' for Tomcat)
     [echo]
     [echo]  * Make an initial administrator account (an e-person) in DSpace:
     [echo]
     [echo]    /dspace/bin/dspace create-administrator
     [echo]
     [echo]  * Start up your servlet container (Tomcat etc.)
     [echo]
     [echo]  You should then be able to access your DSpace's 'home page':
     [echo]
     [echo]    http://localhost:8080/xmlui
     [echo]
     [echo]  You should also be able to access the administrator UI:
     [echo]
     [echo]    http://localhost:8181/xmlui/dspace-admin
     [echo] ====================================================================
     [echo]        

BUILD SUCCESSFUL
Total time: 29 seconds

Restart the Tomcat server
This guide follows the convention where the tomcat user will own all of the files in [dspace], so we have to change the owner of the files to tomcat6. Restarting tomcat will deploy the dspace webapps that are now ready to be viewed.

sudo chown tomcat6:tomcat6 /dspace -R

sudo service tomcat6 restart

Test it out in your browser
That is all that is required to install DSpace on Ubuntu. There are two main webapps that provide a similar turn-key repository interface

http://localhost:8080/xmlui

http://localhost:8080/jspui

Create Administrator

cd /dspace/bin
sudo ./dspace create-administrator

(prompt would look like)
Creating an initial administrator account
E-mail address: <your email>
First name: <your name>
Last name: <last name>
WARNING: Password will appear on-screen.
Password: <your password>
Again to confirm: <your password>
Is the above data correct? (y or n): y
Administrator account created
***@***:/dspace/bin$

It is now time to tinker with the configuration and administration of my new Dspace 1.8.2. Next project creation of integrated GSDLKoha + DSpace LiveCD iso.

Fell free to comment or report any errors or difficulties in following this install guide.



2 comments:

  1. I am facing trouble with postgresql as i am newbie to it. While creating the database user (dspace), password prompt appear for new user..should it to be left blank or value can be kept??

    And while creating the dspace database i am getting this error msg following your steps above:
    "createdb: could not connect to database postgres: FATAL: Peer authentication failed for user "dspace"

    ReplyDelete
    Replies
    1. On question number 1 - you can leave it blank or give your own password, there is no default password so if you choose value can be kept then that also means blank

      On question number 2 - after configuring postgres pg_hba.conf did you restart postgres?

      sudo service postgresql restart

      did you follow the install guide in sequence? if you did and it did not work try

      sudo su postgres

      createdb -U dspace -E UNICODE dspace

      let me know if that works, thanks

      Delete