Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kendrickjr/f2d17cf504131391a17e4e1803864e65 to your computer and use it in GitHub Desktop.
Save kendrickjr/f2d17cf504131391a17e4e1803864e65 to your computer and use it in GitHub Desktop.
INSTALL DSPACE 7 ON UBUNTU 22.04

INSTALL DSPACE 7 ON UBUNTU 22.04

PREREQUISITES

Update and upgrade packages

sudo apt update && sudo apt upgrade -y

Create dspace system user

sudo adduser dspace

Add dspace user to sudoers group

usermod -aG sudo dspace

Install openjdk-11

sudo apt install openjdk-11-jdk -y

Install git, ant and maven

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

DB SETUP

Create the file repository configuration for postgres-13

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

Import repository signing key

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Install postgres-13. DSpace is tested on postgres 11, 12 and 13

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

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/13/main/pg_hba.conf

Change database user permissions to “trust” only

sudo sed -i 's/ident/trust/' /etc/postgresql/13/main/pg_hba.conf

sudo sed -i 's/md5/trust/' /etc/postgresql/13/main/pg_hba.conf

sudo sed -i 's/peer/trust/' /etc/postgresql/13/main/pg_hba.conf

Restart postgres

sudo systemctl restart postgresql

Switch to postgres user

sudo su postgres

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-here';

Give the dspace db user ownership of the dspace db.

ALTER DATABASE dspace OWNER TO dspace;

Give necessary privileges to dspace db user on the dspace db

GRANT ALL PRIVILEGES ON DATABASE dspace TO dspace;

Exit the db shell

\q

Exit postgres user session

exit

Restart postgres

sudo systemctl restart postgresql

SOLR SETUP

Download solr-8

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

Extract the file

tar xvf solr-8.11.2.tgz

Install solr

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

The script will install solr in /opt/solr with a symbolic link to /opt/solr-[version]

SETUP tomcat9

Only tomcat9 is supported for now.

sudo apt install tomcat9

Define JAVA_HOME for tomcat inside

sudo nano /etc/default/tomcat9

as shown below

JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64

Configure tomcat's memory utilization according to your available resources

JAVA_OPTS="-Djava.awt.headless=true -Xmx2048m -Xms1024m -XX:MaxPermSize=1024m"

Alter Tomcat’s default configuration to support searching and browsing of multi-byte UTF-8 correctly. Edit the file server.xml by editing as shown

sudo nano /etc/tomcat9/server.xml

You can comment out the existing element and paste in the one below

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

INSTALL DSPACE 7 BACKEND

Download dspace-7.2 backend code

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

Extract the downloaded file

tar -zxvf dspace-7.6tar.gz

Rename the folder (only to make the name simpler)

mv DSpace-dspace-7.2.1 dspace-7-src

cd to the directory

cd dspace-7-src

Create the deployment directory

sudo mkdir /opt/dspace-7

Change ownership of the deployment directory to dspace system user.

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

Create a configuration local.cfg file by copying the existing example file.

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

Edit the file nano dspace/config/local.cfg

nano nano dspace/config/local.cfg

Edit the following configs

dspace.dir=/opt/dspace-7

dspace.server.url = http://YOUR-SERVER-IP:8080/server

dspace.ui.url = http://YOUR-SERVER-IP

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

db.url = jdbc:postgresql://localhost:5432/dspace

db.driver = org.postgresql.Driver

db.username = dspace

db.password = dspace

Build DSpace

mvn package

cd to the build directory dspace/target/dspace-installer

cd dspace/target/dspace-installer

Deploy the code

ant fresh_install

Configure tomcat9 to serve the deployed code

cd /var/lib/tomcat9/webapps

sudo ln -s /opt/dspace-7/webapps/server server

Copy over solr cores

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

Restart solr

sudo systemctl restart solr

Initialize to create tables on the db

cd /opt/dspace-7

./bin/dspace database migrate

Install the Front End

Install node version manager

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

Load NVM to the terminal session

source ~/.nvm/nvm.sh

Install node 16 LTS

nvm install 16.15

Install npm

sudo apt install npm

Install yarn

sudo npm install --global yarn

Install pm2 (Node.js process manager)

sudo npm install --global pm2

Download the source code

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

Extract the files

tar -zxvf dspace-7.2.tar.gz

Rename the directory (only to simplify the name)

mv dspace-angular-dspace-7.2 dspace-7-angular

cd to the directory

cd dspace-7-angular

Install required angular dependencies

yarn install

Build angular for production

yarn build:prod

Create the deployment dir

sudo mkdir /opt/dspace-7-angular

Give its ownership to dspace user

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

Copy the dist dir to the deployment dir

cp -r dist /opt/dspace-7-angular/

Create config dir

mkdir /opt/dspace-7-angular/config

Create production config file

cp config/config.example.yml /opt/dspace-7-angular/config/config.prod.yml

Configure angular to connect to the backend API

cd /opt/dspace-7-angular/

Run angular via PM2

Create the file dspace-ui.json

nano dspace-ui.json

Add

{
    "apps": [
        {
           "name": "dspace-ui",
           "cwd": "/opt/dspace-7-angular",
           "script": "dist/server/main.js",
           "env": {
              "NODE_ENV": "production"
           }
        }
    ]
}

Start the application

pm2 start dspace-ui.json

CONFIGURE NGINX AS REVERSE PROXY

Install nginx

sudo apt install nginx -y

1.Configure one server block inside /etc/nginx/sites-enabled/default as follows

server {
  listen 80;

  server_name    YOUR-SERVER-IP;
  access_log /var/log/nginx/dspace-access.log;
  error_log /var/log/nginx/dspace-error.log;

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

Restart nginx

sudo service nginx restart

Refer to the official documentation for dspace 7 installation if you encounter any challenges. It is more detailed and explains each of these steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment