Installation of Tomcat9, Java8 and Mysql configuration on ubuntu 20.04
first, Before anything check if you have any java version install on the ubuntu machine or server before installing it.
ctrl + alt + t
sudo update-alternatives --config java
sudo apt-get remove <package_name>
sudo apt-get purge <java_version>
java -version
sudo apt-get update
sudo apt install openjdk-8-jdk
sudo apt-get update
java -version
We are going to remove any existing tomcat version and install the correct version tomcat9
ctrl + alt + t
sudo service tomcat6 stop
sudo apt-get autoremove --purge tomcat6
sudo apt-get autoremove --purge tomcat6
sudo apt-get update
sudo apt install tomcat9
sudo apt install tomcat9-docs tomcat9-examples tomcat9-admin
sudo apt-get update
sudo service tomcat9 status
After Checking TomCat9 Status Screenshot:
Now, we are going to configure the tomcat config,
ctrl + alt + t
sudo nano /etc/tomcat9/server.xml
maxPostSize= "209715200"
URIEncoding="UTF-8"
relaxedQueryChars="[,]"
After Adding lines to Connector to 200MB Screenshot:
sudo nano /usr/share/tomcat9-admin/manager/WEB-INF/web.xml
<max-file-size>209715200</max-file-size>
<max-request-size>209715200</max-request-size>
After adding the lines to Multipart Config Screenshot:
sudo nano /var/lib/tomcat9/conf/catalina.properties
org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
After adding the line Screenshot:
sudo nano /etc/tomcat9/tomcat9-users.xml
<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="admin" password="PASSWORD" roles=" tomcat, manager-gui, admin-gui"/>
After adding the lines and editing the password:
sudo nano /etc/default/tomcat9
JAVA_OPTS="${JAVA_OPTS} -Xmx2048m -Xms1024m -XX:PermSize=512m -XX:MaxPermSize=512m -XX:NewSize=256m"
sudo mkdir /var/lib/OpenMRS
sudo chown -R tomcat:tomcat /var/lib/OpenMRS/
sudo chmod -R 755 /var/lib/OpenMRS*
"sudo chown -R tomcat:tomcat /var/lib/OpenMRS/" changes the owner and group of the "/var/lib/OpenMRS/" directory and its contents to "tomcat" user and group.
"sudo chmod -R 755 /var/lib/OpenMRS*" sets the file permissions of all files and directories that start with "/var/lib/OpenMRS" to 755 recursively
sudo nano /lib/systemd/system/tomcat9.service
- SyslogIdentifier=tomcat9
StandardOutput=append:/var/log/tomcat9/catalina.out
StandardError=append:/var/log/tomcat9/catalina.out
as shown:
ReadWritePaths=/var/lib/OpenMRS/
at end you should have this:
sudo mkdir /etc/systemd/system/tomcat9.service.d
sudo nano /etc/systemd/system/tomcat9.service.d/logging-allow.conf
as show below:
ReadWritePaths=/var/lib/OpenMRS
as shown:
sudo systemctl daemon-reload
sudo systemctl restart tomcat9
sudo service tomcat9 start
sudo service tomcat9 stop
sudo service tomcat9 restart
sudo service tomcat9 status
if you have existing different version of mysql, uninstall the proceed as stated:
ctrl + alt + t
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'
sudo add-apt-repository 'deb http://kr.archive.ubuntu.com/ubuntu xenial main'
sudo apt update
sudo apt-get install mysql-server-5.6
sudo touch /var/run/mysqld/mysql.sock
sudo chown mysql:mysql /var/run/mysqld
sudo update-rc.d mysql defaults
sudo service mysql restart
sudo service mysql start
sudo service mysql stop
sudo service mysql restart
sudo service mysql status
By default the dump database will be store in /Home/ directory
sudo mysqldump -uUSER -pPASSWORD openmrs > FACILITYDUMPDATABASE.sql
locate the setup script.sh
To make the script executable, run the command. [setup_script is the script name]:
sudo chmod +x setup_script.sh
./setup_script.sh
locate to modules folder and make sure they are owned by tomcat. if not then change them. cd /var/lib/OpenMRS/modules
ll
sudo chown tomcat:tomcat *.omod
sudo chmod 755 *.omod
cd /var/lib/tomcat/webapps
sudo chown tomcat:tomcat openmrs.war
sudo mysql -uUSER -pPASSSWORD;
show databases;
use openmrs;
source /location/to/your/backup/database;
incase of any question please DM^ Whatsapp