Install DSpace 9 on Ubuntu 24.04 LTS (2025 Update)

Deploy your own open-source digital repository with this comprehensive, step-by-step guide for installing DSpace 9.0 (Release Candidate 1) on Ubuntu 24.04 LTS. This tutorial covers prerequisites, backend (API server), and frontend (dspace-angular UI) setup, aligned with official DSpace recommendations.
Target Audience: System Administrators, Repository Managers, Librarians, Developers deploying DSpace 9.
Table of Contents
- Prerequisites Checklist (Verified Requirements)
- Initial System Setup (Ubuntu 24.04)
- Install Java Development Kit (JDK 17)
- Install Build Tools (Maven & Ant)
- Install and Configure PostgreSQL (Database)
- Install Apache Solr (Search Index)
- Download DSpace 9 Backend Source Code
- Install and Configure Apache Tomcat 10.1 (Optional Servlet Engine)
- Set Up DSpace Database Schema
- Configure DSpace Backend (local.cfg)
- Build DSpace 9 Backend
- Install/Deploy DSpace 9 Backend (Option A: WAR | Option B: Runnable JAR)
- Deploy Solr Cores & Configure Permissions
- Initialize Database & Create Administrator
- Final Backend Verification & Startup
- Install DSpace 9 Frontend (dspace-angular via npm)
- Configure DSpace 9 Frontend
- Run DSpace 9 Frontend (Development vs. Production with PM2)
- Production Readiness: HTTPS Setup (Crucial!)
- Optional: Usage Statistics Geolocation Database
- Next Steps & Essential Tasks (Cron Jobs)
1. Prerequisites Checklist (Verified Requirements)
Ensure your system meets these requirements before starting.
- Operating System: Ubuntu 24.04 LTS (Fresh installation highly recommended). Other UNIX-like OS or Windows are possible but this guide focuses on Ubuntu.
- Java Development Kit (JDK): JDK 17 (LTS) required (OpenJDK recommended). Must be the full JDK, not just the JRE.
- Apache Maven: 3.8.x or higher (Avoid End-of-Life versions).
- Apache Ant: 1.10.x or later.
- PostgreSQL: Version 14.x, 15.x, 16.x, or 17.x. Ubuntu 24.04 provides v16. Requires the
pgcrypto
extension installed and enabled. UTF-8 encoding is essential (default). - Apache Solr: Version 8.x. Crucially, version 8.11.1 or higher is strongly recommended due to the critical Log4j vulnerability (CVE-2021-44228). Solr 9 is not yet fully supported without modifications. Solr must run with authentication disabled (default). Access should be firewalled.
- Servlet Engine (Optional): Required only if deploying the backend as a WAR file (Option A in Step 12). Apache Tomcat 10.1.x is needed (Tomcat 9 is NOT supported). Alternatively, Jetty 11+ or equivalent Jakarta EE 9+ compatible engine.
- DSpace Backend: Version 9.0-rc1 source code.
- DSpace Angular Frontend: Version 9.0-rc1 source code (matching version).
- Node.js: LTS versions v18.x, v20.x, or v22.x are recommended for the frontend.
- npm (Node Package Manager): Comes with Node.js. Used for frontend dependency management and build scripts.
- PM2 (Process Manager): Optional but highly recommended for running the Node.js frontend in production.
- Text Editor:
nano
orgedit
. This guide usesgedit
. (sudo apt install gedit -y
) - Essential Tools:
wget
,curl
,git
,build-essential
,zip
,unzip
.
2. Initial System Setup (Ubuntu 24.04)
Prepare the base system.
(Open Terminal: Ctrl+Alt+T
)
(Red commands executed in the terminal.)
a) Update System:
sudo apt update && sudo apt upgrade -y
b) Create DSpace OS User (Recommended):
While optional, running DSpace components (especially Tomcat if used, and the build process) under a dedicated dspace
user is good practice. The user running Tomcat must have write access to the DSpace installation directory (/dspace
).
sudo useradd -m dspace
sudo passwd dspace # Set a strong password
sudo usermod -aG sudo dspace # Grant sudo rights for setup
c) Create DSpace Installation Directory ([dspace]
):
This is where the compiled DSpace backend will reside. Let's use /dspace
.
sudo mkdir /dspace
sudo chown dspace:dspace /dspace # Assign ownership to the dspace user
d) Install Essential Tools:
sudo apt install wget curl git build-essential gedit zip unzip -y
Important: For subsequent steps, either log in as the dspace
user or continue using your admin user with sudo
where necessary. Commands assume you are logged in as a user with sudo
privileges unless otherwise specified (e.g., running builds as dspace
).
3. Install Java Development Kit (JDK 17)
DSpace 9 requires JDK 17.
sudo apt install openjdk-17-jdk -y
Verify Installation:
java -version
javac -version
Set Environment Variables:
Ensure JAVA_HOME
is set system-wide and configure default Java options.
sudo gedit /etc/environment
Add these lines at the end:
JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
JAVA_OPTS="-Xmx512M -Xms64M -Dfile.encoding=UTF-8"
Save, close, and apply:
source /etc/environment
echo $JAVA_HOME
echo $JAVA_OPTS
4. Install Build Tools (Maven & Ant)
Required for compiling and installing the DSpace backend.
sudo apt install maven ant -y
Verify Versions (Check against prerequisites):
mvn -v
ant -v
5. Install and Configure PostgreSQL (Database)
Ubuntu 24.04 provides PostgreSQL 16, which is compatible.
a) Install PostgreSQL & Contrib Package: The contrib
package includes pgcrypto
.
sudo apt-get install postgresql postgresql-client postgresql-contrib libpostgresql-jdbc-java -y
b) Check Status & Version:
sudo systemctl status postgresql # Press 'q' to exit
psql --version # Should show 16.x
c) Secure postgres
Admin User:
sudo passwd postgres # Set a strong password
d) Configure Network Access:
Ensure PostgreSQL accepts TCP/IP connections from DSpace (at least on localhost).
sudo gedit /etc/postgresql/16/main/postgresql.conf
Find #listen_addresses = 'localhost'
. Uncomment it (remove #
). 'localhost'
is usually correct if DSpace backend runs on the same server. If not, adjust accordingly (e.g., '*'
). Save and close.
e) Configure Client Authentication (pg_hba.conf
):
Allow the dspace
database user to connect via password.
sudo gedit /etc/postgresql/16/main/pg_hba.conf
Add this line near the top, before any generic rules:
# TYPE DATABASE USER ADDRESS METHOD
# DSpace configuration: Allow 'dspace' user to connect to 'dspace' db from localhost via md5 password
host dspace dspace 127.0.0.1/32 md5
Save and close.
f) Restart PostgreSQL:
sudo systemctl restart postgresql
6. Install Apache Solr (Search Index)
DSpace uses Solr for search. Use Solr 8.11.1 or higher.
a) Download Solr (e.g., 8.11.4):
cd /opt # Or another suitable location like /usr/local
sudo wget https://downloads.apache.org/lucene/solr/8.11.4/solr-8.11.4.tgz # .tgz often preferred on Linux
sudo tar xzf solr-8.11.4.tgz
sudo rm solr-8.11.4.tgz # Clean up archive
# Optional: Create a symlink for easier upgrades
# sudo ln -s /opt/solr-8.11.4 /opt/solr
b) Create Solr User (Recommended for Security):
sudo useradd -r -m -U -d /var/solr -s /usr/sbin/nologin solr
# The home dir /var/solr might be created by Solr service scripts later if using them.
c) Set Solr Ownership:
Ensure the user running Solr (e.g., solr
or dspace
) owns the Solr files. NEVER run Solr as root
in production.
sudo chown -R solr:solr /opt/solr-8.11.4
# If using the symlink: sudo chown -R solr:solr /opt/solr
d) Start Solr (Manual Start):
For production, setting up Solr as a systemd service is highly recommended (see Solr docs: Taking Solr to Production). For initial setup:
# Run as the designated Solr user (e.g., 'solr')
sudo -u solr /opt/solr-8.11.4/bin/solr start -p 8983
# To stop: sudo -u solr /opt/solr-8.11.4/bin/solr stop -p 8983
# To check status: sudo -u solr /opt/solr-8.11.4/bin/solr status
Note: Ensure port 8983 is not used by another service.
e) Verify Solr:
Open http://localhost:8983/solr
in a browser. You should see the Solr Admin UI. Crucially, ensure authentication is disabled (the default). Firewall port 8983 from public access.
Security Note (Log4j): Solr 8.11.1+ mitigates CVE-2021-44228. If using an older 8.x version (NOT RECOMMENDED), add -Dlog4j2.formatMsgNoLookups=true
to SOLR_OPTS
where Solr is started.
7. Download DSpace 9 Backend Source Code
Get the specific 9.0-rc1 release.
a) Create Build Directory:
sudo mkdir /build
sudo chown dspace:dspace /build # Grant build user ownership
cd /build
b) Download Source (as dspace
user or use sudo
):
# Option 1: As dspace user
# su - dspace
# cd /build
# wget https://github.com/DSpace/DSpace/archive/refs/tags/dspace-9.0-rc1.tar.gz
# tar zxvf dspace-9.0-rc1.tar.gz
# exit
# Option 2: With sudo
sudo wget https://github.com/DSpace/DSpace/archive/refs/tags/dspace-9.0-rc1.tar.gz -O dspace-9.0-rc1.tar.gz
sudo tar zxvf dspace-9.0-rc1.tar.gz
sudo chown -R dspace:dspace /build/DSpace-dspace-9.0-rc1 # Ensure correct ownership
Let [dspace-source]
refer to /build/DSpace-dspace-9.0-rc1
.
8. Install and Configure Apache Tomcat 10.1 (Optional Servlet Engine)
Required ONLY if deploying the backend as a WAR file (Option A in Step 12). Skip this step if using the Runnable JAR (Option B).
a) Install Tomcat 10.1:
The version in standard Ubuntu repos might be older. Check apt-cache policy tomcat10
. If it's not 10.1.x, you may need to download from tomcat.apache.org or use a PPA. Assuming apt
provides 10.1.x or you install it manually:
# Example if apt has it (VERIFY VERSION FIRST!)
sudo apt install tomcat10 # Check version carefully!
# If installed manually, follow Tomcat's documentation.
b) Configure Tomcat User Access:
Tomcat's running user (often tomcat
) needs write access to /dspace
.
- Method 1 (Change Ownership):
sudo chown -R tomcat:tomcat /dspace
(Adjust user/group if different). - Method 2 (Run Tomcat as
dspace
): Modify Tomcat startup scripts/service file to run as thedspace
user.
Method 3 (Systemd ReadWritePaths
- Debian/Ubuntu):
sudo systemctl stop tomcat10 # Stop Tomcat first
sudo systemctl edit tomcat10.service # Creates an override file
Add the following content:
[Service]
ReadWritePaths=/dspace
Save, close, then:
sudo systemctl daemon-reload
sudo systemctl start tomcat10
c) Configure Tomcat server.xml
for UTF-8:
sudo gedit /etc/tomcat10/server.xml # Path may differ for manual installs
Find the HTTP <Connector>
element (port 8080). Ensure it includes URIEncoding="UTF-8"
:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
<!-- Add other attributes like minSpareThreads, disableUploadTimeout as needed -->
d) Configure Tomcat AJP Connector (If using Apache proxy with AJP):
If you plan to use mod_proxy_ajp
with Apache HTTPD later (Step 19), uncomment or add the AJP Connector in server.xml
:
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443"
secretRequired="false" <!-- Add if needed for simpler proxy setup -->
URIEncoding="UTF-8" />
Save and close server.xml
.
e) Set Tomcat JAVA_OPTS
:
Ensure Tomcat starts with adequate memory and correct encoding. Edit the Tomcat service file or environment configuration (e.g., /etc/default/tomcat10
or systemd override) to include:JAVA_OPTS="-Xmx512M -Xms64M -Dfile.encoding=UTF-8"
(Adjust memory -Xmx
as needed).
f) Restart Tomcat:
sudo systemctl restart tomcat10.service
9. Set Up DSpace Database Schema
Create the database user and database within PostgreSQL.
a) Switch to postgres
OS User:
sudo su - postgres
b) Create DSpace Database User (dspace
):
Use the password you'll set in local.cfg
.
createuser --username=postgres --no-superuser --pwprompt dspace
# Enter password (e.g., dspace) and confirm.
c) Create DSpace Database (dspace
):
createdb --username=postgres --owner=dspace --encoding=UNICODE dspace
d) Enable pgcrypto
Extension:
psql --username=postgres dspace -c "CREATE EXTENSION pgcrypto;"
# If this fails, ensure 'postgresql-contrib' is installed.
e) (Alternative pgcrypto
Setup): See official docs for installing into a separate schema if desired (more complex).
f) Exit postgres
User:
exit
10. Configure DSpace Backend (local.cfg)
Customize DSpace settings.
a) Create local.cfg
:
cd /build/DSpace-dspace-9.0-rc1/dspace/config
sudo cp local.cfg.EXAMPLE local.cfg
sudo chown dspace:dspace local.cfg # Ensure build user owns it
b) Edit local.cfg
(as dspace
user or with sudo
):
# As dspace:
# gedit local.cfg
# Or with sudo:
sudo -u dspace gedit local.cfg
Review and set these essential properties:
dspace.dir = /dspace
(Crucial: Match Step 2c)dspace.server.url = http://localhost:8080/server
(Initial URL for backend API. Update later if using HTTPS/proxy)dspace.ui.url = http://localhost:4000
(Initial URL for frontend UI. Update later if using HTTPS/proxy)solr.server = http://localhost:8983/solr
(Uncomment and verify URL)db.url = jdbc:postgresql://localhost:5432/dspace
(Verify host/port/db name)db.driver = org.postgresql.Driver
(Default should be fine)db.dialect = org.hibernate.dialect.PostgreSQLDialect
(Default should be fine)db.username = dspace
(Matches DB user from Step 9b)db.password = dspace
(Matches password from Step 9b)db.schema = public
(Default unless you used a custom schema)
Also configure (can be done later):
dspace.name = My DSpace 9 Repository
- Mail settings (
mail.server
,mail.from.address
,feedback.recipient
,mail.admin
)
Important: Any setting from dspace.cfg
or config/modules/*.cfg
can be overridden by adding it to local.cfg
.
Save and close the file.
11. Build DSpace 9 Backend
Compile the source code using Maven. Run this as the dspace
user.
su - dspace # Switch to dspace user
cd /build/DSpace-dspace-9.0-rc1
mvn package
exit # Return to your admin user session
This creates build artifacts in [dspace-source]/dspace/target/
and the installer in [dspace-source]/dspace/target/dspace-installer/
.
12. Install/Deploy DSpace 9 Backend
Choose one of the following deployment methods:
Option A: Deploy WAR to Tomcat (Traditional)
Requires Tomcat installed (Step 8).
a) Install using Ant (Run as dspace
user):
su - dspace
cd /build/DSpace-dspace-9.0-rc1/dspace/target/dspace-installer
ant fresh_install
exit
This populates the /dspace
directory.
b) Deploy server.war
to Tomcat: Choose one technique:
Technique B (Copy WAR):
sudo cp /dspace/webapps/server.war /var/lib/tomcat10/webapps/ # Adjust Tomcat webapps path if needed
# Tomcat should auto-deploy it as /server
Technique A (Context XML): Create /etc/tomcat10/Catalina/localhost/server.xml
(path may vary):
<?xml version='1.0'?>
<Context docBase="/dspace/webapps/server" reloadable="false"/>
c) Restart Tomcat:
sudo systemctl restart tomcat10.service
Option B: Deploy Runnable JAR (New in DSpace 8+)
Does NOT require external Tomcat.
a) Install using Ant (Identical to Option A, Step a - still needed to populate /dspace
):
su - dspace
cd /build/DSpace-dspace-9.0-rc1/dspace/target/dspace-installer
ant fresh_install
exit
b) Locate the Runnable JAR:
The build process (Step 11) should have created [dspace-source]/dspace/target/server-boot.jar
. You might want to copy this JAR to a deployment location, e.g., /dspace/bin
.
# Example copy:
sudo cp /build/DSpace-dspace-9.0-rc1/dspace/target/server-boot.jar /dspace/bin/
sudo chown dspace:dspace /dspace/bin/server-boot.jar
c) Run the JAR (as dspace
user):
For production, use a process manager (like systemd or PM2) to manage this JAR. For initial testing:
# Switch to dspace user to run
su - dspace
cd /dspace/bin # Or wherever you put the JAR
java -jar server-boot.jar
# Use Ctrl+C to stop
exit
- You can override configurations via command-line arguments (e.g.,
--dspace.dir=/dspace
,--server.port=8080
) or environment variables. See DSpace docs.
13. Deploy Solr Cores & Configure Permissions
Copy the DSpace Solr core configurations to your Solr instance.
a) Copy Solr Configsets:
# Destination might be different depending on Solr setup (e.g., /var/solr/data/configsets)
SOLR_CONFIGSETS_DIR="/opt/solr-8.11.4/server/solr/configsets" # Adjust if needed
sudo cp -R /dspace/solr/* ${SOLR_CONFIGSETS_DIR}/
b) Set Ownership for Solr Cores:
The user running Solr (solr
in our example) must own these files.
sudo chown -R solr:solr ${SOLR_CONFIGSETS_DIR}/*
c) Restart Solr:
Use the command appropriate for how you started Solr (manual or service). Example for manual start:
sudo -u solr /opt/solr-8.11.4/bin/solr restart -p 8983
d) Verify Solr Cores:
Go to the Solr Admin UI (http://localhost:8983/solr
). Use the "Core Selector" dropdown on the left. You should see cores like search
, statistics
, oai
, authority
. Check the logs if they don't appear.
14. Initialize Database & Create Administrator
Prepare the database schema and create the first admin user.
a) Initialize/Migrate Database:
Run as the dspace
OS user or with sudo
.
sudo /dspace/bin/dspace database migrate
# Check output for SUCCESS.
b) Verify Database Status:
sudo /dspace/bin/dspace database info
# All migrations should show as "Success" or "Out of Order". Fix errors if any show "Pending" or "Failed".
c) Create DSpace Administrator:
sudo /dspace/bin/dspace create-administrator
Follow prompts for email, name, and password.
15. Final Backend Verification & Startup
Ensure permissions are correct and verify backend endpoints.
a) Ensure Correct Ownership of /dspace
:
If using Tomcat (Option A), ensure the Tomcat user owns /dspace
. If running the JAR (Option B), the dspace
user should own it. We set dspace:dspace
earlier, which works for the JAR method. If using Tomcat run by tomcat
, you might need: sudo chown -R tomcat:tomcat /dspace
. Adjust as per your setup.
b) Start/Restart Backend:
- Tomcat (Option A):
sudo systemctl restart tomcat10.service
- Runnable JAR (Option B): Start it using
java -jar ...
or your process manager (systemd/PM2).
c) Verify Backend Endpoints:
- REST API:
http://localhost:8080/server
(Should show API status/welcome) - OAI-PMH:
http://localhost:8080/server/oai/request?verb=Identify
(Should return XML)
16. Install DSpace 9 Frontend (dspace-angular via npm)
Set up the User Interface. Uses npm
, not yarn
.
a) Install Node.js (LTS v18/20/22) & npm:
Using NodeSource repositories is often cleaner than default apt
versions.
# Example for Node.js 20.x (LTS):
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
Verify installation:
node -v # Should be 20.x.y
npm -v
b) Install PM2 Globally (Recommended for Production):
sudo npm install --global pm2
c) Download DSpace Angular Source ([dspace-angular]
):
Place this somewhere suitable, e.g., /opt
or the dspace
user's home.
cd /opt # Or /home/dspace
sudo wget https://github.com/DSpace/dspace-angular/archive/refs/tags/dspace-angular-9.0-rc1.tar.gz
sudo tar zxvf dspace-angular-9.0-rc1.tar.gz
sudo rm dspace-angular-9.0-rc1.tar.gz
sudo chown -R dspace:dspace /opt/dspace-angular-dspace-9.0-rc1 # Grant ownership
Let [dspace-angular]
refer to /opt/dspace-angular-dspace-9.0-rc1
.
d) Install Frontend Dependencies (using npm
):
Run as the dspace
user or with sudo
.
cd [dspace-angular]
# Option 1 (as dspace user):
# su - dspace
# cd [dspace-angular]
# npm install
# exit
# Option 2 (with sudo - might need --unsafe-perm if permission issues):
sudo npm install # --unsafe-perm
17. Configure DSpace 9 Frontend
Configure the UI to connect to the backend API.
a) Create Production Configuration (config.prod.yml
):
We'll configure for production running. Create a deployment directory ([dspace-ui-deploy]
) separate from the source code ([dspace-angular]
). This minimizes downtime during rebuilds.
# Example deployment location
sudo mkdir /opt/dspace-ui-deploy
sudo chown dspace:dspace /opt/dspace-ui-deploy
Let [dspace-ui-deploy]
refer to /opt/dspace-ui-deploy
.
Create the config directory and file:
sudo mkdir [dspace-ui-deploy]/config
sudo cp [dspace-angular]/config/config.example.yml [dspace-ui-deploy]/config/config.prod.yml
sudo chown -R dspace:dspace [dspace-ui-deploy]/config # Ensure ownership
b) Edit config.prod.yml
:
sudo -u dspace gedit [dspace-ui-deploy]/config/config.prod.yml
Modify the ui
and rest
sections. Crucially, the rest
section must match the public URL of your backend (dspace.server.url
). The ui
section defines where the Node.js process listens (often localhost if using a proxy).
# Example: UI runs locally on 4000, proxied via HTTPS later. Backend is at http://localhost:8080/server initially.
ui:
ssl: false
host: localhost # Node listens on localhost
port: 4000 # Node listens on port 4000
# nameSpace: / # Usually root / is fine
# Example: Backend API URL accessible initially via HTTP
rest:
ssl: false
host: localhost
port: 8080
nameSpace: /server # Must match backend context path
- Important: Update these URLs later (Step 19) if you set up HTTPS proxying. The
rest
URL here MUST be the final, public URL the browser uses to reach the backend.
Save and close.
c) (Optional) Test REST Connection:
Copy the config back to source and run the test script.
cp [dspace-ui-deploy]/config/config.prod.yml [dspace-angular]/config/
cd [dspace-angular]
# As dspace or with sudo:
sudo npm run test:rest
Fix connection or SSL errors before proceeding.
18. Run DSpace 9 Frontend (Development vs. Production with PM2)
Option A: Development Mode (Temporary Test)
Runs directly from source, reflects code changes instantly.
cd [dspace-angular]
# May need these if memory/SSL issues occur
# export NODE_OPTIONS="--max-old-space-size=8192"
# export NODE_TLS_REJECT_UNAUTHORIZED='0' # If backend uses self-signed cert
# Run as dspace or with sudo
sudo npm run start # 'start' usually runs dev mode
Access at http://localhost:4000
(or as configured). Stop with Ctrl+C
.
Option B: Production Mode (Build and Run with PM2)
1. Build for Production: Compile the UI code into the dist
folder.
cd [dspace-angular]
# export NODE_OPTIONS="--max-old-space-size=8192" # May need more memory
# Run as dspace or with sudo
sudo npm run build:prod
2. Deploy Compiled Code: Copy the dist
folder to your deployment directory.
# Ensure target dir exists: sudo mkdir -p [dspace-ui-deploy]
sudo cp -r [dspace-angular]/dist [dspace-ui-deploy]/
sudo chown -R dspace:dspace [dspace-ui-deploy]/dist # Ensure ownership
The structure must be [dspace-ui-deploy]/dist/server/main.js
etc.
3. Create PM2 Configuration (dspace-ui.json
):
Create this file, e.g., in [dspace-ui-deploy]/dspace-ui.json
.
sudo -u dspace gedit [dspace-ui-deploy]/dspace-ui.json
Paste and carefully edit paths (cwd
, script
):
{
"apps": [
{
"name": "dspace-ui",
"cwd": "/opt/dspace-ui-deploy/", // <== SET YOUR DEPLOY PATH
"script": "dist/server/main.js", // <== Relative to cwd
"instances": "max", // Use CPU cores
"exec_mode": "cluster", // Enable cluster mode
"env": {
// Sets Node environment
"NODE_ENV": "production",
// Optional: Override config.prod.yml via ENV vars here
// "DSPACE_UI_SSL": "false",
// "DSPACE_UI_HOST": "localhost",
// "DSPACE_UI_PORT": "4000",
// "DSPACE_REST_SSL": "false",
// "DSPACE_REST_HOST": "localhost",
// "DSPACE_REST_PORT": "8080",
// "DSPACE_REST_NAMESPACE": "/server"
}
}
]
}
- For Windows, use double backslashes in paths (
C:\\path\\...
) and ensurecluster
mode.*
Save and close. Ensure dspace
user owns this file.
4. Start with PM2:
# Run as user with rights to manage PM2 (e.g., your sudo user)
sudo pm2 start [dspace-ui-deploy]/dspace-ui.json
- Check logs:
sudo pm2 logs dspace-ui
- Stop:
sudo pm2 stop dspace-ui
(use name from JSON) - Restart:
sudo pm2 restart dspace-ui
- Make PM2 start on boot:
sudo pm2 startup systemd
(follow instructions)
5. Access Frontend:
Open your browser to the URL configured in the ui
section of config.prod.yml
(e.g., http://localhost:4000
). If using a proxy (Step 19), access via the final public URL (e.g., https://your.dspace.url/
).
19. Production Readiness: HTTPS Setup (Crucial!)
Running DSpace without HTTPS in production is insecure and will likely break logins. Use a reverse proxy like Apache HTTPD or Nginx.
a) Install Apache or Nginx:
# Apache
sudo apt install apache2
sudo a2enmod proxy proxy_http headers rewrite ssl # Enable needed modules
# OR Nginx
sudo apt install nginx
b) Obtain SSL Certificate: Use Let's Encrypt (via certbot
) or purchase a commercial certificate.
# Example using certbot for Apache
sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d your.dspace.url # Replace with your domain
c) Configure Proxy:
- Goal: Proxy public HTTPS requests (
https://your.dspace.url/
) to the UI (Node.js onhttp://localhost:4000/
) and backend API (https://your.dspace.url/server/
) to Tomcat/JAR (http://localhost:8080/server
or AJPajp://localhost:8009/server
).
Nginx Example (/etc/nginx/sites-available/dspace
):
# Redirect HTTP to HTTPS
server {
listen 80;
listen [::]:80;
server_name your.dspace.url;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name your.dspace.url;
# --- SSL Config ---
ssl_certificate /etc/letsencrypt/live/your.dspace.url/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.dspace.url/privkey.pem;
# include /etc/letsencrypt/options-ssl-nginx.conf; # Recommended
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # Recommended
# --- Proxy Settings ---
location / { # UI Proxy
proxy_pass http://localhost:4000; # To Node.js
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /server { # Backend API Proxy
proxy_pass http://localhost:8080/server; # To Tomcat/JAR
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Access and error logs
access_log /var/log/nginx/dspace-access.log;
error_log /var/log/nginx/dspace-error.log;
}
Enable the site: sudo ln -s /etc/nginx/sites-available/dspace /etc/nginx/sites-enabled/
Test and reload Nginx: sudo nginx -t && sudo systemctl reload nginx
Apache HTTPD Example (/etc/apache2/sites-available/dspace-ssl.conf
):
(Assumes certbot configured basic SSL; adapt as needed)
<VirtualHost *:443>
ServerName your.dspace.url # Your public domain
# ServerAdmin admin@your.dspace.url
# --- SSL Config (Likely added by Certbot) ---
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/your.dspace.url/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/your.dspace.url/privkey.pem
# Include /etc/letsencrypt/options-ssl-apache.conf # Recommended
# --- Proxy Settings ---
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "https"
# Proxy UI requests (root /) to Node on port 4000
ProxyPass / http://localhost:4000/ retry=0
ProxyPassReverse / http://localhost:4000/
# Proxy Backend API requests (/server) to Tomcat/JAR on port 8080 (HTTP)
ProxyPass /server http://localhost:8080/server retry=0
ProxyPassReverse /server http://localhost:8080/server
# --- OR Proxy Backend via AJP (if Tomcat AJP enabled) ---
# ProxyPass /server ajp://localhost:8009/server retry=0
# ProxyPassReverse /server ajp://localhost:8009/server
ErrorLog ${APACHE_LOG_DIR}/dspace-error.log
CustomLog ${APACHE_LOG_DIR}/dspace-access.log combined
</VirtualHost>
# Optional: Redirect HTTP to HTTPS
<VirtualHost *:80>
ServerName your.dspace.url
Redirect permanent / https://your.dspace.url/
</VirtualHost>
Enable the site: sudo a2ensite dspace-ssl.conf
Reload Apache: sudo systemctl reload apache2
d) Update DSpace Configuration URLs:
After setting up HTTPS, you must update the URLs in your DSpace configurations:
- Backend (
local.cfg
): Updatedspace.server.url
anddspace.ui.url
to usehttps://your.dspace.url
. Restart Tomcat or the Runnable JAR. - Frontend (
config.prod.yml
): Update therest
section (host
,ssl: true
,port: 443
) to point to the public HTTPS backend URL (https://your.dspace.url/server
). Restart the UI via PM2 (sudo pm2 restart dspace-ui
).
20. Optional: Usage Statistics Geolocation Database
To track usage statistics by location:
- Obtain a City Database:
- MaxMind GeoLite2 City: Free, but requires signup and license key. Install
geoipupdate
tool (sudo apt install geoipupdate
), configure key in/etc/GeoIP.conf
, runsudo geoipupdate
. Database likely at/var/lib/GeoIP/GeoLite2-City.mmdb
. - DB-IP City Lite: Free, no account needed. Download the MMDB file manually.
- MaxMind GeoLite2 City: Free, but requires signup and license key. Install
- Configure DSpace: Edit
local.cfg
and setusage-statistics.dbfile
to the full path of your.mmdb
file (e.g.,/var/lib/GeoIP/GeoLite2-City.mmdb
). - Restart DSpace backend.
21. Next Steps & Essential Tasks (Cron Jobs)
- Scheduled Tasks (Cron): DSpace relies on background tasks. Set up cron jobs (usually run as the
dspace
user) for tasks like:- Media Filter (thumbnail generation, text extraction):
[dspace]/bin/dspace filter-media
- Checksum Checker:
[dspace]/bin/dspace checker
- Statistics Processing:
[dspace]/bin/dspace stats-util -u
(Update Solr stats),[dspace]/bin/dspace stats-util -o
(Update GeoIP) - Subscription Emails:
[dspace]/bin/dspace sub-daily
- See DSpace Documentation: Scheduled Tasks via Cron for details and recommended frequencies.
- Media Filter (thumbnail generation, text extraction):
- Backup: Implement a robust backup strategy for the database, assetstore (
/dspace/assetstore
), and Solr index. - Customization: Explore theming, configuration options, and integrations.
Congratulations! You have successfully installed DSpace 9 on Ubuntu 24.04. Remember to consult the official DSpace 9 Documentation for further details and advanced topics.