Thursday, November 21, 2024
Google search engine
HomeData Modelling & AIInstall DSpace 7 Repository on Ubuntu 20.04|18.04

Install DSpace 7 Repository on Ubuntu 20.04|18.04

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

Welcome to this guide on how to install and configure DSpace 7 Repository on Ubuntu 20.04|18.04. Dspace is a free and open-source tool used to effectively store, capture distribute and index diverse forms of digital content, such as text, audio, video, and more. It provides a user-friendly method of managing and safeguarding content, ensuring increased visibility and accessibility that can be sustained over long periods.

The DSpace Repository finds high use in institutions to provide access to research publications, library collections etc. It can be used to store digital material that includes: computer programs, Documents(such as articles, preprints, working papers, technical reports, and conference papers), Overlay journals, Published books, Administrative records, Video files, Audio files, e-formatted digital library collections, Web pages, Bibliographic datasets etc.

There are several features and benefits associated with DSpace 7 Repository, they include:

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

  • Unlimited File Types: The DSpace Repository can store any type of file with the most common formats such as DOC, PDF, XLS, PPT, JPEG, MPEG, and TIFF supported.
  • Built-in search engine: DSpace comes packaged with Apache Solr, an open-source enterprise search platform that enables filtered (faceted) searching and browsing of all objects.
  • Built-in workflows: Originally designed for libraries, the embedded DSpace data model and approval workflows are familiar to librarians and archivists.
  • Configurable Database: Organizations can choose either PostgreSQL or Oracle for the database in which DSpace manages items and metadata
  • Configurable File Storage: Files in DSpace can be stored either using a local filesystem (default) or a cloud-based solution, such as Amazon S3
  • Data Integrity: On upload, DSpace calculates and stores a checksum for each file. Also, you may ask DSpace to verify those checksums to validate the file
  • Languages: DSpace is available in over 20 languages.integrity
  • Modern, RESTful Web UI: DSpace 7.0 will feature a completely rewritten web user interface based on the Angular 2 javascript platform

By following this guide to the end, you should be able to install and configure DSpace 7 Repository on Ubuntu 20.04|18.04.

Getting Started

For this guide, you will require the following packages:

The Dspace backend installation requires packages that include:

  • Java JDK 11 or 17 (OpenJDK or Oracle JDK)
  • Apache Maven 3.3.x or above (Java build tool)
  • Apache Ant 1.10.x or later (Java build tool)
  • Relational Database (PostgreSQL or Oracle)
  • Apache Solr 8.x (full-text index/search service)
  • Node.js 12 and later
  • Servlet Engine (Apache Tomcat 9, Jetty, Caucho Resin or equivalent)
  • Git (code version control)

Step 1 – Create the Dspace User

We will begin by creating a dedicated user for Dspace on our system.

sudo adduser dspace

Add the user to the sudo group:

sudo usermod -aG sudo dspace

Now switch to the created user:

sudo su - dspace

Step 2 – Install Java Runtime

We will then install Java and make the required configurations. The easiest way of installing Java 11 on Ubuntu 20.04|18.04 is by executing the below commands:

sudo apt update -y
sudo apt-get install openjdk-11-jdk  vim

Once installed, verify with the commands:

$ java -version
openjdk version "11.0.19" 2023-04-18
OpenJDK Runtime Environment (build 11.0.19+7-post-Ubuntu-0ubuntu120.04.1)
OpenJDK 64-Bit Server VM (build 11.0.19+7-post-Ubuntu-0ubuntu120.04.1, mixed mode, sharing)

$ javac -version
javac 11.0.19

The next thing is to export the JAVA_HOME. Open the below file and add the lines:

$ vim ~/.bashrc
# [...]
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
export PATH=$PATH:$JAVA_HOME/bin

Save the changes and source the profile:

source ~/.bashrc

Now verify the made settings:

$ echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-11-openjdk-amd64/bin

Step 3 – Install and Configure PostgreSQL

Dspace uses PostgreSQL to store its data. Dspace has been tested on PostgreSQL 11, 12 and 13. For this guide, we will use PostgreSQL 13 which can be installed by following the guide below:

Ensure all the required packages have been installed:

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

Once installed, we will allow the host to access the PostgreSQL server:

echo "host dspace dspace 127.0.0.1/32 md5" | sudo tee -a /etc/postgresql/*/main/pg_hba.conf

We will also set several user permissions:

sudo sed -i 's/ident/trust/' /etc/postgresql/*/main/pg_hba.conf
sudo sed -i 's/md5/trust/' /etc/postgresql/*/main/pg_hba.conf
sudo sed -i 's/peer/trust/' /etc/postgresql/*/main/pg_hba.conf

After that, restart the PostgreSQL service:

sudo systemctl restart postgresql

Switch to the Postgres user:

sudo su postgres

Create a database user and database for DSpace:

createuser dspace
createdb dspace -E UNICODE

Now access the shell:

psql -d dspace

Create the pgcrypto extension:

CREATE EXTENSION pgcrypto;

Create the password for the user and assigned the required permissions:

ALTER ROLE dspace WITH PASSWORD 'Passw0rd';
ALTER DATABASE dspace OWNER TO dspace;
GRANT ALL PRIVILEGES ON DATABASE dspace TO dspace;

Exit the shell:

\q

Exit the Postgres user:

exit

Restart PostgreSQL:

sudo systemctl restart postgresql

Step 4 – Install Apache Solr 8

To install Apache Solr 8 on Ubuntu 20.04|18.04, you need to download it from the Apache Solr downloads page. You can also download it using the command line:

wget -c https://dlcdn.apache.org/lucene/solr/8.11.2/solr-8.11.2.tgz

Extract the file:

tar xvf solr-*.tgz

Install Apache Solr:

sudo bash solr-8.11.2/bin/install_solr_service.sh solr-8.11.2.tgz

A symbolic link is created in /opt/solr after this.

Step 5 – Install Tomcat 9

Tomcat is also one of the main requirements of DSpace. For this guide, we will install Apache Tomcat 9 which exists in the default Ubuntu 20.04|18.04 repositories:

sudo apt install tomcat9

Here, we need to define our JAVA_HOME and memory limits:

sudo vim /etc/default/tomcat9

In the file, make the below changes:

JAVA_OPTS="-Djava.awt.headless=true -Xmx2048m -Xms1024m -XX:MaxPermSize=1024m"
JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64

We also need to modify the below file:

sudo vim /etc/tomcat9/server.xml

Modify the lines below:

    <Connector port="8080" 
     minSpareThreads="25"
              enableLookups="false"
              redirectPort="8443"
              connectionTimeout="20000"
              disableUploadTimeout="true"
              URIEncoding="UTF-8"/>

Step 6 – Install Git, Maven and Ant

Maven is used to compile the Dspace 7 code, It also downloads all the required dependencies for Dspace. Ant on the other hand installs the compiled code.

To install them on Ubuntu, use the command:

sudo apt-get install ant ant-optional maven git -y

Verify the installation:

$ mvn -v
Apache Maven 3.6.3
Maven home: /usr/share/maven

$ ant -version
Apache Ant(TM) version 1.10.7 compiled on October 24 2019

Step 7 – Install DSpace 7 Backend

Proceed and download the latest version of DSpace Backend from the DSpace GitHub Repository. For this guide, we will use v7.2 which can be pulled with the command:

wget -c https://github.com/DSpace/DSpace/archive/refs/tags/dspace-7.2.1.tar.gz

Extract the archive:

tar -zxvf dspace-*.tar.gz

Rename the folder to a simpler name:

mv DSpace-dspace-* dspace-7-src

Now navigate to the directory:

cd dspace-7-src

Create a directory for the deployment:

sudo mkdir /opt/dspace-7

Set the ownership to the DSpace user:

sudo chown dspace:dspace -R /opt/dspace-7

Create a configuration file from the default available one:

cp dspace/config/local.cfg.EXAMPLE dspace/config/local.cfg

Modify this configuration file:

vim dspace/config/local.cfg

Make the below adjustments:

dspace.dir=/opt/dspace-7
dspace.server.url = http://YOUR-SERVER-IP:8080/server
dspace.ui.url = http://domain_name
dspace.name = DSpace at ComputingforGeeks
solr.server = http://localhost:8983/solr
db.url = jdbc:postgresql://localhost:5432/dspace
db.driver = org.postgresql.Driver
db.username = dspace
db.password = Passw0rd

Once the adjustments have been made, start building Dspace:

mvn package

Sample Output:

DSpace 7 Repository on Ubuntu 20.0418.04 1

Navigate to the created installer directory:

cd dspace/target/dspace-installer

Deploy the generated code:

ant fresh_install

Sample Output:

DSpace 7 Repository on Ubuntu 20.0418.04 2

Once complete, configure Tomcat9 to serve DSpace:

cd /var/lib/tomcat9/webapps
sudo ln -s /opt/dspace-7/webapps/server server

You also need to copy the configs to Solr:

sudo cp -r /opt/dspace-7/solr/* /opt/solr/server/solr/configsets

Restart Apache Solr:

sudo systemctl restart solr

Run database migrations:

cd /opt/dspace-7
./bin/dspace database migrate

Next we create admin user.

$ /opt/dspace-7/bin/dspace create-administrator
Creating an initial administrator account
E-mail address: [email protected]
First name: test
Last name: user
Password will not display on screen.
Password: 
Again to confirm: 
Is the above data correct? (y or n): y
Administrator account created

Now you can access the DSPace Backed using the URL http://IP_Address:8080/server

Install and Configure DSpace 7 Repository on Ubuntu 20.0418.04 3

Step 8 – Install Dspace 7 Front End

When installing the Dspace 7 Front End, you need some packages. One of these packages is NodeJS. Dspace 7 works with Node.js (v16 or v18) and required Dspace 7 and above.

Here, we will install Node.JS using NVM installed with the command:

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

Source the profile:

source ~/.bashrc

Now install Node.JS 16 LTS

nvm install v16

Check the node.js version:

$ node --version
v16.20.0

$ npm -v
8.19.4

Install NPM from the PAT repo:

sudo apt install npm

Also, install Yarn and PM2:

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

Download DSpace Frontend from the GitHub releases page. You can also pull it with Wget:

cd ~
wget -c https://github.com/DSpace/dspace-angular/archive/refs/tags/dspace-7.2.tar.gz

Once downloaded, extract it:

tar -zxvf dspace-*.tar.gz

Rename the directory with a more straightforward name:

mv dspace-angular-dspace-* dspace-7-angular

Navigate into the directory:

cd dspace-7-angular

Instal all the required dependencies:

yarn install

Once installed, start the build process:

yarn build:prod

Sample Output:

DSpace 7 Repository on Ubuntu 20.0418.04 3

Now copy the generated files to it to a dedicated directory in /opt

sudo cp -r ../dspace-7-angular/ /opt/dspace-7-angular

Set the correct permissions:

sudo chown dspace:dspace -R /opt/dspace-7-angular/

Now we need to configure PM2:

cd  /opt/dspace-7-angular/
vim  dspace-ui.json

In the file, add the below lines

{
    "apps": [
        {
           "name": "dspace-angular",
           "cwd": "/opt/dspace-7-angular",
           "script": "yarn",
           "args": "run serve:ssr",
           "interpreter": "none"
        }
    ]
}

Save the file and create a config so that the Frontedn can communicate with the backed:

vim config/config.yml

Modify the values to match your Dspace server:

rest:
  ssl: false
  host: DSpace-IP_Address
  port: 8080
  nameSpace: /server

Start the Dspace Front end:

pm2 start dspace-ui.json

Sample Output:

DSpace 7 Repository on Ubuntu 20.0418.04 4

View the logs:

$ pm2 logs
...
0|dspace-a | Building production app config
0|dspace-a | Overriding app config with /opt/dspace-7-angular/dspace-7-angular/config/config.yml
0|dspace-a | Angular config.json file generated correctly at /opt/dspace-7-angular/dspace-7-angular/dist/browser/assets/config.json 
0|dspace-a | 
0|dspace-a | Environment extended with app config
0|dspace-a | [HPM] Proxy created: /  -> http://192.168.200.51:8080/server/sitemaps
0|dspace-a | [20:39:40 GMT+0300 (East Africa Time)] Listening at http://localhost:4000/
....

At this point, you will have the Dspace listening on port 4000, localhost

Step 9 – Configure Nginx Reverse Proxy

To be able to access the Dspace Frontend using the domain name or IP address, we need to configure a reverse proxy. For this guide, we will use Nginx.

Install Nginx on Ubuntu with the command:

sudo apt install nginx -y

Create a virtual host file:

sudo vim /etc/nginx/conf.d/dspace_ui.conf

Add the below lines replacing your domain name/IP address appropriately:

server {
  listen 80;
  server_name    YOUR-DOMAIN-NAME;
  access_log /var/log/nginx/dspace-access.log;
  error_log /var/log/nginx/dspace-error.log;

    location / {
        proxy_pass http://localhost:4000/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Once created, restart nginx:

sudo service nginx restart

Step 10 – Access Dspace 7 Front End

Now you should be able to access your Dspace 7 Frontend using your domain name or IP address. For example //dspace.geeksforgeeks.org

DSpace 7 Repository on Ubuntu 20.0418.04 5

In case you find error 500, you need to modify the dspace.ui.url on your Dspace Backend to match what you are trying to access the server with.

You can then log in using the admin we created earlier. First, accept the license terms:

DSpace 7 Repository on Ubuntu 20.0418.04 6

Provide the username and password:

DSpace 7 Repository on Ubuntu 20.0418.04 7

Once authenticated, you will see this.

DSpace 7 Repository on Ubuntu 20.0418.04 8

Now you are set to start creating the desired digital material to be stored.

DSpace 7 Repository on Ubuntu 20.0418.04 9

The end!

That marks the end of this detailed guide on how to install and configure the DSpace 7 Repository on Ubuntu 20.04|18.04. I hope this worked for you as well.

Interested in more?

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

RELATED ARTICLES

Most Popular

Recent Comments