Dev:PCH installation: Difference between revisions

From Kordeus Wiki
Jump to navigation Jump to search
Goranugrincic (talk | contribs)
No edit summary
Goranugrincic (talk | contribs)
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
TBD
 
== JAVA 8 ON UBUNTU 24.04 ==
 
Yes, it is possible to install Java 8 on Ubuntu 24.04, though Ubuntu 24.04 might come with a more recent version of Java by default. However, you can still install Java 8 by using either the OpenJDK package or the Oracle JDK. Here's how to do it:
 
==== '''1. Install OpenJDK 8''' ====
You can install OpenJDK 8 directly from the Ubuntu repositories. Open a terminal and run the following commands:
 
{{Font color|Color=red|Text='''sudo apt update'''}}
 
{{Font color|Color=red|Text='''sudo apt install openjdk-8-jdk'''}}
 
Once installed, you can check the Java version using:
 
{{Font color|Color=red|Text='''java -version'''}}
 
==== '''2. Set Java 8 as the Default Version''' ====
If you have multiple Java versions installed, you can set Java 8 as the default using the update-alternatives command. Here’s how:
 
sudo update-alternatives --config java
 
This will show a list of installed Java versions. Select the number corresponding to the OpenJDK 8 installation and press Enter.
 
For javac (the Java compiler), you can set it similarly:
 
sudo update-alternatives --config javac
 
== TOMCAT 8 ON UBUNTU 24.04 ==
 
 
 
Yes, it is possible to install Tomcat 8 on Ubuntu 24.04, although it might require some manual steps since Tomcat 8 is older and might not be available in the default repositories for the latest Ubuntu releases.
 
Here's a step-by-step guide to install Tomcat 8 on Ubuntu 24.04:
 
==== '''1. Update System Packages''' ====
First, make sure your system is up to date:
 
{{Font color|Color=red|Text='''sudo apt update'''}}
 
{{Font color|Color=red|Text='''sudo apt upgrade'''}} 
 
==== '''2. Download Tomcat 8''' ====
Visit the official Tomcat download page to get the link to the Tomcat 8 binary. At the time of writing, you can use the following wget command to download the Tomcat 8 tar.gz file.
 
{{Font color|Color=red|Text='''cd /opt'''}}
 
{{Font color|Color=red|Text='''sudo wget <nowiki>https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.76/bin/apache-tomcat-8.5.76.tar.gz</nowiki>'''}}
 
(Note: Make sure to check for the latest available version of Tomcat 8. You can check this on the official Apache Tomcat Archive.)
 
==== '''3. Extract Tomcat Archive''' ====
Once the download is complete, extract the tar.gz file:
 
{{Font color|Color=red|Text='''sudo tar -xvzf apache-tomcat-8.5.76.tar.gz'''}}
 
Rename the extracted folder for easier access:
 
{{Font color|Color=red|Text='''sudo mv apache-tomcat-8.5.76 tomcat'''}}
 
==== '''4. Set Environment Variables (Optional)''' ====
You can set the environment variables for Tomcat, such as CATALINA_HOME, which points to the Tomcat installation directory.
 
Edit your .bashrc or .profile file:
 
{{Font color|Color=red|Text='''nano /home/<username>/.bashrc'''}}
 
Add the following lines at the end:
 
{{Font color|Color=red|Text='''export CATALINA_HOME="/opt/tomcat"'''}}
 
{{Font color|Color=red|Text='''export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"'''}}
 
{{Font color|Color=red|Text='''export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"'''}}
 
 
 
After saving the file, run:
 
{{Font color|Color=red|Text='''source /home/<username>/.bashrc'''}}
 
==== '''5. Set Permissions''' ====
Ensure that the tomcat directory is accessible to the user running Tomcat (e.g., for starting and stopping Tomcat):
 
{{Font color|Color=red|Text='''sudo chown -R www-data:owners /opt/tomcat'''}}
 
Previous command didn’t work so I run:
 
{{Font color|Color=red|Text='''sudo chmod -R 777 /opt/tomcat'''}}
 
==== '''6. Start Tomcat''' ====
Now you can start Tomcat manually by running the startup script:
 
/opt/tomcat/bin/startup.sh
 
This will start Tomcat, and you should be able to access the Tomcat server in your browser at <nowiki>http://your_server_ip:8080</nowiki>.
 
==== '''7. Configure Tomcat as a System Service (Optional)''' ====
If you'd like to run Tomcat as a service (so that it starts automatically with the system), you can create a systemd service for Tomcat.
 
Create a new service file:
 
{{Font color|Color=red|Text='''sudo nano /etc/systemd/system/tomcat.service'''}}
 
Add the following content:
 
 
 
{{Font color|Color=red|Text='''[Unit]'''}}
 
{{Font color|Color=red|Text='''Description=Tomcat 8 servlet container'''}}
 
{{Font color|Color=red|Text='''After=network.target''' }}
 
{{Font color|Color=red|Text='''[Service]'''}}
 
{{Font color|Color=red|Text='''Type=forking'''}}
 
{{Font color|Color=red|Text='''Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64'''}}
 
{{Font color|Color=red|Text='''Environment=CATALINA_HOME=/opt/tomcat'''}}
 
{{Font color|Color=red|Text='''Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid'''}}
 
{{Font color|Color=red|Text='''ExecStart=/opt/tomcat/bin/startup.sh'''}}
 
{{Font color|Color=red|Text='''ExecStop=/opt/tomcat/bin/shutdown.sh'''}}
 
{{Font color|Color=red|Text='''User=www-data'''}}
 
{{Font color|Color=red|Text='''Group=owners'''}}
 
{{Font color|Color=red|Text='''WorkingDirectory=/opt/tomcat'''}}
 
{{Font color|Color=red|Text='''RestartSec=10'''}}
 
{{Font color|Color=red|Text='''Restart=always'''}}
 
{{Font color|Color=red|Text='''[Install]'''}}
 
{{Font color|Color=red|Text='''WantedBy=multi-user.target'''}}
 
Enable and start the service:
 
{{Font color|Color=red|Text='''sudo systemctl enable tomcat'''}}
 
{{Font color|Color=red|Text='''sudo systemctl start tomcat'''}}
 
You can check the status of Tomcat:
 
sudo systemctl status tomcat
 
This will run Tomcat as a system service, which will also automatically start on system boot.
 
==== '''8. Access Tomcat Web Interface''' ====
You can now access the Tomcat interface by navigating to:
 
<nowiki>http://your_server_ip:8080</nowiki>
 
For more advanced configuration, you can modify files under /opt/tomcat/conf/ (e.g., server.xml).
 
This should get Tomcat 8 running on Ubuntu 24.04. Let me know if you need help with any other steps or troubleshooting!
 
= Tomcat Configuration =
 
{{Font color|Color=red|Text=sudo nano /etc/default/tomcat}}
 
'''JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -Djava.net.preferIPv4Stack=true"'''
 
To get started with Tomcat, we still need to update the tomcat default configuration.
 
 
 
{{Font color|Color=red|Text=sudo nano /opt/tomcat/conf/tomcat-users.xml}}
 
add the following elements inside <tomcat-users> element, to enable a web browser based tomcat manager:
 
'''<role rolename="admin-gui"/>'''
 
'''<role rolename="manager-gui"/>'''
 
'''<role rolename="manager-script"/>'''
 
'''<user username="admin" password="<new password>" roles="manager-gui,manager-status,manager-script,manager-jmx,admin-gui"/>'''
 
 
 
 
 
{{Font color|Color=red|Text=sudo nano /opt/tomcat/conf/server.xml}}
 
in '''<Host>''' element, replace the value of appBase attribute with the following value, to make tomcat monitor that folder for new apps:
 
'''appBase="/opt/tomcat/webapps"'''
 
 
 
 
{{Font color|Color=red|Text=sudo nano /opt/tomcat/conf/catalina.properties }}
 
Add paths to the configuration and external libs (/opt/tomcat/config/,/opt/tomcat/lib) to the '''shared.loader''' variable, so that we keep the tomcat distribution clean for future updates:
 
''',"/opt/tomcat/lib/*.jar","/opt/tomcat/conf"'''
 
 
 
 
Then, restart the tomcat so all changes to the configuration are applied:
 
{{Font color|Color=red|Text=sudo systemctl restart tomcat}}
 
 
 
then try to invoke (replace locahost by the server on which tomcat is installed)
 
<nowiki>http://localhost:8080/</nowiki>
 
 
 
Create a basic file structure for tomcat server:
 
sudo mkdir /opt/tomcat
 
sudo mkdir /opt/tomcat/webapps
 
sudo mkdir /opt/tomcat/lib
 
sudo mkdir /opt/tomcat/conf
 
sudo mkdir /opt/tomcat/temp
 
sudo mkdir /opt/tomcat/store
 
 
 
{{Font color|Color=red|Text=wget <nowiki>http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.35/</nowiki> mysql-connector-java-5.1.35.jar; (use current/latest version)}}
 
{{Font color|Color=red|Text=sudo cp mysql-connector-java-5.1.35.jar /opt/tomcat/lib/}}
 
 
 
{{Font color|Color=red|Text=Also copy OCRB.jar and DaxOT.jar to /opt/tomcat/lib folder, that files are fonts PCH requires for printing bills in Kordeus.}}
 
 
 
And finally, restart the service with the command
 
sudo systemctl restart tomcat
 
 
 
[[Category:Printing]]
[[Category:Printing]]
[[Category:Device integration]]
[[Category:Device integration]]

Latest revision as of 09:25, 30 June 2025

JAVA 8 ON UBUNTU 24.04

Yes, it is possible to install Java 8 on Ubuntu 24.04, though Ubuntu 24.04 might come with a more recent version of Java by default. However, you can still install Java 8 by using either the OpenJDK package or the Oracle JDK. Here's how to do it:

1. Install OpenJDK 8

You can install OpenJDK 8 directly from the Ubuntu repositories. Open a terminal and run the following commands:

sudo apt update

sudo apt install openjdk-8-jdk

Once installed, you can check the Java version using:

java -version

2. Set Java 8 as the Default Version

If you have multiple Java versions installed, you can set Java 8 as the default using the update-alternatives command. Here’s how:

sudo update-alternatives --config java

This will show a list of installed Java versions. Select the number corresponding to the OpenJDK 8 installation and press Enter.

For javac (the Java compiler), you can set it similarly:

sudo update-alternatives --config javac

TOMCAT 8 ON UBUNTU 24.04

Yes, it is possible to install Tomcat 8 on Ubuntu 24.04, although it might require some manual steps since Tomcat 8 is older and might not be available in the default repositories for the latest Ubuntu releases.

Here's a step-by-step guide to install Tomcat 8 on Ubuntu 24.04:

1. Update System Packages

First, make sure your system is up to date:

sudo apt update

sudo apt upgrade

2. Download Tomcat 8

Visit the official Tomcat download page to get the link to the Tomcat 8 binary. At the time of writing, you can use the following wget command to download the Tomcat 8 tar.gz file.

cd /opt

sudo wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.76/bin/apache-tomcat-8.5.76.tar.gz

(Note: Make sure to check for the latest available version of Tomcat 8. You can check this on the official Apache Tomcat Archive.)

3. Extract Tomcat Archive

Once the download is complete, extract the tar.gz file:

sudo tar -xvzf apache-tomcat-8.5.76.tar.gz

Rename the extracted folder for easier access:

sudo mv apache-tomcat-8.5.76 tomcat

4. Set Environment Variables (Optional)

You can set the environment variables for Tomcat, such as CATALINA_HOME, which points to the Tomcat installation directory.

Edit your .bashrc or .profile file:

nano /home/<username>/.bashrc

Add the following lines at the end:

export CATALINA_HOME="/opt/tomcat"

export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"

export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"


After saving the file, run:

source /home/<username>/.bashrc

5. Set Permissions

Ensure that the tomcat directory is accessible to the user running Tomcat (e.g., for starting and stopping Tomcat):

sudo chown -R www-data:owners /opt/tomcat

Previous command didn’t work so I run:

sudo chmod -R 777 /opt/tomcat

6. Start Tomcat

Now you can start Tomcat manually by running the startup script:

/opt/tomcat/bin/startup.sh

This will start Tomcat, and you should be able to access the Tomcat server in your browser at http://your_server_ip:8080.

7. Configure Tomcat as a System Service (Optional)

If you'd like to run Tomcat as a service (so that it starts automatically with the system), you can create a systemd service for Tomcat.

Create a new service file:

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

Add the following content:


[Unit]

Description=Tomcat 8 servlet container

After=network.target

[Service]

Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Environment=CATALINA_HOME=/opt/tomcat

Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid

ExecStart=/opt/tomcat/bin/startup.sh

ExecStop=/opt/tomcat/bin/shutdown.sh

User=www-data

Group=owners

WorkingDirectory=/opt/tomcat

RestartSec=10

Restart=always

[Install]

WantedBy=multi-user.target

Enable and start the service:

sudo systemctl enable tomcat

sudo systemctl start tomcat

You can check the status of Tomcat:

sudo systemctl status tomcat

This will run Tomcat as a system service, which will also automatically start on system boot.

8. Access Tomcat Web Interface

You can now access the Tomcat interface by navigating to:

http://your_server_ip:8080

For more advanced configuration, you can modify files under /opt/tomcat/conf/ (e.g., server.xml).

This should get Tomcat 8 running on Ubuntu 24.04. Let me know if you need help with any other steps or troubleshooting!

Tomcat Configuration

sudo nano /etc/default/tomcat

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -Djava.net.preferIPv4Stack=true"

To get started with Tomcat, we still need to update the tomcat default configuration.


sudo nano /opt/tomcat/conf/tomcat-users.xml

add the following elements inside <tomcat-users> element, to enable a web browser based tomcat manager:

<role rolename="admin-gui"/>

<role rolename="manager-gui"/>

<role rolename="manager-script"/>

<user username="admin" password="<new password>" roles="manager-gui,manager-status,manager-script,manager-jmx,admin-gui"/>



sudo nano /opt/tomcat/conf/server.xml

in <Host> element, replace the value of appBase attribute with the following value, to make tomcat monitor that folder for new apps:

appBase="/opt/tomcat/webapps"



sudo nano /opt/tomcat/conf/catalina.properties

Add paths to the configuration and external libs (/opt/tomcat/config/,/opt/tomcat/lib) to the shared.loader variable, so that we keep the tomcat distribution clean for future updates:

,"/opt/tomcat/lib/*.jar","/opt/tomcat/conf"



Then, restart the tomcat so all changes to the configuration are applied:

sudo systemctl restart tomcat


then try to invoke (replace locahost by the server on which tomcat is installed)

http://localhost:8080/


Create a basic file structure for tomcat server:

sudo mkdir /opt/tomcat

sudo mkdir /opt/tomcat/webapps

sudo mkdir /opt/tomcat/lib

sudo mkdir /opt/tomcat/conf

sudo mkdir /opt/tomcat/temp

sudo mkdir /opt/tomcat/store


wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.35/ mysql-connector-java-5.1.35.jar; (use current/latest version)

sudo cp mysql-connector-java-5.1.35.jar /opt/tomcat/lib/


Also copy OCRB.jar and DaxOT.jar to /opt/tomcat/lib folder, that files are fonts PCH requires for printing bills in Kordeus.


And finally, restart the service with the command

sudo systemctl restart tomcat