Please note: This guide is partly obsolete. npm is no longer used to build the server. See Dockerfile.server for the correct steps.
Hello forum,
Here are the steps I took to install Joplin Server inside of an LXC container running in Proxmox. I used Debian 11 as the base image, checked the box for unprivileged container and nesting. I would be grateful if others could try this as well and let me know if you run into any issues.
- Install needed packages
apt install -y git vim curl postgresql-13 python2.7 make gcc g++ apache2
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
apt update
apt upgrade
apt install nodejs
npm install -g pm2
- Generate https certs, be sure to enter the IP address of the server as the Common Name
openssl req -x509 -nodes -days 10000 -newkey rsa:4096 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
- Switch to postgres user to create database
su postgres
psql
CREATE DATABASE joplin;
CREATE USER joplin with password 'joplinrocks';
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO joplin;
- As root, create joplin directory and joplin user
mkdir -p /opt/joplin/packages/{fork-sax,lib}
useradd --create-home --shell /bin/bash joplin
chown -R joplin:joplin /opt/joplin
su -l joplin
git clone https://github.com/laurent22/joplin
- Copy needed files from git repo
cp joplin/packages/fork-sax/package*.json /opt/joplin/packages/fork-sax/
cp joplin/packages/lib/package*.json /opt/joplin/packages/lib/
cp joplin/lerna.json /opt/joplin/
cp joplin/tsconfig.json /opt/joplin/
cp joplin/package*.json /opt/joplin/
cp -r joplin/packages/fork-htmlparser2/ /opt/joplin/packages/
cp -r joplin/packages/turndown-plugin-gfm/ /opt/joplin/packages
cp -r joplin/packages/turndown/ /opt/joplin/packages/
cp -r joplin/packages/renderer/ /opt/joplin/packages/
cp -r joplin/packages/server/ /opt/joplin/packages/
cp -r joplin/packages/tools/ /opt/joplin/packages/
cp -r joplin/packages/lib /opt/joplin/packages/
- Build application using npm
cd /opt/joplin/
npm config set python python2.7
npm install --ignore-scripts
npm run bootstrap
npm run bootstrapServerOnly
npm run build
npm install jquery
npm i @fortawesome/fontawesome-free
- Create autostart file for PM2 to use
joplin@joplin-server:~$ cat /opt/joplin/packages/server/ecosystem.config.js
module.exports = {
apps : [
{
name: "joplin-server",
script: "/opt/joplin/packages/server/dist/app.js",
watch: false,
env: {
"DB_CLIENT": "pg",
"POSTGRES_DATABASE": "joplin",
"POSTGRES_PASSWORD": "joplinrocks",
"POSTGRES_USER": "joplin",
"APP_BASE_URL": "https://<your ip>/joplin",
"NODE_ENV": "development"
}
}
]
}
joplin@joplin-server:~$
- Add cron to joplin user to autostart server on boot
@reboot sh -c 'cd /opt/joplin/packages/server/ && pm2 start /opt/joplin/packages/server/ecosystem.config.js'
- Switch back to root user and enable proxy services in Apache
a2enmod proxy
a2enmod proxy_http
a2enmod ssl
- Create reverse proxy in Apache
root@joplin-server:~# cat /etc/apache2/sites-available/000-default-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
ProxyPass "/joplin" http://localhost:22300
ProxyPassReverse "/joplin" http://localhost:22300
ServerName <your ip>
SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
SSLEngine on
# Intermediate configuration, tweak to your needs
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
SSLHonorCipherOrder off
SSLSessionTickets off
SSLOptions +StrictRequire
# Add vhost name to log entries:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" vhost_combined
LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common
</VirtualHost>
</IfModule>
root@joplin-server:~#
- Enable site
a2ensite 000-default-ssl
- Reboot