Januarry 2024 - Ubuntu Server 22.04 MySQL Tomcat 8.5 Java 8 Dear everyone.
The last few days I tried to install OpenMRS on a Ubuntu Server 22.04, Windows 10 and Windows 11 PC. Let me tell you i refreshed a lot of my IT knowledge. First of ALL I like the Project. Its amazing and I wish it will go on for many years like it had already. Sadly I need to say something bad too. The Installation is not simple and not at all easy and I’m afraid that this will cause issues with the Project in the future. So to Everyone that is making 3.0. MAKE IT EASY.
So now my current problem and I know it has not much to do with OpenMRS but to make it run its part of it. Every time my server starts i need to manually start Tomcat but from that it works.
Here now my Installation:
Ubuntu Server 22.04
- Installation → give user and password.
- in the installation allow SSH if you like to do the installation from the couch
- install all current upgrdes
sudo apt-get upgrades
- and update the system
sudo apt-get update
- Name of the Server
hostname -A
- IP of the Server hostname -I
///Useful progams and commands///
- tree floders and files
sudo apt-get install tree
tree /path/to/folder
//////////////
- finds folders and files
sudo apt install locate
- update database
sudo updatedb
- finde file/folder locate tomcat
///- commands
- see all user
awk -F: ‘{ print $1 }’ /etc/passwd
- check what group is created
getent group
//////
Change timezone in Ubuntu Server
- check timezone
timedatectl
cat /etc/timezone
- check location
ls -l /etc/localtime
- this option is: select the time more = quit easy
sudo dpkg-reconfigure tzdata
- check timezone
timedatectl
///////////
login via SSH or continue on server
Next step I’m not sure if it is necessary or if it is needed but its in the instructions on the official homepage
*Install Firefox
sudo apt install firefox
ROOT AREA WATCH OUT!!!
sudo -i
Install JAVA 8
- yes there are newer versions but it needs to work with all the components
apt install openjdk-8-jdk
- check your version
java -version
Install Tomcat
- Check which version of tomcat is supported with which java
- browser or mobile → Apache Tomcat® - Which Version Do I Want?
- add a group
groupadd tomcat
- add user tomcat useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
download and install tomcat
wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.97/bin/apache-tomcat-8.5.97.tar.gz
- Create a directory for Tomcat and extract the downloaded file:
mkdir /opt/tomcat
- extract the file in the folder
tar -xvzf apache-tomcat-8.5.97.tar.gz -C /opt/tomcat/ --strip-components=1
- Set proper ownership for the directory:
chown -R tomcat:tomcat /opt/tomcat
Create a Systemd Service File for Tomcat
- Create the service file
nano /etc/systemd/system/tomcat.service
- Add the following lines to the file:
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
UMask=0007
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
- reload
systemctl daemon-reload
- start the Tomcat service:
systemctl start tomcat
- Verify the status of the Tomcat service:
systemctl status tomcat
- add admin password
nano /opt/tomcat/conf/tomcat-users.xml
- add the lines before the last line you can change the username and password if you like
<role rolename="tomcat"/>
<role rolename="admin"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="tomcat,admin,manager,manager-gui"/>
- change all the context.xml files () to get from the network to the Server.
cd /opt/tomcat/webapps/manager/META-INF
cd /opt/tomcat/webapps/host-manager/META-INF
cd /opt/tomcat/webapps/docs/META-INF
cd /opt/tomcat/webapps/examples/META-INF
nano context.xml
- By default,the $CATALINA_HOME/webapps/manager/META-INF/context.xml file will have the following markup.
<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="false" privileged="true">
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionsFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HasMap"/>
</context>
- The Valve section only allow access from 127.x.x.x or ::1. Comment out the Valve section.
- changing too:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="false" privileged="true">
<!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionsFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HasMap"/>
</context>
- To add a limit to a specific port, set a byte size for the attribute. For example, the below config for the default 8080 port limits request size to 200 MB. This means that all the apps installed under port 8080 now has the size limit of 200MB
opt/tomcat/conf
nano server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxPostSize="209715200" />
-
After passing the port level size limit, you can still configure app level limit. This also means that app level limit should be less than port level limit. The limit can be done through annotation within each servlet, or in the web.xml file. Again, if this is not set at all, there is no limit on request size.
-
change the amout that can be loaded max 50 to 500MB
cd /opt/tomcat/webapps/manager/WEB-INF/
nano web.xml
- find 50MB change it to 500 by adding a 0
- below are 2 more add to both a 0 more
- OR
- 200 MB => 209715200
<multipart-config>
<!-- 500 MiB max -->
<max-file-size>524288000</max-file-size>
<max-request-size>524288000</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
mysql
- create group and user
groupadd mysql
useradd -g mysql mysql
- install mysql
sudo apt install mysql-server sudo apt-get install libaio1 libncurses5 libnuma-dev
- check the status
sudo systemctl status mysql
- get out with ctrl c
- or check status with
systemctl is-active mysql
- You can set MySQL to start automatically upon system restart as shown.
sudo systemctl enable mysql
- go to and chown
cd /usr/share/mysql
- chown
chown -R mysql:mysql *
chown -R root .
cd
Secure MySQL Server Installation
sudo mysql
use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'SECURE PASSWORD';
FLUSH PRIVILEGES;
exit;
sudo mysql_secure_installation
-
enter your root password
-
change the passowrd: n
-
remove anonymous user: y
-
allow that from the network you can login as root (needed for openmrs): n
-
remove test database: y
-
reload privilege table: y
LOAD OpenMRS
- create folder for OpenMRS
mkdir /var/lib/OpenMRS
chown -R tomcat:tomcat /var/lib/OpenMRS
Option 1
- download file Download openmrs.war (OpenMRS)
- got to firefox and type in IP:8080/manager/html
- user and password = admin admin
- WAR file to deploy → Select WAR file to upload → browse file and deploy !it takes some time!
- it should say runnung = true
Option 2
- Download the latest version of OpenMRS:
wget https://sourceforge.net/projects/openmrs/files/releases/OpenMRS_Platform_2.5.7/openmrs.war
- Copy the downloaded file to the Tomcat webapps directory:
cp openmrs.war /opt/tomcat/webapps/
- Change the ownership of the openmrs.war file:
chown -R tomcat:tomcat /opt/tomcat/webapps/openmrs.war
finally go to http://localhost:8080/openmrs
I will try to make a more easy explanation but this is just a hobby
Happy New Year to EVERYONE
love to hear your respond
[/quote]