ssh root@IP_Address -p Port_number<\/pre>\nYou will need to replace \u2018IP_Address\u2018 and \u2018Port_number\u2018 with your server\u2019s respective IP address and SSH port number. Additionally, replace \u2018root\u2019 with the username of the system user with sudo privileges.<\/p>\n
You can check whether you have the proper Debian version installed on your server with the following command:<\/p>\n
$ lsb_release -a<\/pre>\nYou should get this output:<\/p>\n
No LSB modules are available.\r\nDistributor ID: Ubuntu\r\nDescription: Ubuntu 20.04.3 LTS\r\nRelease: 20.04\r\nCodename: focal<\/pre>\nBefore starting, you have to make sure that all Ubuntu OS packages installed on the server are up to date. You can do this by running the following commands:<\/p>\n
$ sudo apt update -y\r\n$ sudo apt upgrade -y<\/pre>\n<\/span>Step 2. Install Dependencies<\/span><\/h2>\nIn order to install Jasper Reports for a production server, we are going to install it manually instead of using the installer. To proceed with this, we need to have at least Java version 8 to be able to run Tomcat 9 which we are going to install in the next step. Let’s run the command below to install default JDK version 11, which is available on the built-in Ubuntu 20.04 repositories by using the following command:<\/p>\n
$ sudo apt install default-jdk unzip wget -y<\/pre>\n<\/span>Step 3. Create a System User<\/span><\/h2>\nIt is not recommended to run Tomcat as root, so for security reasons, we will create a new system user to run Tomcat.<\/p>\n
$ sudo useradd -r tomcat -m -d \/opt\/tomcat --shell \/bin\/bash<\/pre>\nCheck the path of Tomcat\u2019s home by running this command:<\/p>\n
<\/span>Step 4. Install MariaDB<\/span><\/h2>\nNext, we will install MariaDB server from the repository. To do this, simply run the following command:<\/p>\n
$ sudo apt install mariadb-server<\/pre>\nMariaDB will be running upon installation, now let’s create a MySQL user with full privileges.<\/p>\n
MariaDB [(none)]> grant all on *.* to master@localhost identified by 'm0d1fyth15';\r\nMariaDB [(none)]> flush privileges;\r\n\r\n<\/pre>\n<\/span>Step 5. Install Tomcat<\/span><\/h2>\nIn this step, we are going to install Tomcat and run it under the user ‘tomcat’ we created earlier. When writing this tutorial, the latest stable Tomcat to download is version 9.0.62. You can go to https:\/\/tomcat.apache.org\/download-90.cgi and check if they release the more recent version. To proceed with the installation, let\u2019s download the binary distribution file first.<\/p>\n
$ su - tomcat\r\n$ wget https:\/\/dlcdn.apache.org\/tomcat\/tomcat-9\/v9.0.62\/bin\/apache-tomcat-9.0.62.tar.gz -O tomcat-9.0.62.tar.gz<\/pre>\nTomcat will be installed in the directory \/opt\/tomcat, the directory itself has already been created when we were creating user ‘tomcat’ in the previous step. Let’s extract the downloaded file now.<\/p>\n
$ tar -xzvf tomcat-9.0.62.tar.gz -C \/opt\/tomcat --strip-components=1<\/pre>\nNow, exit from user ‘tomcat’ and go back to the root or your sudo user.<\/p>\n
$ exit<\/pre>\nLet’s create systemd service file for Tomcat.<\/p>\n
$ sudo nano \/etc\/systemd\/system\/tomcat.service<\/pre>\nPaste the following into the systemd service file, then save it.<\/p>\n
[Unit]\r\nDescription=Apache Tomcat\r\nAfter=network.target\r\n\r\n[Service]\r\nType=forking\r\n\r\nUser=tomcat\r\nGroup=tomcat\r\n\r\nEnvironment=JAVA_HOME=\/usr\/lib\/jvm\/java-1.11.0-openjdk-amd64\r\nEnvironment=CATALINA_PID=\/opt\/tomcat\/tomcat.pid\r\nEnvironment=CATALINA_HOME=\/opt\/tomcat\r\nEnvironment=CATALINA_BASE=\/opt\/tomcat\r\nEnvironment=\"CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC\"\r\n\r\nExecStart=\/opt\/tomcat\/bin\/startup.sh\r\nExecStop=\/opt\/tomcat\/bin\/shutdown.sh\r\n\r\nExecReload=\/bin\/kill $MAINPID\r\nRemainAfterExit=yes\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n\r\n<\/pre>\nSave the file and reload systemd.<\/p>\n
$ sudo systemctl daemon-reload<\/pre>\nWe are not going to start Tomcat now, so let’s not run Tomcat at this moment.<\/p>\n
<\/span>Step 6. Download and Deploy JasperReports<\/span><\/h2>\nIn this step, we will download the Jasper Reports server zipped file and install it manually. When writing this article, the latest available version is 8.0.0. You can check if they have the more recent version at https:\/\/sourceforge.net\/projects\/jasperserver\/files\/JasperServer\/.<\/p>\n
$ su - tomcat\r\n$ wget https:\/\/sourceforge.net\/projects\/jasperserver\/files\/JasperServer\/JasperReports%20Server%20Community%20edition%208.0.0\/TIB_js-jrs-cp_8.0.0_bin.zip\/download -O jasperreports_8.0.0.zip<\/pre>\nOnce downloaded, we can extract it directly.<\/p>\n
$ unzip jasperreports_8.0.0.zip<\/pre>\nJasper Reports server supports PostgreSQL, MySQL, Oracle, DB2, and SQL servers. In this article, we are going to use MySQL (MariaDB) and we already installed it. To proceed with the Jasper Report configuration file, let’s copy the sample configuration file first.<\/p>\n
Let’s copy \/opt\/jasperreports-server-cp-8.0.0-bin\/buildomatic\/sampe-conf\/mysql.master_properties to buildomatic as default_master.properties<\/p>\n
$ cp jasperreports-server-cp-8.0.0-bin\/buildomatic\/sample_conf\/mysql_master.properties jasperreports-server-cp-8.0.0-bin\/buildomatic\/default_master.properties<\/pre>\nIn this file, we need to set or modify the existing setting with the following values.<\/p>\n
CATALINA_HOME = \/opt\/tomcat\r\nCATALINA_BASE = \/opt\/tomcat\r\n\r\ndbHost=localhost\r\ndbUsername=master\r\ndbPassword=m0d1fyth15\r\n\r\nencrypt = true<\/pre>\nSave the file then exit. Make sure the MySQL database user and password are correct. It should look like this.<\/p>\n
<\/p>\n
Next, let’s enter the buildomatic directory and run the js-install-ce.sh executable file. Prior to running this executable file, make sure Tomcat is NOT running.<\/p>\n
$ cd jasperreports-server-cp-8.0.0-bin\/buildomatic\/\r\n$ .\/js-install-ce.sh<\/pre>\nThis will create databases and deploy the jasperserver in Tomcat.<\/p>\n
Then, let’s edit \/opt\/tomcat\/conf\/catalina.policy file.<\/p>\n
$ nano \/opt\/tomcat\/conf\/catalina.policy<\/pre>\nInsert the following into the file.<\/p>\n
grant codeBase \"file:\/groovy\/script\" {\r\n permission java.io.FilePermission \"${catalina.home}${file.separator}webapps${file.separator}\r\n jasperserver-pro${file.separator}WEB-INF${file.separator}classes${file.separator}-\", \"read\";\r\n permission java.io.FilePermission \"${catalina.home}${file.separator}webapps${file.separator}\r\n jasperserver-pro${file.separator}WEB-INF${file.separator}lib${file.separator}*\", \"read\";\r\n permission java.util.PropertyPermission \"groovy.use.classvalue\", \"read\";\r\n};<\/pre>\nSave the file then exit.<\/p>\n
Then, we also need to edit applicationContext.xml file.<\/p>\n
$ nano \/opt\/tomcat\/webapps\/jasperserver\/WEB-INF\/applicationContext.xml<\/pre>\nInsert these into the reportsProtectionDomainProvider list.<\/p>\n
<bean id=\"reportsProtectionDomainProvider\" class=\"com.jaspersoft.jasperserver.api.\r\nengine.jasperreports.util.PermissionsListProtectionDomainProvider\">\r\n<property name=\"permissions\">\r\n<list>\r\n <bean class=\"java.io.FilePermission\">\r\n <constructor-arg value=\"${catalina.home}${file.separator}webapps\r\n ${file.separator}jasperserver-pro${file.separator}\r\n WEB-INF${file.separator}classes${file.separator}-\"\/>\r\n <constructor-arg value=\"read\"\/>\r\n <\/bean>\r\n <bean class=\"java.io.FilePermission\">\r\n <constructor-arg value=\"${catalina.home}${file.separator}webapps\r\n ${file.separator}jasperserver-pro${file.separator}WEB-INF\r\n ${file.separator}lib${file.separator}*\"\/>\r\n <constructor-arg value=\"read\"\/>\r\n <\/bean>\r\n<\/list>\r\n<\/property>\r\n<\/bean><\/pre>\nIt should look like in the picture below.<\/p>\n
<\/p>\n
Once completed, you can start Tomcat and wait for a few moments until everything is running.<\/p>\n
$ sudo systemctl start tomcat<\/pre>\nThen, you can navigate to http:\/\/YOUR_SERVER_IP_ADDRESS:8080\/jasperserver\/ to access JasperReports Server using the default login credentials.<\/p>\n
username: jasperadmin\r\npassword: jasperadmin\r\n\r\n<\/pre>\n