Installing DSpace on Red Hat Enterprise Linux 5

From DSpace Wiki

Jump to: navigation, search


Contents

[edit] DSpace 1.4.x

The aim of this method of installing DSpace is to minimise the maintenance burden on the system administrator by using Red Hat-supplied packages where possible. This includes making use of the RHEL 5 Supplementary channel for the Sun Java 1.5.0 package.


[edit] Install the prerequisite Red Hat packages

  • Make sure your system is subscribed to the Supplementary channel.
  • Install all the required packages that can be obtained from Red Hat
    • ant
    • ant-apache-regexp
    • httpd
    • java-1.5.0-sun-devel
    • postgresql-server
    • postgresql-jdbc


yum -y install ant ant-apache-regexp httpd java-1.5.0-sun-devel postgresql-server postgresql-jdbc

[edit] Create a DSpace User

Create a unix account for the dspace process.

useradd dspace

There's no need to give it login ability.

[edit] Tomcat 5.5

Unfortunately, the version of Tomcat 5 that is packaged with RHEL5 does not work cleanly with the proprietary Javas (including Sun's). Fortunately, the binary distribution of Tomcat 5.5 that you can download from the Tomcat website installs and runs cleanly.

[edit] Download

Grab the tarball of the Core version of Tomcat 5.5 download site and put it in /tmp directory.


[edit] Install

Change to the dspace user, copy it to the dspace user's home directory and extract it.

[privuser@dhost ~]$ sudo su - dspace
[dspace@dhost ~]$ cp /tmp/apache-tomcat-5.5.26.tar.gz ./
[dspace@dhost ~]$ tar zxf apache-tomcat-5.5.26.tar.gz 
[dspace@dhost ~]$ exit
[privuser@dhost ~]$ 

As root, move the extracted apache-tomcat-5.5.x directory to /usr/local/

[privuser@dhost ~]$ sudo mv /home/dspace/apache-tomcat-5.5.26 /usr/local/
[privuser@dhost ~]$

Create a symlink from /usr/local/tomcat to this directory.

[privuser@dhost ~]$ sudo ln -s /usr/local/apache-tomcat-5.5.26 /usr/local/tomcat
[privuser@dhost ~]$

[edit] Set up the Enviroment Variables

Create the file /etc/profile.d/dspace.sh and set required the environment variables in it. Using a separate profile.d file is neater than modifying the /etc/profile file directly.

#!/bin/bash

export CATALINA_HOME=/usr/local/tomcat
export CATALINA_BASE=/usr/local/tomcat
export CATALINA_TMPDIR=/usr/local/tomcat/temp
if [ `/bin/arch` = "x86_64" ]; then
        XARCH=".x86_64"
fi
export JRE_HOME=/usr/lib/jvm/jre-1.5.0-sun${XARCH}
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun${XARCH}

[edit] Install init.d Script

Create /etc/rc.d/init.d/dspace with the following contents:

#!/bin/bash
###########################################################
# chkconfig: 345 80 20                                    #
# Description: This is an init.d script for dspace/tomcat #
###########################################################

# set environment

[ -n "${TOMCAT_USER}" ] || export TOMCAT_USER=dspace
[ -n "${CATALINA_BASE}" ] || export CATALINA_BASE=/usr/local/tomcat
[ -n "${CATALINA_HOME}" ] || export CATALINA_HOME=/usr/local/tomcat
[ -n "${CATALINA_TMPDIR}" ] || export CATALINA_TMPDIR=/usr/local/tomcat/temp
# Need to specify a different java path if we're x86_64
if [ `/bin/arch` = "x86_64" ]; then
        XARCH=".x86_64"
fi
[ -n "${JAVA_HOME}" ] || export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun${XARCH}
[ -n "${JRE_HOME}" ] || export JRE_HOME=/usr/lib/jvm/jre-1.5.0-sun${XARCH}
export JAVA_OPTS="-Xmx800m -Xms800m -Dcatalina.base=$CATALINA_BASE"

GREP_STRING="dspace"

PROG=$(basename $0)

# For SELinux we need to use 'runuser' not 'su'
if [ -x "/sbin/runuser" ]; then
    SU="/sbin/runuser"
else
    SU="su"
fi

stop() {
        echo "Stopping tomcat instance $PROG..."
        $CATALINA_HOME/bin/catalina.sh stop
        echo "Done."
}

status() {
        PID=`ps -ef | grep catalina.start | grep ${GREP_STRING} | awk '!/grep/ {
print $2}'`
        if [[ -n "$PID" ]]; then
                echo $"${PROG} is running (pid $PID)."
        else
                echo $"${PROG} is not running..."
                echo ""
        fi
}


start() {
        echo "Starting tomcat instance $PROG..."
        ${SU} -m ${TOMCAT_USER} -c "$CATALINA_HOME/bin/catalina.sh start"
        echo "Done."
}

restart() {
        stop
        echo "Pausing 15 seconds before restarting."
        sleep 15
        start
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                restart
                ;;
        status)
                status
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|status}"
                exit 1
esac

exit $?

The permissions on /etc/rc.d/init.d/dspace should be 755. Once you've created the file, you can check that it works by starting, stopping, querying status etc. E.g.

sudo /sbin/service dspace start

If it's all working you can get it to start up at boot time using the chkconfig system. First, add it to the chkconfig system.

sudo /sbin/chkconfig --add dspace

Then get it to start up automatically

sudo /sbin/chkconfig dspace on

[edit] Set up the Database

If the postgresql server has never been started before, make sure to start it so that all the default configuration files get created.

/sbin/service postgresql start

Edit /var/lib/pgsql/data/pg_hba.conf and ensure that this is the first authentication line that is uncommented.

host  dspace  dspace  127.0.0.1/32  trust

N.B. this is good for testing, but tighten up the method for production (e.g. replace "trust" with "md5")

Set PostGreSQL server to start up when the server boots.

/sbin/chkconfig postgresql on

If you haven't already started postgresql in a previous step, then start the server.

/sbin/service postgresql start

Create the dspace postgresql user (need to be postgres user):

# su -l postgres
$ createuser -U postgres -d -A -P dspace
Enter password for new role:
Enter it again:
Shall the new role be allowed to create more new roles? (y/n) n
CREATE ROLE
$

Create the dspace database (need to be dspace unix user):

# su -l dspace
$
$ createdb -U dspace -E UNICODE -T template0 dspace
CREATE DATABASE
$

[edit] Build and Install DSpace

(See also the detailed instructions.)

Download the latest (stable) release of DSpace and put it in /home/dspace/.

Most of the following steps should be done as the dspace user. Keep an eye out for exceptions.

Extract the tarball (e.g. if you got the bzip2ed version):

tar -jxvf dspace-1.4.2-source.tbz2

Copy the PostGreSQL jdbc into the source tree:

cp /usr/share/java/postgresql-jdbc3.jar dspace-1.4.2-source/lib/postgresql.jar

Edit the dspace.cfg (in the config directory of the source tree). Things you probably should customise:

  • dspace.dir
  • dspace.url
  • dspace.hostname
  • dspace.name
  • db.password
  • mail.server
  • mail.from.address
  • feedback.recipient
  • mail.admin
  • alert.recipient

Make sure that the directory defined in dspace.dir exists and is owned by and writable by the dspace user. The same goes for any other directory such as assetstore.dir if you customised that. For this example, we define our dspace.dir as /data/dspace, so as root we create this directory and change ownership:

mkdir -p /data/dspace
chown dspace:dspace /data/dspace

Now, back as the dspace user, change to the source directory

cd dspace-1.4.2-source

Build the war files

ant fresh_install

you will see a whole bunch of output, which should finish off with some instructions as well as something like this:

BUILD SUCCESSFUL
Total time: 28 seconds

Copy the resultant war files to the tomcat webapps directory

cp -Rpv build/*.war /usr/local/tomcat/webapps/

Create the initial DSpace administrator

/data/dspace/bin/create-administrator


Make DSpace the root webapp, by symlinking ROOT to the dspace directory. N.B. the dspace directory will only be created from the dspace.war file the first time tomcat is started, but Unix lets you create symlinks to files that don't exist. As root:

ln -s /usr/local/tomcat/webapps/dspace /usr/local/tomcat/webapps/ROOT

Start up dspace. As root:

/sbin/service dspace start

You should now be able to see DSpace running as the root application on port 8080 of your host, e.g. http://www.example.com:8080/

[edit] Set Up mod_proxy_ajp

You've got tomcat running, by default it will also be listening on the AJP port, so you can use Apache httpd to act as the point of entry for your site.

Edit /etc/httpd/conf.d/proxy_ajp.conf and add this to it:

ProxyPass               /               ajp://localhost:8009/


Start up httpd

/sbin/service httpd start

Check your site, e.g. go to http://www.example.com/ with your browser.

Set up httpd to start up automatically when the server boots

/sbin/chkconfig httpd on

[edit] To Do

  • directory structure suggestions
  • security improvements
    • PostGreSQL
    • File ownership
    • SELinux
Personal tools