Monday, October 7, 2024

Install DSpace 8 on Ubuntu 24.04 LTS

Here, we use Xubuntu 24.04 LTS to install DSpace 8. Xubuntu 24.04 LTS loaded with Snap, which makes the system slow. In such cases, choose snapless Ubuntu-based Linux operating systems like Linux Lite / Rhino LinuxAsmi Linux.

Prepare the system for Dspace installation.

DSpace consists of both a Java-based backend and an Angular-based front end. Both the backend and front end need to be installed separately. Install the prerequisites for the DSpace software. Dspace builds on the Java platform and requires software packages like Tomcat, Solr, Maven, Ant, etc.

Update the operating system.

Apply the following commands one by one to receive new updates. It makes the system new.

sudo apt update && sudo apt upgrade -y

Create a DSpace user from the terminal after the installation. Here are the commands to create the DSpace user;

sudo useradd -m dspace
sudo passwd dspace

[enter a password for the new user dspace]

Add dspace user to sudoers group

sudo usermod -aG sudo dspace 

Create the directory for the DSpace installation.

sudo mkdir /dspace

Change the dspace folder permission to the dspace user.

sudo chown dspace /dspace

Build the Installation Package

Install packages to support the Dspace installation.

sudo apt install wget curl git build-essential mousepad zip unzip -y

Install Open JDK

The JDK is a development environment for building applications, applets, and components using the Java programming language. JDK prepares an environment to run Java-based applications on the machine.

sudo apt install openjdk-17-jdk -y

Set the JAVA_HOME Environment Variable

DSpace requires the Java installation location. Open the following file to add the java environment variable,

sudo mousepad /etc/environment

Add the following two lines to the file,

JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
JAVA_OPTS="-Xmx512M -Xms64M -Dfile.encoding=UTF-8"

Save and close the file.

Apply the following commands one by one to check Java Home is successfully saved,

source /etc/environment
echo $JAVA_HOME
echo $JAVA_OPTS

Install Maven and Ant

Apache Maven requires for the build process during the Dspace installation. Maven helps to download the dependencies. Maven is used to build the installer. Ant used to install/deploy DSpace to the installation directory

sudo apt install maven ant -y

Install PostgreSQL

PostgreSQL, also known as Postgres, is a free and open-source relational database management system. Dspace makes use of PostgreSQL as a Relational Database System. Apply the following command to install PostreSQL and related packages;

sudo apt-get install postgresql postgresql-client postgresql-contrib libpostgresql-jdbc-java -y

Apply the following command to check the PostgreSQL version number. 

psql -V psql

Check whether the installation of PostgreSQL is successful or not,

sudo pg_ctlcluster 16 main start
sudo systemctl status postgresql

Apply the key, CTRL C, to exit from the screen.

Create a password for PostgreSQL.

sudo passwd postgres

Try to login into PostgreSQL using the password created.

su postgres

The command prompt looks like this postgres@user: if you could log in successfully. apply the following command to exit from there,

exit

Open the following file,

sudo mousepad /etc/postgresql/16/main/postgresql.conf

Uncomment the line (remove #) listen_addresses = 'localhost' under the connection settings option.

Save and exit

We need to tighten the security of PostgreSQL. Open the following file,

sudo mousepad /etc/postgresql/16/main/pg_hba.conf

Find the line, # Database administrative login by Unix domain socket.

Add the following lines below it,

#DSpace configuration
host dspace dspace 127.0.0.1 255.255.255.255 md5

Restart Postresql

sudo systemctl restart postgresql

Solr Installation

Solr is an open-source search platform, written in Java. Its major features include full-text search, hit highlighting, faceted search, real-time indexing, dynamic clustering, database integration, NoSQL features, and rich document handling.

Download the Solr software package from the website and save it to the opt folder in the operating system. 

Enter into the home folder. Apply the following command,

cd

Download the Solr (version 8) package using the following command line,

sudo wget https://downloads.apache.org/lucene/solr/8.11.4/solr-8.11.4.zip

Unzip the package,

sudo unzip solr-8.11.4.zip

Apply the following command to install Solr,

sudo bash solr-8.11.4/bin/install_solr_service.sh solr-8.11.4.zip

After successful installation, exit from the process. Apply the key combination,

Ctl + C

Apply the following commands one by one to start automatically upon system boot.

sudo systemctl enable solr
sudo systemctl start solr
sudo systemctl status solr

Apply CTRL + C key combination to exit from Solr status in Terminal.

Add the URL on a browser to open the Solr interface,

http://localhost:8983/solr

Download the DSpace package

Create a temporary folder with the name build in the root folder (/)to store the DSpace package,

sudo mkdir /build

Download the DSpace package. Enter into the /build directory.

cd /build

Download the DSpace 8 package into /build folder.

sudo wget https://github.com/DSpace/DSpace/archive/refs/tags/dspace-8.0.zip

Extract the package,

sudo unzip dspace-8.0.zip

Change the permission of the /build folder.

sudo chmod 777 -R /build

Install Tomcat

Tomcat provides a "pure Java" HTTP web server environment where Java code can run. 

sudo apt install tomcat10 -y

Specify the DSpace installation path to Tomcat. Open the following file,

sudo mousepad /lib/systemd/system/tomcat10.service

Find the category, #Security,

Add the following line at the last portion,

ReadWritePaths=/dspace

Save and close the file.

Alter Tomcat's default configuration to support searching and browsing of multi-byte UTF-8.

Open the following file,

sudo mousepad /etc/tomcat10/server.xml

Find the below-mentioned lines in the file, and comment out. Add  <!-- in the first line and --> in the last line,

<Connector port="8080" protocol="HTTP/1.1"
            connectionTimeout="20000"
            redirectPort="8443" />

It will look like this after commented out,

<!-- <Connector port="8080" protocol="HTTP/1.1"
            connectionTimeout="20000"
            redirectPort="8443" /> -->

Add the following lines below the commented-out lines,

<Connector port="8080" protocol="HTTP/1.1"
minSpareThreads="25"
enableLookups="false"
redirectPort="8443"
connectionTimeout="20000"
disableUploadTimeout="true"
URIEncoding="UTF-8"/>
Save and close the file.
Restart Tomcat,

sudo systemctl restart tomcat10.service

If it shows the following message,

Warning: The unit file, source configuration file or drop-ins of tomcat9.service changed on disk. Run 'systemctl daemon-reload to reload units.

Apply the following command,

sudo systemctl daemon-reload

Again try to restart the Tomcat,

sudo systemctl restart tomcat10.service

Database setup

Create a DSpace user. Apply the following commands one by one,
Login into the Postgres terminal,

sudo su postgres

Enter the following directory.

cd /etc/postgresql/16/main

Create the user named dspace. Enter the password when it asks. This is the connection password for the DSpace database; note it down. 

createuser --username=postgres --no-superuser --pwprompt dspace

This command will create the database with the name dspace. The database owner is dspace, the user created in the previous command.

createdb --username=postgres --owner=dspace --encoding=UNICODE dspace

Enable pgcrypto extension. 

The pgcrypto module provides cryptographic functions for PostgreSQL. It secures data from the security breach.

psql --username=postgres dspace -c "CREATE EXTENSION pgcrypto;"

Exit from the Postgres terminal,

exit

Create a new DSpace configuration fil.

Enter into the folder,
cd /build/DSpace-dspace-8.0/dspace/config
 
Make a copy of the local.cfg file,
sudo cp local.cfg.EXAMPLE local.cfg
 
Open the local.cfg file,
sudo mousepad local.cfg

See the essential lines in the file and their purpose. Give IP address or domain name instead of localhost.

DSpace server URL
dspace.server.url = http://localhost:8080/server

DSpace frontend URL
dspace.ui.url = http://localhost:4000

# Name of the site
dspace.name = DSpace at My University

If any changes in the DSpace database username/password, mention them here.

# Database username and password
db.username = dspace
db.password = dspace

Uncomment the following line in the local.cfg file,

solr.server = http://localhost:8983/solr

Save and close the file.

Installation of DSpace backend

Login as the Root user,

sudo su
 
Enter into the DSpace package downloaded in /build folder.

cd /build/DSpace-dspace-8.0
 
Download the dependencies and the required packages to build DSpace,
mvn package

The package-building process depends on the Internet speed and server responses and it may take 10 to 20 minutes to finish. 

Install DSpace Backend

Enter into the folder where DSpace installer located and install,
cd dspace/target/dspace-installer
 
Install the DSpace package,
ant fresh_install

After successful install, exit from sudo user, apply the following command,

exit

Copy the DSpace web apps folder to the Tomcat server,

sudo cp -R /dspace/webapps/* /var/lib/tomcat10/webapps
 
Copy DSpace Solr folders into the default home of Solr (/var/solr/data),
sudo cp -R /dspace/solr/* /var/solr/data

Change the permission of the folder. 
sudo chown -R solr:solr /var/solr/data

Restart Solr

sudo systemctl restart solr

Open the Solr on the browser using the URL, http://localhost:8983 and check the Core Selector is available on the Left side of the screen.

Initialize the Database. 
Enter into the below mentioned folder and apply the migration command.

cd /dspace/bin/
sudo ./dspace database migrate

Create a DSpace Administrator Account

sudo /dspace/bin/dspace create-administrator

This process will ask questions,

Creating an initial administrator account
E-mail address: e.g. dspace@localhost
First name: e.g. DSpace
Last name: e.g. MGU
Is the above data correct? (y or n): y
Password will not display on screen.
Password: Enter the password to login DSpace.
Again to confirm: Confirm the password again.
Administrator account created

Change permission of DSpace to Tomcat user

sudo chown -R tomcat:tomcat /dspace/
sudo systemctl restart tomcat10.service

Now Open a Browser and test whether the below pages are displaying correctly or not.
Open the REST API Interface at,

Try to open OAI-PMH Interface,

http://localhost:8080/server/oai/request?verb=Identify 

Install the Front End

To install the front required to install Node.js, Yarn, and DSpace-Angular packages.

Install Node.js

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment.

sudo apt install nodejs -y

Install npm

sudo apt install npm

Install Yarn

Yarn is a software packaging system.

sudo npm install --global yarn
sudo npm install --global pm2
 

Front end installation

DSpace user interfaces build on Angular. Angular is a TypeScript-based free and open-source web application framework. Follow the steps to install Dspace-Angular.

We are going to place the dspace-angular package into dspace home folder. Enter it into the folder;

sudo su
cd /home/dspace

Download the dspace-angular package,

sudo wget https://github.com/DSpace/dspace-angular/archive/refs/tags/dspace-8.0.zip

Extract the package,
unzip dspace-8.0.zip
 
Remove the dspace zip package,

rm dspace-8.0.zip

Enter into the dspace-angular folder, 

cd /home/dspace/dspace-angular-dspace-8.0

Install all dependencies,

yarn install

Enter into the /dspace-angular/config folder,

cd config

Copy and rename the following file,

cp config.example.yml config.prod.yml

Open the config file

mousepad config.prod.yml

Find the block of information related REST API server settings.  

Make changes like this,

# The REST API server settings
# NOTE: these settings define which (publicly available) REST API to use. They are usually
# 'synced' with the 'dspace.server.url' setting in your backend's local.cfg.
rest:
  ssl: false
  host: localhost
  port: 8080

Save and close the file.

Run the command,

yarn run build:prod
exit

If this operation fails, add more RAM to your machine and try again. I recommend a capacity of at least 5-6 GB of RAM.

Startup the User Interface

Create a PM2 JSON configuration file. 
Create the file,

sudo mousepad /home/dspace/dspace-angular-dspace-8.0/dspace-ui.json

Copy the following content into the dspace-ui.jason file,

{
    "apps": [
        {
           "name": "dspace-ui",
           "cwd": "/home/dspace/dspace-angular-dspace-8.0/",
           "script": "dist/server/main.js",
           "instances": "max",
           "exec_mode": "cluster",
           "env": {
              "NODE_ENV": "production"
           }
        }
    ]
}

Start the application using PM2. Apply the following command to start the service,

sudo su
pm2 start /home/dspace/dspace-angular-dspace-8.0/dspace-ui.json

Create a cronjob entry at the ROOT user to autostart dspace-ui.json. Login as a ROOT user. Apply the following commands,

crontab -e

Add the following line

#Auto start dspace-angular
@reboot bash -ci 'pm2 start /home/dspace/dspace-angular-dspace-8.0/dspace-ui.json'

To save the file, apply CTRL + O key combination. Exit from the editor and apply CTRL + X.

Enter the below URL on the browser to start the DSpace front end,

http://localhost:4000

You may also want to install/configure pm2-logrotate to ensure that PM2's log folder doesn't fill up over time.

pm2 install pm2-logrotate
pm2 set pm2-logrotate:max_size 1000K
pm2 set pm2-logrotate:compress true
pm2 set pm2-logrotate:rotateInterval 0 0 19 1 1 7

Build directory no longer required after the installation of DSpace; remove it. Apply the following command;

sudo rm -rf /build

Restart the computer and check the Solr, Tomcat, and DSpace works.

Express my sincere thanks to the contributors; Matúš Formanek (KMKD FHV University, Slovakia), Jeremiah Kellogg (Library Faculty, Systems, Eastern Oregon University), Anoop P.A. (Technical Assistant, Kerala Institute Of Local Administration), and Mahesh Palamuttath (Librarian, East Campus, Sacred Heart College, Thevara, Ernakulam). 

References

No comments:

Post a Comment