Compile & Install Sakai LMS v20.1 with Nginx

  1. Install Git
$ sudo apt install git
$ cd /opt
$ sudo apt install tree
...
$ tree -L 2
.
├── jvm
│ └── jdk1.8.0_261
├── maven
│ └── 3.5.4
└── tomcat
└── 9.0.38
# Java env for Sakai
export JAVA_HOME=/opt/jvm/jdk1.8.0_261/
export MAVEN_HOME=/opt/maven/3.5.4/
export CATALINA_HOME=/opt/tomcat/9.0.38/
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$CATALINA_HOME/bin:$PATHexport MAVEN_OPTS='-Xms512m -Xmx1024m'
$ source ~/.bashrc
$ cd
$ git clone https://github.com/sakaiproject/sakai.git
$ cd sakai
$ git checkout 20.1
$ cd /opt
$ sudo chown -R $USER:$USER tomcat
$ cd tomcat/9.0.38
$ mkdir sakai
$ vi bin/setenv.sh
export JAVA_OPTS="-server -d64 -Xms1g -Xmx2g -Djava.awt.headless=true -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC"
JAVA_OPTS="$JAVA_OPTS -Dhttp.agent=Sakai"
JAVA_OPTS="$JAVA_OPTS -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false"
JAVA_OPTS="$JAVA_OPTS -Dsakai.security=$CATALINA_HOME/sakai/"
JAVA_OPTS="$JAVA_OPTS -Duser.timezone=US/Eastern"
JAVA_OPTS="$JAVA_OPTS -Dsakai.cookieName=SAKAI2SESSIONID"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8089 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -Dsakai.demo=true"
$ chmod +x bin/setenv.sh
$ vi conf/context.xml
<JarScanner>
<!-- This is to speedup startup so that tomcat doesn't scan as much -->
<JarScanFilter defaultPluggabilityScan="false" />
</JarScanner>
$ cd
$ cd git
$ cp config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties /opt/tomcat/9.0.38/sakai/sakai.properties
username@javax.sql.BaseDataSource=sakaiuser
password@javax.sql.BaseDataSource=sakaipassword
## MySQL settings
vendor@org.sakaiproject.db.api.SqlService=mysql
#driverClassName@javax.sql.BaseDataSource=com.mysql.jdbc.Driver
driverClassName@javax.sql.BaseDataSource=org.mariadb.jdbc.Driver
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
url@javax.sql.BaseDataSource=jdbc:mysql://127.0.0.1:3306/sakaidatabase?useUnicode=true&characterEncoding=UTF-8
validationQuery@javax.sql.BaseDataSource=
defaultTransactionIsolationString@javax.sql.BaseDataSource=TRANSACTION_READ_COMMITTED
$ sudo mysql -u root
[sudo] password for $USER:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 1145
Server version: 10.3.23-MariaDB-0+deb10u1 Debian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> create database sakaidatabase default character set utf8;
Query OK, 1 row affected (0.00 sec)

mysql> grant all on sakaidatabase.* to sakaiuser@'localhost' identified by 'sakaipassword';
Query OK, 0 rows affected (0.00 sec

mysql> grant all on sakaidatabase.* to sakaiuser@'127.0.0.1' identified by 'sakaipassword';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
$ cd ~/sakai/
$ cd master
$ mvn -version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T08:33:14-10:00)
Maven home: /opt/maven/3.5.4
Java version: 1.8.0_265, vendor: Debian, runtime: /opt/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.19.0-11-amd64", arch: "amd64", family: "unix"

$ mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.sakaiproject:master >-----------------------
[INFO] Building Sakai Master 20.1
[INFO] --------------------------------[ pom ]---------------------------------
...
$ cd ..
$ mvn clean install sakai:deploy -Dmaven.tomcat.home=$CATALINA_HOME
$ startup.sh && tail -f $CATALINA_HOME/logs/catalina.out
13-Oct-2020 18:06:46.638 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
13-Oct-2020 18:06:46.648 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [46700] milliseconds
  • User Id: admin
  • Password: admin
$ shutdown.sh
$ sudo apt install nginx
$ cd /etc/nginx/sites-available
$ vi sakai.conf
server {
server_name yourdomain.tld;
access_log /var/log/nginx/tomcat-access.log;
error_log /var/log/nginx/tomcat-error.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
}
$ cd ..
$ cd sites-enabled
$ ln -s /etc/nginx/sites-available/sakai.conf .
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8080" protocol="HTTP/1.1"
proxyName="yourdomain.tld"
proxyPort="443"
scheme="https"
connectionTimeout="20000"
redirectPort="8443" />
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl restart
$ startup.sh
$ sudo useradd -m -U -d /opt/tomcat/9.0.38 -s /bin/false tomcat
$ sudo chown -R tomcat:tomcat /opt/tomcat/9.0.38
$ sudo vi /etc/systemd/system/sakai.tomcat.service
[Unit]
Description=Tomcat 9 servlet container for Sakai
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/opt/jvm/jdk1.8.0_261"
Environment="JRE_HOME=/opt/jvm/jdk1.8.0_261"
Environment="CATALINA_BASE=/opt/tomcat/9.0.38"
Environment="CATALINA_HOME=/opt/tomcat/9.0.38"
Environment="CATALINA_PID=/opt/tomcat/9.0.38/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M"
ExecStart=/opt/tomcat/9.0.38/bin/startup.sh
ExecStop=/opt/tomcat/9.0.38/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl start sakai.tomcat.service
$ sudo systemctl status sakai.tomcat.service● sakai.tomcat.service - Tomcat 9 servlet container for Sakai
Loaded: loaded (/etc/systemd/system/sakai.tomcat.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-10-18 11:10:09 HST; 10min ago
Process: 20172 ExecStart=/opt/apache/tomcat/9.0.38/bin/startup.sh (code=exited, status=0/SUCCESS)
...
$ sudo systemctl stop sakai.tomcat.service
$ sudo systemctl status sakai.tomcat.service● sakai.tomcat.service - Tomcat 9 servlet container for Sakai
Loaded: loaded (/etc/systemd/system/sakai.tomcat.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sun 2020-10-18 11:21:21 HST; 6s ago
...
$ sudo systemctl enable sakai.tomcat.service
$ sudo systemctl start sakai.tomcat.service
  • Extra: Make a portal as the domain root
server {
server_name yourdomain.tld;
access_log /var/log/nginx/tomcat-access.log;
error_log /var/log/nginx/tomcat-error.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/portal;
}
}
server {
server_name yourdomain.tld;
location = / {
return 301 http://yourdomain.tld/portal;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store