×
Community Blog How to Install Opencast on Ubuntu 16.04

How to Install Opencast on Ubuntu 16.04

In this blog tutorial, you will be learning how to install Opencast on an Alibaba Cloud ECS instance that is installed with Ubuntu 16.04.

By Sajid Qureshi, Alibaba Cloud Community Blog author.

Opencast is a free and open-source web-based application for automated video capture and distribution. It is written in Java and uses a MySQL server to store the database. It lets you create an event that is automatically recorded on a provided schedule. You can also schedule the publication of the recordings on multiple distribution channels.

Various distribution channels are supported by Opencast, such as on-demand viewing, learning tools interoperability, Atom, RSS, and publishing to iTunes and YouTube. It has an built-in media player which can be used to view the recording and slideshows. Media Player can be easily embedded into other applications. Recorded videos can be edited and trimmed using the powerful online video editor which uses FFmpeg in the background. Many prominent organizations and universities are using Opencast on daily basis to record and schedule the events and seminars.

Requirements

  1. An Alibaba Cloud ECS instance with Ubuntu 16.04 64-bit installed.
  2. Firewall or Security group rules configured to allow the port "80", "443" and "8080".
  3. A domain name that needs to be pointed towards your ECS instance (Optional).

You can follow the "Quick Start Guide" to create the instance and steps to connect to your instance. This tutorial assumes that you have created your Alibaba instance and "192.168.0.101" is the public IP address assigned to your Ubuntu instance. You have also configured "opencast.example.com" to point to your Ubuntu instance. It is also recommended to create a sudo user instead of using the root account to run commands.

Run the following command to update the repository cache and the base system.

sudo apt update
sudo apt upgrade -y

Procedure

Installing Java

Opencast is written in Java. Since we are installing Opencast from source, we will need to install Java Development Kit (JDK). In this tutorial, we will install Oracle Java 8, however, if you wish, you can also install OpenJDK. Add the Ubuntu repository for Oracle Java 8.

sudo apt-get install software-properties-common
sudo add-apt-repository --yes ppa:webupd8team/java
sudo apt update

Install Oracle Java.

sudo apt -y install oracle-java8-installer

You can verify if Java has been installed successfully by running java -version command.

aliyun@alibaba-cloud:~$ java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

Set the default path for the Java by installing the following package.

sudo apt -y install oracle-java8-set-default

You can verify if JAVA_HOME is set by running.

echo $JAVA_HOME

You should see.

aliyun@alibaba-cloud:~$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle

If you see no output at all, you will need to log out from the current shell and log back in.

Installing Dependencies

Opencast required several dependencies such as build tools, Tesseract, sox etc. Install the dependencies.

sudo apt -y install git unzip build-essential hunspell tesseract-ocr sox 

It also requires FFmpeg to edit video files. Add FFmpeg repository.

sudo add-apt-repository --yes ppa:jonathonf/ffmpeg-3
sudo apt update

Install FFmpeg.

sudo apt -y install ffmpeg

Check the version of installed FFmpeg, it should be greater than "3.2.4".

aliyun@alibaba-cloud:~$ ffmpeg -version
ffmpeg version 3.4.4-1~16.04.york0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
...

Since we are building Opencast from source, We also require Apache Maven. Maven is a project management tool primarily used for Java applications.

Download the latest version of Maven from it's official website.

cd /tmp
wget https://www-eu.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz

Extract and move the Maven binaries.

tar -xf apache-maven-3.6.0-bin.tar.gz
sudo mv apache-maven-*/ /opt/maven/

Add Maven to PATH variable.

echo 'export PATH="/opt/maven/bin:$PATH"' | tee -a ~/.bashrc
source ~/.bashrc

Check if Apache Maven has been installed successfully by verifying its version using mvn -version. You should see.

aliyun@alibaba-cloud:/tmp$ mvn -version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: /opt/maven
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-117-generic", arch: "amd64", family: "unix"

Installing ActiveMQ

Apache ActiveMQ is an open source message broker system. Opencast requires the ActiveMQ as message relay for the administrative user interface.

Download the latest version of Apache ActiveMQ from it's official website.

cd /tmp
wget -O apache-activemq-5.15.7-bin.tar.gz "http://www.apache.org/dyn/closer.cgi?filename=/activemq/5.15.7/apache-activemq-5.15.7-bin.tar.gz&action=download"

Extract the archive and move into /opt directory.

tar -xf apache-activemq-5.15.7-bin.tar.gz
sudo mv apache-activemq-*/ /opt/activemq/

We will create a startup script to easily start and manage the ActiveMQ process. It will also ensure that ActiveMQ is automatically started on failures and system reboots.

sudo nano /etc/systemd/system/activemq.service

Enter the following configuration.

[Unit]
Description=ActiveMQ service
After=network.target

[Service]
Type=forking
ExecStart=/opt/activemq/bin/activemq start
ExecStop=/opt/activemq/bin/activemq stop
Restart=always
RestartSec=9
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=activemq

[Install]
WantedBy=multi-user.target

Start the ActiveMQ service and enable it to automatically start at boot time.

sudo systemctl start activemq
sudo systemctl enable activemq

To check if the service is running, you can check the status of the ActiveMQ service.

sudo systemctl status activemq

You should get the following output.

aliyun@alibaba-cloud:/tmp$ sudo systemctl status activemq
● activemq.service - ActiveMQ service
   Loaded: loaded (/etc/systemd/system/activemq.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-11-18 17:52:15 CST; 243ms ago
 Main PID: 7129 (java)
   CGroup: /system.slice/activemq.service
           └─7129 /usr/bin/java -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/opt/activemq//conf/login.config -Dcom.sun.ma

Nov 18 17:52:15 alibaba-cloud systemd[1]: Starting ActiveMQ service...
Nov 18 17:52:15 alibaba-cloud activemq[7089]: INFO: Loading '/opt/activemq//bin/env'
Nov 18 17:52:15 alibaba-cloud activemq[7089]: INFO: Using java '/usr/bin/java'
Nov 18 17:52:15 alibaba-cloud activemq[7089]: INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
Nov 18 17:52:15 alibaba-cloud activemq[7089]: INFO: pidfile created : '/opt/activemq//data/activemq.pid' (pid '7129')
Nov 18 17:52:15 alibaba-cloud systemd[1]: Started ActiveMQ service.

To check if ActiveMQ is working correctly you can browse to http://192.168.0.101:8161/admin. Log in using the default credentials with username admin and password admin. You should see ActiveMQ web administration interface.

Configuring a Database

Opencast needs MySQL server to store its data. Alibaba Cloud provides ApsaraDB for RDS which is a relational database service. For production grade environment, it is strongly recommended to use ApsaraDB for RDS . However you also have option to install the database server on the same ECS instance. In this tutorial, we will use the local MySQL to host the opencast database. However you should consider using

MariaDB is an open source fork of MySQL. Add the MariaDB repository to your system. The default Ubuntu repository contains an older version of MariaDB.

sudo apt-key adv --yes --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mariadb.biz.net.id/repo/10.2/ubuntu xenial main'
sudo apt update

Install MariaDB. During installation, the installer will ask for the password of the MySQL root user. Provide a strong password.

sudo apt -y install mariadb-server

Start MariaDB and enable it to automatically start at boot time.

sudo systemctl start mariadb.service 
sudo systemctl enable mariadb.service

Before configuring the database, you will need to secure the MariaDB instance.

sudo mysql_secure_installation

You will be asked for the current MariaDB root password and then prompted to change the root password. Since we already set a strong password for the root user during installation, skip it by answering "N". For all other questions, answer "Y". The questions asked are self-explanatory.

Log on to the MySQL shell as root.

mysql -u root -p

Provide the password for the MariaDB root user to log in.

Run the following queries to create a database and a database user for the Opencast installation.

CREATE DATABASE opencast CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'opencast_user'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON opencast.* TO 'opencast_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

You can replace the database name opencast and username opencast_user according to your choice. Please make sure to change StrongPassword to a very strong password.

Configuring a Data Disk (Optional)

Since Opencast is a video capture and distribution platform, you may require storage larger than the disk space that comes with the instance. It is recommended to store the data files such as videos and other media onto a separate data disk than the system disk.

To create a new data disk, navigate to Block Storage -> Disks under ECS web console and click on Create Disk button. Choose the same region and zone in which your ECS instance is running. Provide a size for your disk and choose SSD Cloud Disk for maximum performance.

3

Once your disk is created, you will need to mount it on the opencast ECS instance. Go to the management page of the data disk and click on Mount button. Now choose the opencast instance and mount it to that instance.

4

Once your disk is mounted, return back to the command line and check for disk on terminal using the command sudo fdisk -l. You should see your data disk mounted at /dev/vdb.

aliyun@alibaba-cloud:~$ sudo fdisk -l
Disk /dev/vda: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x77ba45a4

Device     Boot Start      End  Sectors Size Id Type
/dev/vda1  *     2048 41940991 41938944  20G 83 Linux


Disk /dev/vdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Before you can start using the disk, you will need to format it. Run the following commands for same.

sudo parted -s /dev/vdb mklabel gpt
sudo parted -s /dev/vdb unit mib mkpart primary 0% 100%

Create the file system on the new disk.

sudo mkfs.ext4 /dev/vdb1

Mount the block storage drive.

sudo mkdir /mnt/opencast-media
sudo cp /etc/fstab /etc/fstab.backup
echo "
/dev/vdb1 /mnt/opencast-media ext4 defaults,noatime 0 0" | sudo tee -a /etc/fstab
sudo mount /mnt/opencast-media

Now, run df -h, and you will see the new block storage drive mounted on /mnt/opencast-media.

aliyun@alibaba-cloud:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            2.0G     0  2.0G   0% /dev
tmpfs           396M  2.8M  393M   1% /run
/dev/vda1        20G   14G  4.7G  75% /
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
tmpfs           396M     0  396M   0% /run/user/0
/dev/vdb1        200G   44M   199G   1% /mnt/opencast-media

Installing Opencast

Create a new unprivileged user for the installation of Opencast. This user will be used to run the Opencast process. Running the processes with a non-sudo user will ensure the security of the system even if the application is somehow compromised.

sudo useradd -r -d /opt/opencast opencast

Download the Opencast Source code using Git.

cd ~
git clone https://github.com/opencast/opencast.git opencast_source
cd opencast_source

Check for the tags associated with all the releases.

git tag

You should see a list of all releases with the most recent release at the end.

...
4.3
4.4
4.5
5.0
5.1
5.2

Checkout the latest release using the following command.

git checkout 4.3

Build the code using Apache Maven.

mvn clean install -DskipTests

Building the code will require several minutes. Maven will create separate binaries for all the modules of Opencast installation along with an all-in-one distribution package which includes all the modules of Opencast. Since we are installing Opencast on a single node with all the features, we will go with the all-in-one package. Extract the package.

cd build
tar -xf opencast-dist-allinone*.tar.gz

Move the files to its desired location.

sudo mv opencast-dist-allinone*/ /opt/opencast/

Provide the ownership to the Opencast user.

sudo chown -R opencast:opencast /opt/opencast

Import database schema and initial data for Opencast installation. You will need to provide the MySQL root user's password.

cd /opt/opencast
mysql -u root -p opencast < docs/scripts/ddl/mysql5.sql

You can verify if the import is successful by listing the tables in opencast database. Provide the password of the opencast_user when prompted.

mysql -u opencast_user -p -D opencast -e "SHOW TABLES;"

You should see the following output.

aliyun@alibaba-cloud:/opt/opencast$ mysql -u opencast_user -p -D opencast -e "SHOW TABLES;"
Enter password: 
+--------------------------------+
| Tables_in_opencast             |
+--------------------------------+
| SEQUENCE                       |
| oc_acl_episode_transition      |
| oc_acl_managed_acl             |
| oc_acl_series_transition       |
| oc_annotation                  |
| oc_assets_asset                |
| oc_assets_properties           |
| oc_assets_snapshot             |
...
...

Edit the Opencast configuration file to make few changes in the configuration.

sudo nano /opt/opencast/etc/custom.properties

Modify the configuration as instructed below.

Set your Opencast URL.

org.opencastproject.server.url=http://192.168.0.101:8080

Provide the initial administrator username and password. The password can be changed from administration panel later.


org.opencastproject.security.admin.user=admin
org.opencastproject.security.admin.pass=opencast

Provide the administrator email address.


org.opencastproject.admin.email=admin@example.com

Uncomment and set the MySQL database server details and database credentials.

org.opencastproject.db.ddl.generation=false
org.opencastproject.db.vendor=MySQL
org.opencastproject.db.jdbc.driver=com.mysql.jdbc.Driver
org.opencastproject.db.jdbc.url=jdbc:mysql://localhost/opencast
org.opencastproject.db.jdbc.user=opencast_user
org.opencastproject.db.jdbc.pass=StrongPassword

If you are using a data disk to store the media files on a separate disk, edit the following option. If not, leave the default value.

org.opencastproject.storage.dir=/mnt/opencast-media

Save the file and exit from the editor. If you are using a data disk, provide the ownership of the media directory to the Opencast user.

sudo chown -R opencast:opencast /mnt/opencast-media

Open the web server configuration file.

sudo nano /opt/opencast/etc/org.ops4j.pax.web.cfg

Set the listening address to 0.0.0.0 so that the application can be accessed outside the network.

org.ops4j.pax.web.listening.addresses=0.0.0.0

Save the file and exit from the editor.

Open the environment configuration file.

sudo nano /opt/opencast/bin/setenv

At the end of the file, set the environment variable of JAVA_HOME. You can check the value of the JAVA_HOME using the command echo $JAVA_HOME. It configuration should look like the following.

...
export JAVA_MAX_MEM=1G
export JAVA_PERM_MEM=256M
export JAVA_HOME=/usr/lib/jvm/java-8-oracle

Save the file and exit from editor.

Opencast provides a replacement configuration for Apache ActiveMQ. It is important to use the configuration provided by Opencast rather than the default one. Create a backup of the existing ActiveMQ configuration.

sudo mv /opt/activemq/conf/activemq.xml /opt/activemq/conf/activemq.xml.backup

Copy the configuration provided by Opencast.

sudo cp /opt/opencast/docs/scripts/activemq/activemq.xml /opt/activemq/conf/activemq.xml

Opencast ActiveMQ configuration disables the web administration console of ActiveMQ. For running Opencast, there is no need for the web administration console, however, if you still wish to enable the console, edit the configuration file.

sudo nano /opt/activemq/conf/activemq.xml

Scroll down to find the following line at the end.

<!--<import resource="jetty.xml"/>-->

Uncomment it and save the file.


<import resource="jetty.xml"/>

Restart Apache ActiveMQ so that the change in configuration is implemented.

sudo systemctl restart activemq

Opencast provides a startup script to easily start and manage the Opencast server processes. Copy the Service file.

cd /opt/opencast
sudo cp docs/scripts/service/opencast.service /etc/systemd/system/

Reload the Systemd units.

sudo systemctl daemon-reload

Now, you can start the Opencast service using the following command.

sudo systemctl start opencast.service

Enable the service to automatically start at boot time and failures.

sudo systemctl enable opencast.service

Check the status of the service.

sudo systemctl status opencast.service

If the server is successfully started, you should see the following output.

aliyun@alibaba-cloud:/opt/opencast$ sudo systemctl status opencast.service
● opencast.service - Opencast
   Loaded: loaded (/etc/systemd/system/opencast.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-11-18 18:45:40 CST; 6s ago
     Docs: https://docs.opencast.org
 Main PID: 15278 (start-opencast)
   CGroup: /system.slice/opencast.service
           ├─15278 /bin/sh /opt/opencast/bin/start-opencast server
           └─15343 /usr/lib/jvm/java-8-oracle/bin/java -server -Xms128M -Xmx1G -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dorg.eclipse.jetty.server.Request.maxFormCont

Nov 18 18:45:40 alibaba-cloud systemd[1]: Started Opencast.

Browse the URL http://192.168.0.101:8080 using your favorite web browser, you should see the Opencast login page.

5

Log on using the administrator user credentials entered in the configuration file and you should see the events page.

6

Configuring NGINX as a Reverse Proxy

By default, the Opencast server listens to the port 8080 on unsecured connections. It is not recommended exposing the inbuilt Jetty web server to the internet but to set up a production-grade web server such as Nginx or Apache as a reverse proxy to forward the incoming requests. In this section of the tutorial, we will install and secure Nginx web server with Let's Encrypt free SSL certificates.

Install the Nginx web server.

sudo apt -y install nginx

Start the Nginx web server and enable it to automatically start at boot time.

sudo systemctl start nginx
sudo systemctl enable nginx

Add Certbot repository, which is a client application for the Let's Encrypt CA.

sudo add-apt-repository --yes ppa:certbot/certbot
sudo apt update

Install Certbot.


sudo apt -y install certbot

Note: To obtain certificates from Let's Encrypt CA, the domain for which the certificates are to be generated must be pointed towards the server. If not, make the necessary changes to the DNS records of the domain and wait for the DNS to propagate before making the certificate request again. Certbot checks the domain authority before providing the certificates.

Generate the SSL certificates.

sudo certbot certonly --webroot -w /var/www/html/ -d opencast.example.com

The generated certificates are likely to be stored in /etc/letsencrypt/live/opencast.example.com/ directory. Let's Encrypt certificates are expired in 90 days, hence it is recommended to set up auto-renewal of the certificates using the Cron jobs.

Open the cron job file for root user.

sudo crontab -e

Add the following line at the end of the file.

30 5 * * * /usr/bin/certbot renew --quiet

The above cron job will run every day at 5:30 AM. If the certificate is due for expiry, it will automatically renew them.

Create a new configuration file for the Opencast proxy.

sudo nano /etc/nginx/sites-available/opencast

Populate the file with.

server {
    listen 80;
    server_name opencast.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name opencast.example.com;

    root html;
    index index.html index.htm;

    ssl on;
    ssl_certificate         /etc/letsencrypt/live/opencast.example.com/fullchain.pem;
    ssl_certificate_key     /etc/letsencrypt/live/opencast.example.com/privkey.pem;

    ssl_session_cache      shared:SSL:10m;
    ssl_session_timeout  1440m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
            
    gzip on;
    
    location / {
      proxy_pass         http://localhost:8080;
      proxy_redirect     off;

      proxy_set_header   Host             $host;
      proxy_set_header   X-Real-IP        $remote_addr;
      proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
   }  
 }

Check for the errors in the new configuration file.

sudo nginx -t

If you see the following output, the configuration is error free.

aliyun@alibaba-cloud:/opt/opencast$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

If you have received some kind of error, double check the path to the SSL certificates. Activate the Opencast configuration file.

sudo ln -s /etc/nginx/sites-available/opencast /etc/nginx/sites-enabled/opencast

Restart the Nginx web server to implement the change in configuration.

sudo systemctl restart nginx

Open Opencast configuration file.

sudo nano /opt/opencast/etc/custom.properties

Set your Opencast URL.

org.opencastproject.server.url=https://opencast.example.com

Restart the Opencast server.

sudo systemctl restart opencast

Now you can access the Opencast dashboard at https://opencast.example.com. You will see that the connections to Opencast are now secured with SSL. Log in using the administrator credentials you have created and start using the Opencast by creating your first event. Once your first event is created, you can view it on its feature rich web player at https://opencast.example.com/engage/ui.

7

1 0 0
Share on

Alibaba Clouder

1,940 posts | 433 followers

You may also like

Comments

5676565643125508 October 3, 2019 at 9:32 pm

Hi, Greg Logan from Opencast here! These instructions are great, especially the portions dealing with Alibaba infrastructure components. A few notes regarding the Opencast components: You're recommending a very, very out of date version of Opencast. At the time of this post, new users should only be installing Opencast 7. We also have Ansible scripts to install things, as well as Debian/Ubuntu packages to make life easier. If you want a recent version of Opencast, check out the Administration docs on https://docs.opencast.org!