Tuesday, January 16, 2024

Change the text at DSpace 7 home page


Frontpage template available at [dspace-angular-frontend]\src\themes\dspace\app\home-page\home-news\home-news.component.html. The location of the dspace-angular-dspace may vary.

Open the template file using a text editor like Nano, e.g.

sudo nano /home/dspace/dspace-angular-dspace-7.6.1/src/themes/dspace/app/home-page/home-news/home-news.component.html 

Rebuild the production environment to take effect the changes.

Enter the location of the dspace-angular-dspace. Find the exact location of the [dspace-angular-frontend] and apply the following command. Here is an example of the command,

cd /home/dspace/dspace-angular-dspace-7.6.1/config

Apply the following command

yarn run build:prod

Refresh the home page of DSpace to see the changes made.

Thursday, February 23, 2023

Automate DSpace backups with Cron Task

Database backup

Open a Terminal and log in as a Postgres user,

sudo su - postgres

Create a directory in the Postgres user’s home to store the backups. Apply the following command,

mkdir -p ~/backups

Enter into the crontab:

crontab -e

Add the following entry into the Cron,

#DSpace Postgres backup

10 20 * * * pg_dump -U postgres dbname > ~/postgres/backups/dbname-$(date +%d-%m-%Y-%H.%M).bak

Change the timing of the backup, here backup take at 8:10 PM

Apply  CTRL + O button to save the cron entry.
Then apply CTRL + X to exit from the cron. 

Type exit to exit from Postgres prompt.

Backup of asset store and log folders


Open a terminal and apply the following command to create a folder in Home to hold asset store and log folders.

sudo mkdir dspacebkup

Open crontab to add the entry to automate the folder backup,
sudo su
crontab -e

Add the following lines,

10 20 * * * zip -r /home/vimal/dspacebkup/assetstore-$(date +%d-%m-%Y-%H.%M).zip /dspace/assetstore
10 20 * * * zip -r /home/vimal/dspacebkup/log-$(date +%d-%m-%Y-%H.%M).zip /dspace/log

Change the path based on your local setup.

Saturday, February 4, 2023

Error 500-Service unavailable: how to solve

Many DSpace users got Error 500. To solve the error, check the following things one by one.

Solr

Apply the following commands to restart Solr.

su dspace
/opt/solr/bin/solr start
exit

Tomcat

Apply the following command restart Tomcat

sudo systemctl restart tomcat9.service

Start the user interface

Apply the following commands,

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

Make available DSpace 7 in a local network / web

DSpace 7 default port for the front end is 4000. The port needs to open to make DSpace available in a local network. I applied this method on Ubuntu 22.04 and Debian 11. Here are the processes to make available DSpace 7 in the network. 

Open the Port 4000

ufw is the default firewall configuration tool. Install ufw by applying the following command,
 
sudo apt install ufw
 
Apply the following command to open port 4000.

sudo ufw allow 4000
sudo ufw enable 

Network configuration for DSpace

Find the IP address of the computer where DSpace is installed. Apply the following commands to install net-tools software in Ubuntu and know the network details.
 
sudo apt install net-tools 
ifconfig 

Debian users can apply the following command to know the network details,

nmcli -p device show

Note down the details and add the IP address. 
Open the DSpace configuration file, 

sudo mousepad /dspace/config/local.cfg 

Find the following lines and add the IP address/domain name instead of localhost.

dspace.ui.url = http://localhost:4000 
dspace.server.url = http://localhost:8080/server 

Save and close the file. 
Open the following configuration file (make sure the location of the file in your server) of the DSpace front end, 

sudo mousepad /home/dspace/dspace-angular-dspace-7.6.1/config/config.prod.yml

Find the following piece of lines, 

ssl: false 
host: localhost 
port: 4000 

Change the hostname. Change localhost to the IP address / domain name.

ssl: false 
host: your-ip-address
port: 4000 

Find the following portion and add the IP address instead of localhost,
 
# 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
  # NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
  nameSpace: /server


Save and close the file.

Open the following file (make sure the location of the file in your server) and add the IP address there,

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

Find the line,

"DSPACE_REST_HOST": "localhost",

Change localhost to the IP address. Save and close the file.
 
Restart PC. Try to load DSpace 7 from other PC in the network. Example, http://192.168.1.20:4000


References

Monday, December 12, 2022

Upgrading DSpace 6 to 7

Take a backup of the DSpace 6 database and folders

Open a Terminal and apply the following commands,

sudo su - postgres
pg_dump dspace > dspace.backup


The above command takes a backup of the DSpace database and stores in /var/lib/postgresql. Copy the database.backup file to a safe place.

Saturday, December 3, 2022

Install DSpace 7 on Debian 11 / Ubuntu 22.04 LTS

We use Debian 11 (Bull Eye) Xubuntu 22.04 LTS to install DSpace 7. ISO file of Debian 11 can be downloaded from the link (I prefer Debian with MATE desktop). Xubuntu 22.04 can be downloaded from here. Users who feel challenged to use barebone Debian can also try Dbebian-based Linux operating systems like Pepper Mint OSEither burn the ISO file to a pen drive or DVD. Install Debian 11 on the machine. Create a user account during the installation (e.g. mgu). Create the user with the name dspace after installing the Linux-based operating system. If you have already run on Ubuntu/Debian (e.g. for Koha), create a dspace user.

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-11-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-11-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

The version number of PostgreSQL varies in Ubuntu 22.04 and Debian 11. PostgreSQL 14 is available with Ubuntu 22.04, and PostgreSQL 13 is available with Debian 11. Check whether the installation of PostgreSQL is successful or not,

For Ubuntu 22.04 LTS users

sudo pg_ctlcluster 14 main start
sudo systemctl status postgresql

For Debian 11 users

sudo pg_ctlcluster 13 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,

For Ubuntu 22.04 LTS users

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

For Debian 11 users

sudo mousepad /etc/postgresql/13/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,

For Ubuntu 22.04 LTS users

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

For Debian 11 users

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

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

Add the below lines above the line,

#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://dlcdn.apache.org/lucene/solr/8.11.3/solr-8.11.3.zip

Unzip the package,

sudo unzip solr-8.11.3.zip

Apply the following command to install Solr,

sudo bash solr-8.11.3/bin/install_solr_service.sh solr-8.11.3.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 package into /build folder.

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

Extract the package,

sudo unzip dspace-7.6.1.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 tomcat9 -y

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

sudo mousepad /lib/systemd/system/tomcat9.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/tomcat9/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 tomcat9.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 tomcat9.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. If there are any changes in the version number, add them.

Ubuntu users apply the following command,

cd /etc/postgresql/14/main

Debian users apply the following command,

cd /etc/postgresql/13/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-7.6.1/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-7.6.1
 
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/tomcat9/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 tomcat9.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  npm -y

Install NVM

Node Version Manager (NVM) is a tool used to manage multiple active Node. js versions. Apply the commands one by one.

sudo su

curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

Close the current terminal and open a new one and the following commands to install the Node.js.

sudo su

nvm install 16.18.1

Install Yarn

Yarn is a software packaging system.

npm install --global yarn
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;

cd /home/dspace

Download the dspace-angular package,

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

Extract the package,

unzip dspace-7.6.1.zip
 
Remove the dspace zip package,

rm dspace-7.6.1.zip

Enter into the dspace-angular folder, 

cd /home/dspace/dspace-angular-dspace-7.6.1

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 and find the lines.  Make changes like this,

ssl: true -> false
host:  api7.dspace.org -> localhost
Port: Change to 8080

# The REST API server settings
# NOTE: these must be '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
 

Startup the User Interface

Create a PM2 JSON configuration file. 
Create the file,

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

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

{
    "apps": [
        {
           "name": "dspace-ui",
           "cwd": "/home/dspace/dspace-angular-dspace-7.6.1/",
           "script": "dist/server/main.js",
           "instances": 4
           "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-7.6.1/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-7.6.1/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; 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

Thursday, July 28, 2022

Install DSpace 6.3 on Ubuntu 20.04

We use Xubuntu 20.04 LTS for the installation of DSpace 6. ISO file of the operating system can be downloaded from the Xubuntu website, https://xubuntu.org/release/20-04. No problem using other Ubuntu flavors (e.g. Ubuntu with GNOME, KDE, Lubuntu) for the installation. Either burn the ISO file to a pen drive or DVD. Install the Xubuntu on the machine. Create a user account during the installation (e.g. mgu). Create the user with the name dspace after the installation of Linux based operating system. If you have already run on Ubuntu/Debian (e.g. for Koha), create a dspace user.

Prepare the system for Dspace installation.

DSpace builds on the Java platform and it requires a set of software packages like Tomcat, Solr, Maven, Ant, etc. Install the prerequisites for the Dspace software.