Install DSpace 8 on Ubuntu 24.04

By

,

This guide shows how to quickly install dspace 8 on Ubuntu 24.04 server for testing purposes. If you follow this guide to install a production server, please MAKE SURE to change the default passwords and other necessary security requirements for your system.

Hardware requirements: This guide was developed using a VPS server with the following specifications

8 GB Memory / 2 Intel vCPUs / 160 GB Disk / Ubuntu 24.04 (LTS) x64

Setup Prerequisites

Create system user and group dspace and add to sudoers group

adduser dspace
usermod -aG sudo dspace

Quit root user and switch to dspace

su dspace && cd
sudo apt update && sudo apt upgrade -y

Install DSpace 8 prerequisite packages

sudo apt install openjdk-17-jdk git ant ant-optional maven postgresql postgresql-contrib libpostgresql-jdbc-java zip npm nginx -y

Configure PostgresSQL Database

Set up host based access on PostgreSQL with the following command

echo "host dspace dspace 127.0.0.1/32 md5" | sudo tee -a /etc/postgresql/16/main/pg_hba.conf
Change database user permissions to “trust” only
sudo sed -i 's/ident/trust/' /etc/postgresql/16/main/pg_hba.conf
sudo sed -i 's/md5/trust/' /etc/postgresql/16/main/pg_hba.conf
sudo sed -i 's/peer/trust/' /etc/postgresql/16/main/pg_hba.conf

Restart postgres db

sudo systemctl restart postgresql

Switch to postgres user

sudo su postgres && cd

Create dspace db user

createuser dspace
Create the dspace db with UNICODE encoding
createdb dspace -E UNICODE

Access the db shell

psql -d dspace

Create the pgcrypto extension to the dspace database

CREATE EXTENSION pgcrypto;

Create the dspace user password

ALTER ROLE dspace WITH PASSWORD 'your-db-password';

Give the dspace db user ownership of the dspace db.

ALTER DATABASE dspace OWNER TO dspace;

Give necessary privileges to dspace user on the dspace database

GRANT ALL PRIVILEGES ON DATABASE dspace TO dspace;

Quit the database shell

\q

Exit postgres user’s shell

exit

Restart postgres

sudo systemctl restart postgresql

SETUP SOLR SEARCH ENGINE

Solr is the search engine behind dspace search functionality as well as statistics

Download solr 8

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

Extract the downloaded file

tar xvf solr-8.11.4.tgz

Install solr to the system

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

By default, the script will install solr in /opt/solr with a symbolic link to /opt/solr-8.11.4. Therefore, solr data directory will be in /var/solr directory.

Install DSpace 8 Back-end

Download dspace 8 from github

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

Extract the downloaded archive

tar -zxvf dspace-8.0.tar.gz

Rename the extracted folder to dspace-backend

mv DSpace-dspace-8.0 dspace-backend

Delete the downloaded archive

rm -f dspace-8.0.tar.gz

Access the back-end source code folder.

cd dspace-backend

Create local.cfg configuration file

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

Look for the following changes in local.cfg file and add or adjust them accordingly


dspace.dir=/opt/dspace-8/server
dspace.server.url = http://YOUR-SERVER-HOST/server
dspace.ui.url = http://YOUR-SERVER-HOST
solr.server = http://localhost:8983/solr
db.url = jdbc:postgresql://localhost:5432/dspace
db.username = dspace
db.password = dspace
### uncomment the following 2 lines to run dspace 8 on localhost:8080
# server.address=127.0.0.1
# server.port=8080

Create the deployment folders and ensure they have the correct permissions.

sudo mkdir -p /opt/dspace-8/server && sudo mkdir -p /opt/dspace-8/client
sudo chown -R dspace:dspace /opt/dspace-8

Compile the source code using maven

mvn package

Wait for the following “BUILD SUCCESS” message. If it fails, you must troubleshoot and resolve the error before proceeding.

Access the compiled source code

cd dspace/target/dspace-installer

Deploy the code to the deployment directory using ant

ant fresh_install

Look out for the following “BUILD SUCCESSFUL” message. If there are errors, resolve them before proceeding.

Switch to the backend deployment directory

cd /opt/dspace-8/server

Copy solr cores

sudo cp -r solr/* /var/solr/data/

Set proper permissions for the solr folders and files you just copied

sudo chown solr:solr -R /var/solr/data

Restart solr

sudo systemctl restart solr

Initialize the database

bin/dspace database migrate

Create the backend service file with the following steps

Create dspace.service file

sudo nano /etc/systemd/system/dspace-backend.service

Paste the following into the file

[Unit]
Description=DSpace 8 Backend
After=network.target

[Service]
User=dspace
Group=dspace
ExecStart=/usr/bin/java -jar /opt/dspace-8/server/webapps/server-boot.jar
WorkingDirectory=/opt/dspace-8/server/webapps/
Restart=on-failure
Environment=JAVA_OPTS="-Xms512m -Xmx2048m"
Environment=DS_HOME=/opt/dspace-8/server

[Install]
WantedBy=multi-user.target

Restart systemd to apply the changes

sudo systemctl daemon-reload

Enable the backend service to auto-start at reboot

sudo systemctl enable dspace-backend

Start the service

sudo systemctl start dspace-backend

The backend should now be accessible at http://YOUR-SERVER:8080/server. If not, check the status of dspace-backend.service and troubleshoot and fix any errors before proceeding to installation of the front-end.

Install DSpace 8 Angular Front-end

Get back to the system user’s home directory and download the front-end application from github

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

Extract the archive

tar -zxvf dspace-8.0.tar.gz

Rename the source code folder

mv dspace-angular-dspace-8.0 dspace-frontend

cd into the source code folder

cd dspace-frontend

Verify your installed node version. You should have node version 18 or 20

node -v
npm -v

Install yarn and pm2

sudo npm install -g yarn pm2

Install angular dependencies

yarn install

Build the front-end source code for production using yarn

yarn build:prod

Copy dist folder to the deployment folder

cp -r dist /opt/dspace-8/client/

Create a config folder

mkdir -p /opt/dspace-8/client/config

Create the production configuration file

cp config/config.example.yml /opt/dspace-8/client/config/config.prod.yml

Configure angular to connect to the backend REST API as shown in the image below. Adjust ssl, host and port number settings according to your setup. Remember, SSL must be enabled in production mode.

Run the front-end using pm2

Ensure you are in the front-end deployment folder

cd /opt/dspace-8/client

Create the file dspace-ui.json needed to use pm2

nano dspace-ui.json

Copy-paste the following code to the file

{
    "apps": [
        {
           "name": "dspace-ui",
           "cwd": "/opt/dspace-8/client",
           "script": "dist/server/main.js",
           "instances": 4,
           "exec_mode": "cluster",
           "env": {
              "NODE_ENV": "production"
           }
        }
    ]
}

Start the front-end application

pm2 start dspace-ui.json

Use nginx as a proxy to the applications

Edit nginx configuration file

sudo nano /etc/nginx/sites-available/default

Configure your server block as shown below

server {
  listen 80;

  server_name    143.198.126.21;
  access_log /var/log/nginx/dspace-access.log;
  error_log /var/log/nginx/dspace-error.log;

  location /server {
    # proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-Host $server_name;
    proxy_pass http://localhost:8080/server;
  }

  location / {
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Forwarded-Server $server_name;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:4000/;
  }
}

In production mode, replace the IP address with your actual domain name and install SSL certificate.

Restart nginx

sudo systemctl restart nginx

About The Author

One response to “Install DSpace 8 on Ubuntu 24.04”

  1. Murat Avatar
    Murat

    Thanks for your share. But you didn’t explain to create admin user. I search this topic. I add a admin user but i have an error username or password wrong. I don’t use SSL so the cause of my error from SSL.

    Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hello!

Select one of our contacts below to chat on WhatsApp

× How can I help you?