Installation of DSpace 7 on ubuntu 22.04 LTS

DSpace-7  introduces an angular-based user interface that combines both JSPUI and XMLUI interfaces. DSpace-7 application is split into two parts front-end and back-end. The front end is the user interface and the back end is used for server API. We need to install both preferably on the same machine in order to make it fully functional. To run the frontend properly, we need to install the backend first.

dspace 7

Prerequisites:-

  • Java JDK  
  • Apache Maven 3.3.x or above.
  • Apache Ant 1.8 or above.
  • PostgreSQL  
  • Apache Tomcat 8 or above version
  • Apache Solr 7.2.1 or above.  (New requirement for DSpace 7)

I have tested the following commands on ubuntu 22.04 LTS. You can follow the same steps on other Linux-based operating systems too. 

Open the terminal (CTRL + ALT + T)

Update  and upgrade the ubuntu system

sudo su 

sudo apt update -y

sudo apt upgrade -y

Install git (Supporting package for the DSpace installation)

sudo apt install git

Install Java development kit (JDK) 

sudo apt install default-jdk 

You can check the java version with the following command (JDK 11 and JDK 17 versions are fully supported to dsapce7)

java -version

Open the following file to activate the JAVA_HOME & JAVA_OPTS environment variable

sudo gedit /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 command

source /etc/environment

Check the status that the JAVA_HOME & JAVA_OPTS have been set successfully or not

echo $JAVA_HOME

echo $JAVA_OPTS

Install Apache Maven and Apache Ant in the 'etc' directory

cd /etc

sudo apt install maven -y

sudo apt install ant -y

Install Postgresql Database and related packages

sudo apt install postgresql postgresql-client postgresql-contrib

Check the Postgres version

psql -V psql

(Note down the version number. The version numbers vary in Ubuntu 20.04, 22.04, and Debian-11, In my case, this is version 14. Replace the version number in the following command if your Linux distribution is other than Ubuntu 22.04)

sudo pg_ctlcluster 14 main start

Set the Password for Postgres

sudo passwd postgres

(Enter the password e.g. dspace)

Now Connect to the Postgres user 

su postgres

(Enter the password if the system asked)

Run the following commands to check whether UTF8 is enabled or not

cd /etc/postgresql/14/main

psql -c "SHOW SERVER_encoding"

Now, Exit from the Postgres user

exit

Now, open the configure file of PostgreSQL (Change the Postgres version number if you are using other than Ubuntu 22.04)

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

Uncomment the following line by removing ‘#’ under the connection settings option 

listen_addresses = 'localhost'

Save and Exit

Open the following file and add the line to host-based access on Postgres

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

Find the line “# Database administrative login by Unix domain socket” and add the following line above this line.

host dspace dspace 127.0.0.1 255.255.255.255 md5

Add a line as the below screenshot

Restart the PostgreSQL

sudo systemctl restart postgresql

Solr Installation

Install Solr in the opt directory (Apply the following commands)

cd /opt

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

Extract the zip file

unzip solr-8.11.2.zip

Delete the solr zip file as it is not required

sudo rm solr-8.11.2.zip

Change the permission of the solr directory

sudo chown -R vijender:vijender solr-8.11.2

(Change the vijender:vijender with your user name in the above command)

Create the Directory in the root directory with the name dspace

cd / 

sudo mkdir /dspace

Change the permission of the newly created directory

sudo chown -R vijender:vijender /dspace

(Replace the 'vijender:vijender' with your root user name) 

Return to the home directory

cd

exit

Apply the following command from the home directory

gedit .profile

(Paste the following line in the file for auto-start Solr and save the file)

/opt/solr-8.11.2/bin/solr start

Now apply the following commands from the terminal to start the solr

/opt/solr-8.11.2/bin/solr start

Open the following URL in the browser and check whether the Solr admin dashboard is loaded.

http://localhost:8983/solr

Install Tomcat

sudo apt install tomcat9

Open the following file

sudo gedit /lib/systemd/system/tomcat9.service

Add the following line at the bottom under the Security

ReadWritePaths=/dspace

Save and close

Open the following file in the tomcat folder

sudo gedit /etc/tomcat9/server.xml

Find the following lines in the file

<Connector port="8080" protocol="HTTP/1.1"

                   connectionTimeout="20000"

                   redirectPort="8443" />

Replace the above lines with the following lines

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

Restart the Tomcat

sudo systemctl restart tomcat9.service

If you see the following warning message while restarting tomcat

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

Run the following command

sudo systemctl daemon-reload

Now-Again restart the Tomcat

sudo systemctl restart tomcat9.service

Backend Installation of Dspace

Download the DSpace-7.3 in the home folder with the following command.

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

Unzip the DSpace file

unzip dspace-7.3.zip

(It will unzip the folder named 'Dspace-dspace-7.3')

Remove the zip folder as it is not required

sudo rm dspace-7.3.zip

Change the directory and enter the Dspace-dspace-7.3

cd DSpace-dspace-7.3

Change the permission to dspace directory

sudo chown -R vijender:vijender /DSpace-dspace-7.3 

(Replace the vijender:vijender with your root user name)

Now set the database under the dspace

su postgres

(Enter the password if the system prompt to password)

Enter into the following directory (Change the Postgres version number accordingly)

cd /etc/postgresql/14/main

Create the username and the password for the new role

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

(Enter the password e.g dspace)

Create the new database 

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

Add pgcrypto extension

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

Exit from Postgres user

exit

DSpace configuration (Enter the dspace configuration directory)

cd DSpace-dspace-7.3/dspace/config

Make a copy of file ‘local.cfg.EXAMPLE’ named ‘local.cfg’

cp local.cfg.EXAMPLE local.cfg

Open the configuration file

gedit local.cfg

Here you will find important lines and their purpose. Make the changes in the file wherever required

# Name of the site

(Change the name of your repository)

dspace.name = DSpace at My University   

# Database username and password

(Change the database username and password if there are any changes)

db.username = dspace

db.password = dspace  

Un-comment (delete the #) the following line

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

Save and close the file

Return to the DSpace directory

cd DSpace-dspace-7.3

Build the Installation Package

mvn package

(It may take time to build the package 10 to 40 minutes depending on your internet speed and server response. After the successful installation your terminal screen will look similar to the following image)

Install DSpace Backend (Enter the dspace-installer directory)

 cd DSpace-dspace-7.3/dspace/target/dspace-installer/

Install the ant fresh

ant fresh_install

(It will look similar to the following image after built successfully)

Initialize the Database (Apply the following commands)

cd /dspace/bin

./dspace database migrate

Copy the dspace webapps directory to the Tomcat server

sudo cp -R /dspace/webapps/* /var/lib/tomcat9/webapps*

Now Copy Solr directory

cd /dspace/solr

cp -R /dspace/solr/* /opt/solr-8.11.2/server/solr/configsets

Now Restart the Solr

cd /opt/solr-8.11.2/bin

./solr restart

Create an Administrator Account

/dspace/bin/dspace create-administrator

(Enter the email address, first name, last name, password, etc.)

Change the permissions of dspace to Tomcat User

sudo chown -R tomcat:tomcat /dspace

Restart the Tomcat

sudo systemctl restart tomcat9.service

Now open the browser and locate the following URL to open the REST API interface

http://localhost:8080/server

You will see the REST API interface as blow screenshot. Review the steps followed if not load screen like this.

Install Frontend of DSpace

Download Node Version Manager in the home directory

cd

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Restart the Terminal  (Close and Open Again)

Install the latest version of NVM

nvm install --lts

Installation of Yarn

npm install --global yarn

Installation of pm2

npm install --global pm2

Download DSpace Angular (Release7.3) in the home directory

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

Extract the zip file

unzip dspace-7.3.zip

Delete the  zip file as it is not required

sudo rm dspace-7.3.zip

Install yarn in the dspace angular directory

cd dspace-angular-dspace-7.3

yarn install

Copy and rename the production file 

cd config 

cp config.example.yml config.prod.yml

Now open the renamed file

gedit config.prod.yml

Now, make following changes under The REST API server settings in the file 

# 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

Build the User Interface 

yarn run build:prod

Go to the dspace-angular-dspace-7.3 directory

cd /home/vijender/dspace-angular-dspace-7.3

(Replace the vijender to your root user name to give the proper path)

Create pm2  dspace-angular.json file

gedit dspace-angular.json 

add the below lines to the file

{

    "apps": [

        {

           "name": "dspace-angular",

           "cwd": "/home/vijender/dspace-angular-dspace-7.3",

           "script": "dist/server/main.js",

           "env": {

              "NODE_ENV": "production",

   "DSPACE_REST_SSL": "false",

   "DSPACE_REST_HOST": "localhost",

   "DSPACE_REST_PORT": "8080",

   "DSPACE_REST_NAMESPACE": "/server"

           }

        }

    ]

}

(In the above block, the "cwd" setting must correspond to your dspace-angular-dspace-7.3 directory path.)

Start the pm2  (You need to run this command from the same directory of the dspace-angular-dspace-7.3

pm2 start dspace-angular.json

Now open the browser and enter the following URL

http://localhost:4000

Login in the admin panel with the admin user Email- ID and Password

References:
https://wiki.lyrasis.org/display/DSDOC7x/Installing+DSpace
https://www.youtube.com/watch?v=Ta-BpqBFJsg
Mr. D P Tripathi (Deputy Librarian at Dr. B R Ambedkar National Institute of Technology)
http://dspacegeek.blogspot.com/2022/05/install-dspace7-ubuntu-debian.html

Post a Comment

14 Comments

  1. sudo chown -R vijender:vijender /DSpace-dspace-7.3
    I have changed the name but permission error chown: cannot access `...' : No such file or directory

    ReplyDelete
    Replies
    1. I have the same problem , in that step it starts to fail , I could not find the cause of the problem .

      Delete
    2. Check the Dspace-dspace-7.3 directory, whether it is available in home directory

      Delete
  2. Hi, have a error in maven-war-plugin 3.2.3

    ReplyDelete
  3. I have just installed dspace 7 in ubuntu server 22.04 but unable to access in local network. Only localhost works fine. Please help me in this regard

    ReplyDelete
    Replies
    1. I'm facing same issue dspace7 is not working in local area network.

      Delete

    2. Replace the localhost with your IP address in the " local.cfg" and "config.prod.yml" files

      Delete
  4. hi sir
    i try your instruction but when i follow this step >source /etc/environment

    To Check the status that the JAVA_HOME & JAVA_OPTS

    this error came out > –Xms64M: command not found

    Please help me, tq for advance

    ReplyDelete
    Replies
    1. Add the following one line only in the previous command to the file instead two

      JAVA_HOME=”/usr/lib/jvm/java-11-openjdk-amd64”

      Delete
    2. i do as you told. After i Apply the following command
      source /etc/environment
      But there are no status like shown as you guide
      Check the status that the JAVA_HOME & JAVA_OPTS have been set successfully or not
      echo $JAVA_HOME

      Delete
    3. it's a character encoding problem, change the en dash (–) to a hyphen (-) and type the quotation mark (") directly to your file on the operational system as (”) is different from (")

      Delete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Hi, my name is sebastian i followed your instruction and finally i could install Dspace Back and Front! Thank you very much.

    Could i explain me, how can i customize the logo for my Dspace repository in dspace7? I followed this instruction, but i cant do it.

    https://wiki.lyrasis.org/display/DSDOC7x/User+Interface+Customization

    I hope you could help me. Thank you

    ReplyDelete