A
PROFILE
Laman Web Staf UPM
ENCIK MUIZZUDIN BIN KASPOL
KETUA BAHAGIAN
PERPUSTAKAAN SULTAN ABDUL SAMAD
muizzudin
BM
EN

How to install DSpace 6.3 on Ubuntu 20.04

- 23 Sep 2020
STEP 1
Prerequisite Softwares for Creating Institutional Repository Using DSpace. Must know, what is to be required for creating IR using DSpace:

1. Java Development Kit (JDK)
2. PostgreSQL 10 Database
3. DSpace CRIS 6.3 Software
4. Apache Ant (Pure Java Build Tool) v1.10.5
5. Apache Maven (Apache Build Automation Tool for Java Projects) v3.6.0
6. Apache Tomcat (Web Server for hosting Dspace) v9.0.37

Open Terminal and execute following commands. Use [Ctrl+Alt+T] to open Terminal.
Refer: https://wiki.duraspace.org/display/DSPACECRIS/Installation

STEP 2
First update and upgrade your Ubuntu server and then Install All Prerequisite Softwares for creating Institutional Repository at your Institute. Use the following command.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install default-jdk openjdk-8-jdk postgresql ant maven git openssh-server net-tools curl unzip


STEP 3
Create the database user. Please use the following command and follow the instructions.

$ sudo su postgres
$ createuser -U postgres -d -A -P dspace
Enter password for new role: dspace
Enter it again: dspace
$ exit

Tips:
Enter password for new role: [Enter a password e.g. dspace]
Shall the new role be allowed to create more new roles? (y/n) n
[Enter n and press enter button]


STEP 4
Allow the database user (dspace) to connect to the database
Open the file "pg_hba.conf" by using the following command.
[If the following command not open, check the postgresql version number and apply in the command]


$ sudo nano /etc/postgresql/12/main/pg_hba.conf


Add this line to the configuration file at the end:

local [tab] all [tab] dspace [tab] md5


Example:

save and close the file ( CTRL+O, ENTER, CTRL+X)

Restart PostgreSQL :

$ sudo /etc/init.d/postgresql restart
[enter postgresql password = dspace] – ***if necessary


STEP 5
Create Dspace user and Dspace Installation Directory:
Execute the following commands one by one.


$ sudo mkdir /dspace

$ sudo chown -Rf dspace:dspace /dspace


STEP 6
Create the PostgreSQL 'dspace' database and extension pgcrypto:


$ sudo -u dspace createdb -U dspace -E UNICODE dspace

$ sudo su postgres


Now type the following command to create extension pgcrypto (simply copy & paste the following command in your command line interface)


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

$ exit


Type the following to restart postgres:


$ sudo /etc/init.d/postgresql restart
[enter postgresql password = dspace]


STEP 7
Create Dspace Source directory and give permission to it:


$ sudo mkdir /dspace_build

$ sudo chmod -Rf 777 /dspace_build



STEP 8
Download Dspace to /dspace_build directory: Execute the following command to proceed.


$ cd /dspace_build



Then simply Copy and paste (use mouse only) following line in the terminal.
Download here:- https://github.com/DSpace/DSpace/releases


$ sudo wget https://github.com/DSpace/DSpace/releases/download/dspace-6.3/dspace-6.3-src-release.zip


Then extract Dspace package by using the following command:

$ sudo unzip dspace-6.3-src-release.zip


STEP 9
Use the following command to run maven for the installation of Dspace in Installation Directory (/dspace):


$ cd /dspace_build/dspace-6.3-src-release/

$ sudo update-alternatives --config java

$ select no.2 = openjdk-8 as default [enter]

$ sudo mvn -U package


STEP 10
Enter into Dspace package folder to download packages by issuing the following commands.


$ cd dspace/target/dspace-installer

$ sudo ant fresh_install

$ exit




STEP 11
Installation of Tomcat (one more prerequisite software for DSpace):
Download and extract the Tomcat package. First, change the current directory to /opt Directory.
Refer: https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04


Step 1: Install Java
Tomcat requires Java to be installed on the server so that any Java web application code can be executed. We can satisfy that requirement by installing OpenJDK with apt-get.

First, update your apt-get package index:

$ sudo apt-get update


Then install the Java Development Kit package with apt-get:


$ sudo apt-get install default-jdk


Now that Java is installed, we can create a tomcat user, which will be used to run the Tomcat service.

Step 2: Create Tomcat User

For security purposes, Tomcat should be run as an unprivileged user (i.e. not root). We will create a new user and group that will run the Tomcat service.

First, create a new tomcat group:


$ sudo groupadd tomcat


Next, create a new tomcat user. We’ll make this user a member of the tomcat group, with a home directory of /opt/tomcat (where we will install Tomcat), and with a shell of /bin/false (so nobody can log into the account):

$ sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat


Now that our tomcat user is set up, let’s download and install Tomcat.






Step 3: Install Tomcat

$ cd /opt

$ sudo wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.38/bin/apache-tomcat-9.0.38.tar.gz

$ sudo tar -xvzf apache-tomcat-9.0.38.tar.gz

$ sudo mv apache-tomcat-9.0.38 tomcat


Step 4: Update Permissions

The tomcat user that we set up needs to have access to the Tomcat installation. We’ll set that up now.

Change to the directory where we unpacked the Tomcat installation:


$ cd /opt/tomcat


Give the tomcat group ownership over the entire installation directory:


$ sudo chgrp -R tomcat /opt/tomcat


Next, give the tomcat group read access to the conf directory and all of its contents, and execute access to the directory itself:


$ sudo chmod -R g+r conf
$ sudo chmod g+x conf


Make the tomcat user the owner of the webapps, work, temp, and logs directories:


$ sudo chown -R tomcat webapps/ work/ temp/ logs/


Now that the proper permissions are set up, we can create a systemd service file to manage the Tomcat process.




Step 5: Create a systemd Service File

We want to be able to run Tomcat as a service, so we will set up systemd service file.
Tomcat needs to know where Java is installed. This path is commonly referred to as “JAVA_HOME”. The easiest way to look up that location is by running this command:


$ sudo update-java-alternatives -l



Output
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64


The correct JAVA_HOME variable can be constructed by taking the output from the last column (highlighted in red) and appending /jre to the end. Given the example above, the correct JAVA_HOME for this server would be:


JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre


Your JAVA_HOME may be different.
With this piece of information, we can create the systemd service file. Open a file called tomcat.service in the /etc/systemd/system directory by typing:


$ sudo nano /etc/systemd/system/tomcat.service




Paste the following contents into your service file. Modify the value of JAVA_HOME if necessary to match the value you found on your system. You may also want to modify the memory allocation settings that are specified in CATALINA_OPTS:


[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms1536M -Xmx3024M -server -XX:+UseParallelGC -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target

ATAU BOLEH RUJUK
1. https://linuxize.com/post/how-to-install-tomcat-9-on-ubuntu-18-04/
2. https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04
3. https://phoenixnap.com/kb/how-to-install-tomcat-ubuntu

When you are finished, save and close the file.

Next, reload the systemd daemon so that it knows about our service file:


$ sudo systemctl daemon-reload





Start the Tomcat service by typing:


$ sudo systemctl start tomcat


Double check that it started without errors by typing:


$ sudo systemctl status tomcat


Step 6: Adjust the Firewall and Test the Tomcat Server

Now that the Tomcat service is started, we can test to make sure the default page is available.

Before we do that, we need to adjust the firewall to allow our requests to get to the service. If you followed the prerequisites, you will have a ufw firewall enabled currently.

Tomcat uses port 8080 to accept conventional requests. Allow traffic to that port by typing:


$ sudo ufw allow 8080


With the firewall modified, you can access the default splash page by going to your domain or IP address followed by :8080 in a web browser:


Open in web browser
http://server_domain_or_IP:8080


You will see the default Tomcat splash page, in addition to other information. However, if you click the links for the Manager App, for instance, you will be denied access. We can configure that access next.

If you were able to successfully accessed Tomcat, now is a good time to enable the service file so that Tomcat automatically starts at boot:


$ sudo systemctl enable tomcat







Step 7: Configure Tomcat Web Management Interface

In order to use the manager web app that comes with Tomcat, we must add a login to our Tomcat server. We will do this by editing the tomcat-users.xml file:


$ sudo nano /opt/tomcat/conf/tomcat-users.xml


You will want to add a user who can access the manager-gui and admin-gui (web apps that come with Tomcat). You can do so by defining a user, similar to the example below, between the tomcat-users tags. Be sure to change the username and password to something secure:





Save and close the file when you are finished.

By default, newer versions of Tomcat restrict access to the Manager and Host Manager apps to connections coming from the server itself. Since we are installing on a remote machine, you will probably want to remove or alter this restriction. To change the IP address restrictions on these, open the appropriate context.xml files.

For the Manager app, type:


$ sudo nano /opt/tomcat/webapps/manager/META-INF/context.xml


For the Host Manager app, type:


$ sudo nano /opt/tomcat/webapps/host-manager/META-INF/context.xml


Inside, comment out the IP address restriction to allow connections from anywhere. Alternatively, if you would like to allow access only to connections coming from your own IP address, you can add your public IP address to the list:
context.xml files for Tomcat webapps






Save and close the files when you are finished.

To put our changes into effect, restart the Tomcat service:


$ sudo systemctl restart tomcat


Step 8: Access the Web Interface
Now that we have create a user, we can access the web management interface again in a web browser. Once again, you can get to the correct interface by entering your server’s domain name or IP address followed on port 8080 in your browser:


Open in web browser
http://server_domain_or_IP:8080
ATAU
http://server_domain_or_IP:8080/manager/html












STEP 12

Copy Dspace webapps files (web deployment directory) to Tomcat folder

$ sudo cp -R /dspace/webapps/* /opt/tomcat/webapps

OR

sudo cp -R /dspace/webapps/jspui /opt/tomcat/webapps
sudo cp -R /dspace/webapps/xmlui /opt/tomcat/webapps
sudo cp -R /dspace/webapps/solr /opt/tomcat/webapps
sudo cp -R /dspace/webapps/oai /opt/tomcat/webapps
sudo cp -R /dspace/webapps/rdf /opt/tomcat/webapps
sudo cp -R /dspace/webapps/rest /opt/tomcat/webapps
sudo cp -R /dspace/webapps/sword /opt/tomcat/webapps
sudo cp -R /dspace/webapps/swordv2 /opt/tomcat/webapps


STEP 14
Give permission to tomcat owner, so that tomcat can be executed by dspace user by applying following command:

$ cd /opt

$ sudo chown dspace.dspace tomcat/ -R
ATAU
$ sudo chown tomcat.tomcat tomcat/ -R


STEP 15
Start Tomcat server:
Use following command to start tomcat server.

$ sudo systemctl daemon-reload


If you want to stop Tomcat server, then use following command:


$ sudo systemctl start OR restart tomcat








STEP 16
Make an initial administrator account (an e-person) in DSpace:

Apply following command in a terminal,

$ sudo /dspace/bin/dspace create-administrator

Creating an initial administrator account
E-mail address: muizzudin@upm.edu.my
First name: Muizzudin
Last name: Kaspol
Password will not display on screen.
Password:admin123
Again to confirm:admin123
Is the above data correct? (y or n): y
Administrator account created

STEP 17
Open Dspace in your browser
You can load either one Dspace interface in a browser.

1. http://localhost:8080/xmlui


2. http://localhost:8080/jspui


NOTA TAMBAHAN:
1. Jika keluar page Internal system error kat Main Page DSpace
2. Semak solr http://localhost:8080/solr
3. Set permission dalam directory /dspace/solr

dibaca
3744
BLOG