Complete DSpace Installation Guide
Installation of Backend
Step 1: System Preparation
i. Update & Upgrade System Packages
sudo apt update && sudo apt upgrade -y
Explanation: This command updates the package lists and upgrades all installed packages to their latest versions. The -y flag automatically confirms the upgrade process.
Step 2: Install Required Dependencies
i. Core Tools
sudo apt install wget curl git build-essential unzip zip -y
Explanation: This command installs essential tools needed for software development and system administration, including wget for downloading files, curl for transferring data, git for version control, and build tools for compiling software.
ii. Java Development Kit (OpenJDK 17)
sudo apt install openjdk-17-jdk -y
Explanation: This command installs OpenJDK 17, which is required for running DSpace. DSpace is a Java-based application that requires a Java Runtime Environment.
iii. Verify Java Installation:
java -version
Explanation: This command displays the installed Java version, confirming that OpenJDK 17 was installed correctly.
iv. Set the Environment Variable
sudo nano /etc/environment
Explanation: This command opens the system environment variables file for editing, where we'll add Java-specific configuration.
JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
Explanation: This line sets the JAVA_HOME variable to point to the Java installation directory, which is needed by many Java applications.
JAVA_OPTS="-Xmx512M -Xms64M -Dfile.encoding=UTF-8"
Explanation: This line configures Java memory settings (maximum heap size of 512MB, initial heap size of 64MB) and sets UTF-8 encoding for proper character handling.
source /etc/environment
Explanation: This command applies the changes made to the environment variables file to the current shell session.
echo $JAVA_HOME
Explanation: This command displays the value of the JAVA_HOME environment variable to confirm it was set correctly.
echo $JAVA_OPTS
Explanation: This command displays the value of the JAVA_OPTS environment variable to confirm it was set correctly.
v. Build Tools (Maven & Ant)
sudo apt install maven ant -y
Explanation: This command installs Maven and Ant, which are build automation tools used to compile and package DSpace.
mvn -version
Explanation: This command displays the installed Maven version, confirming that Maven was installed correctly.
ant -version
Explanation: This command displays the installed Ant version, confirming that Ant was installed correctly.
Step 3: Install PostgreSQL
sudo apt install postgresql postgresql-contrib libpostgresql-jdbc-java -y
Explanation: This command installs PostgreSQL database server, additional contributed packages, and the Java JDBC driver for PostgreSQL connectivity.
i. Configure PostgreSQL
sudo -u postgres psql
Explanation: This command switches to the postgres system user and starts the PostgreSQL interactive terminal (psql).
ii. Run the following command to setup the database for DSpace
CREATE USER dspace WITH PASSWORD 'dspace';
Explanation: This SQL command creates a new PostgreSQL user named 'dspace' with the password 'dspace' that will be used by the DSpace application.
CREATE DATABASE dspace WITH OWNER dspace;
Explanation: This SQL command creates a new database named 'dspace' and assigns ownership to the 'dspace' user created in the previous step.
\q
Explanation: This command exits the PostgreSQL interactive terminal and returns to the regular shell prompt.
iii. Enable pgcrypto Extension
sudo -u postgres psql dspace -c "CREATE EXTENSION pgcrypto;"
Explanation: This command enables the pgcrypto extension in the dspace database, which provides cryptographic functions that DSpace uses for secure operations.
iv. Update and Configuration network access
Allow PostgreSQL to accept local connections from DSpace. This enables PostgreSQL to listen on localhost (for security, it won't accept external connections). DSpace (running locally) needs to communicate with PostgreSQL via TCP/IP.
sudo nano /etc/postgresql/16/main/postgresql.conf
Explanation: This command opens the main PostgreSQL configuration file for editing to configure network listening settings.
#listen_addresses = 'localhost'
Explanation: This is the default commented-out line that needs to be uncommented and modified to allow PostgreSQL to listen on localhost.
listen_addresses = 'localhost'
Explanation: This line configures PostgreSQL to listen for connections on the localhost interface only, enhancing security while allowing local applications to connect.
v. Configure Client Authentication (pg_hba.conf)
Allow the dspace user to authenticate with a password. This allows the dspace user to connect to the dspace database from localhost using password authentication (md5).
sudo nano /etc/postgresql/16/main/pg_hba.conf
Explanation: This command opens the PostgreSQL client authentication configuration file to set up access rules for the dspace database user.
# Database administrative login by Unix domain socket
Explanation: This comment marks the section where authentication rules are defined in the pg_hba.conf file.
#DSpace configuration
Explanation: This comment helps identify the DSpace-specific configuration in the authentication file.
host dspace dspace 127.0.0.1 255.255.255.255 md5
Explanation: This line allows the dspace user to connect to the dspace database from localhost (127.0.0.1) using password authentication (md5).
vi. Restart PostgreSQL
sudo systemctl restart postgresql
Explanation: This command restarts the PostgreSQL service to apply all the configuration changes made to the postgresql.conf and pg_hba.conf files.
Step 4: Install Solr 9.x
sudo wget https://downloads.apache.org/solr/solr/9.9.0/solr-9.9.0.tgz -P /opt
Explanation: This command downloads the Solr 9.9.0 package from the Apache mirrors and saves it to the /opt directory.
sudo tar xzf /opt/solr-9.9.0.tgz -C /opt
Explanation: This command extracts the downloaded Solr archive to the /opt directory.
sudo mv /opt/solr-9.9.0 /opt/solr
Explanation: This command renames the extracted directory to a simpler name for easier reference.
sudo rm /opt/solr-9.9.0.tgz
Explanation: This command removes the downloaded archive file to free up disk space after extraction.
sudo useradd -r -d /opt/solr -M solr
Explanation: This command creates a dedicated system user for running Solr with the home directory set to /opt/solr.
sudo chown -R solr:solr /opt/solr
Explanation: This command changes ownership of the Solr directory to the solr user, ensuring proper permissions for operation.
sudo nano /etc/systemd/system/solr.service
Explanation: This command creates a systemd service file to manage Solr as a system service.
[Unit]
Description=Apache Solr for DSpace
After=network.target
[Service]
User=solr
Group=solr
WorkingDirectory=/opt/solr
Environment="SOLR_OPTS=-Dsolr.config.lib.enabled=true -Djava.security.manager=allow"
Environment="SOLR_JETTY_HOST=0.0.0.0"
ExecStart=/opt/solr/bin/solr start -f
ExecStop=/opt/solr/bin/solr stop
Restart=on-failure
LimitNOFILE=65536
TimeoutSec=180
[Install]
WantedBy=multi-user.target
Explanation: This systemd service configuration defines how Solr should run, including the user, environment variables, and execution commands.
sudo systemctl daemon-reload
Explanation: This command reloads the systemd manager configuration to recognize the new Solr service.
sudo systemctl enable --now solr
Explanation: This command enables Solr to start at boot and starts the service immediately.
sudo systemctl start solr
Explanation: This command starts the Solr service (redundant with --now flag but included for completeness).
sudo systemctl status solr
Explanation: This command displays the current status of the Solr service to verify it's running properly.
Once testing is complete and DSpace is fully integrated with Solr, you should restrict Solr to listen only on localhost. This is critical to protect the Solr admin panel and prevent unauthorized access.
sudo nano /etc/systemd/system/solr.service
Explanation: This command opens the Solr service file to modify it for production security.
[Unit]
Description=Apache Solr for DSpace
After=network.target
[Service]
User=solr
Group=solr
WorkingDirectory=/opt/solr
Environment="SOLR_OPTS=-Dsolr.config.lib.enabled=true -Djava.security.manager=allow"
Environment="SOLR_HOST=127.0.0.1"
Environment="SOLR_PORT=8983"
Environment="SOLR_HEAP=512m"
ExecStart=/opt/solr/bin/solr start -f
ExecStop=/opt/solr/bin/solr stop
Restart=on-failure
LimitNOFILE=65536
TimeoutSec=180
[Install]
WantedBy=multi-user.target
Explanation: This configuration restricts Solr to listen only on localhost (127.0.0.1) for security and sets memory limits.
sudo systemctl daemon-reload
Explanation: This command reloads systemd to apply the modified Solr service configuration.
sudo systemctl restart solr
Explanation: This command restarts Solr to apply the security changes (listening on localhost only).
sudo systemctl status solr
Explanation: This command checks that Solr is running properly with the new security configuration.
Step 5: Install Tomcat 10.x
sudo apt install tomcat10 -y
Explanation: This command installs Apache Tomcat 10, which will host the DSpace web applications.
sudo systemctl status tomcat10
Explanation: This command displays the status of the Tomcat service to verify it was installed correctly.
sudo chown -R tomcat:tomcat /dspace
Explanation: This command changes ownership of the DSpace directory to the Tomcat user, allowing Tomcat to read and write to it.
sudo nano /etc/default/tomcat10
Explanation: This command opens the Tomcat environment configuration file to set Java options.
JAVA_OPTS="-Djava.awt.headless=true"
Explanation: This is the default Java options setting that needs to be modified for DSpace.
JAVA_OPTS="-Xmx2G -Xms512M -Dfile.encoding=UTF-8 -Djava.awt.headless=true"
Explanation: This sets Java heap memory to 2GB maximum, 512MB initial, with UTF-8 encoding for proper character handling.
Tomcat's systemd unit needs permission to write to certain paths.
sudo nano /lib/systemd/system/tomcat10.service
Explanation: This command opens the Tomcat systemd service file to add write permissions.
ReadWritePaths=/dspace
Explanation: This line grants Tomcat write access to the /dspace directory, which is needed for DSpace operations.
To ensure your web application can properly handle international characters, you need to configure Tomcat to use UTF-8 encoding on its main HTTP connector.
sudo nano /etc/tomcat10/server.xml
Explanation: This command opens the main Tomcat configuration file to modify the HTTP connector.
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxParameterCount="1000"
/>
Explanation: This is the default HTTP connector configuration that needs to be modified for UTF-8 support.
<!-- <Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxParameterCount="1000"
/> -->
Explanation: This comments out the default HTTP connector to replace it with a customized version.
<Connector port="8080"
minSpareThreads="25"
enableLookups="false"
redirectPort="8443"
connectionTimeout="20000"
disableUploadTimeout="true"
URIEncoding="UTF-8"/>
Explanation: This custom HTTP connector configuration enables UTF-8 encoding for proper international character support.
sudo systemctl daemon-reload
Explanation: This command reloads systemd to apply the Tomcat service changes.
sudo systemctl restart tomcat10
Explanation: This command restarts Tomcat to apply all configuration changes.
sudo systemctl status tomcat10
Explanation: This command checks that Tomcat is running properly with the new configuration.
Step 6: Create a dedicated DSpace User
For security reasons and installation directory of the DSpace
sudo useradd -m dspace
Explanation: This command creates a dedicated system user for DSpace operations with a home directory.
sudo passwd dspace
Explanation: This command sets a password for the DSpace user (you'll be prompted to enter and confirm the password).
sudo usermod -aG sudo dspace
Explanation: This command adds the DSpace user to the sudo group, granting administrative privileges.
sudo mkdir /dspace
Explanation: This command creates the main directory where DSpace will be installed.
sudo chown dspace /dspace
Explanation: This command changes ownership of the /dspace directory to the dspace user.
Step 7: Download and Set Up DSpace Backend (v9.1)
In this step, we'll download the latest DSpace 9.x backend package (currently DSpace 9.1) and prepare it for configuration and build.
sudo mkdir /opt/build
Explanation: This command creates a temporary directory for building DSpace.
sudo wget https://github.com/DSpace/DSpace/archive/refs/tags/dspace-9.1.tar.gz -P /opt/build/
Explanation: This command downloads the DSpace 9.1 source code from GitHub to the build directory.
sudo tar xzf /opt/build/dspace-9.1.tar.gz -C /opt/build/
Explanation: This command extracts the downloaded DSpace source code.
sudo mv /opt/build/DSpace-dspace-9.1/ /opt/build/dspace-backend
Explanation: This command renames the extracted directory for easier reference.
sudo rm /opt/build/dspace-9.1.tar.gz
Explanation: This command removes the downloaded archive file after extraction.
sudo chmod 777 -R /opt/build
Explanation: This command sets full permissions on the build directory to avoid permission issues during the build process.
cd /opt/build/dspace-backend/dspace/config/
Explanation: This command navigates to the DSpace configuration directory.
sudo cp local.cfg.EXAMPLE local.cfg
Explanation: This command creates the local configuration file from the example template.
sudo nano local.cfg
Explanation: This command opens the DSpace configuration file for editing.
dspace.server.url = http://localhost:8080/server
Explanation: This configuration sets the URL for the DSpace backend REST API.
dspace.ui.url = http://localhost:4000
Explanation: This configuration sets the URL for the DSpace Angular frontend.
dspace.name = DSpace at My University
Explanation: This configuration sets the name of your DSpace repository.
db.username = dspace
Explanation: This configuration sets the PostgreSQL database username for DSpace.
db.password = dspace
Explanation: This configuration sets the PostgreSQL database password for DSpace.
assetstore.dir = ${dspace.dir}/assetstore
Explanation: This configuration sets the directory where DSpace will store uploaded files.
solr.server = http://localhost:8983/solr
Explanation: This configuration sets the URL for the Solr search server.
sudo mkdir -p /dspace/assetstore
Explanation: This command creates the directory where DSpace will store uploaded files.
sudo chown -R tomcat:tomcat /dspace/assetstore
Explanation: This command sets ownership of the assetstore directory to the Tomcat user.
sudo su
Explanation: This command switches to the root user for the build process.
cd /opt/build/dspace-backend/
Explanation: This command navigates to the DSpace source code directory.
mvn package
Explanation: This command compiles the DSpace source code and creates deployment packages using Maven.
cd dspace/target/dspace-installer
Explanation: This command navigates to the DSpace installer directory created by Maven.
ant fresh_install
Explanation: This command installs DSpace to the /dspace directory using Ant.
exit
Explanation: This command exits the root user session and returns to the regular user.
sudo cp -R /dspace/webapps/* /var/lib/tomcat10/webapps
Explanation: This command copies the DSpace web applications to the Tomcat webapps directory.
sudo cp -R /dspace/solr/* /opt/solr/server/solr/
Explanation: This command copies the DSpace Solr search cores to the Solr server directory.
sudo chown -R solr:solr /opt/solr/server/solr
Explanation: This command sets ownership of the Solr cores to the Solr user.
sudo systemctl restart solr
Explanation: This command restarts Solr to load the DSpace cores.
cd /dspace/bin/
Explanation: This navigates to the DSpace binary directory where essential administrative commands are available.
sudo ./dspace database migrate
Explanation: This command initializes or updates the database schema for DSpace by applying the latest migrations.
sudo ./dspace create-administrator
Explanation: This command starts a prompt to create the initial DSpace administrator, which is required to access the admin panel.
sudo chown -R tomcat:tomcat /dspace/
Explanation: This sets proper ownership so that the Tomcat process can access and manage DSpace files without permission errors.
sudo systemctl restart tomcat10
Explanation: Restarts the Tomcat application server to load the deployed DSpace application and reflect recent changes.
sudo systemctl restart solr
Explanation: This command restarts Solr to ensure it's running with the DSpace cores.
Once the backend is deployed, you can verify it's running by accessing the following endpoints in your browser.
Note: Replace localhost with your actual server IP or domain name if accessing remotely.
http://localhost:8080/server
Explanation: This is the URL for the DSpace REST API, which should return a response if the backend is running correctly.
http://localhost:8080/server/oai/request?verb=Identify
Explanation: This is the URL for the OAI-PMH interface, which should return repository information if configured correctly.