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
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:


== JAVA 8 ON UBUNTU 24.04 ==
== 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:
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:
Line 8: Line 7:
You can install OpenJDK 8 directly from the Ubuntu repositories. Open a terminal and run the following commands:
You can install OpenJDK 8 directly from the Ubuntu repositories. Open a terminal and run the following commands:


'''sudo apt update'''
{{Font color|Color=red|Text='''sudo apt update'''}}


'''sudo apt install openjdk-8-jdk'''
{{Font color|Color=red|Text='''sudo apt install openjdk-8-jdk'''}}


Once installed, you can check the Java version using:
Once installed, you can check the Java version using:


'''java -version'''
{{Font color|Color=red|Text='''java -version'''}}


==== '''2. Set Java 8 as the Default Version''' ====
==== '''2. Set Java 8 as the Default Version''' ====
Line 27: Line 26:
sudo update-alternatives --config javac
sudo update-alternatives --config javac


==== '''3. Install Oracle JDK 8 (Optional)''' ====
== TOMCAT 8 ON UBUNTU 24.04 ==
If you prefer Oracle JDK 8, it’s a bit more involved since Oracle JDK is no longer available through Ubuntu’s default repositories. However, you can still manually install it. You can download it from the Oracle website and install it manually. Here's a general guide:
 
# Download the .tar.gz package from the Oracle website.
# Extract it to a directory (e.g., /opt).
# Set environment variables in your ~/.bashrc or ~/.zshrc file (or equivalent    for your shell) to point to the Oracle JDK.
 
export JAVA_HOME=/opt/jdk1.8.0_xxx
 
export PATH=$PATH:$JAVA_HOME/bin
 
Then, reload the shell configuration:
 
source ~/.bashrc  # or ~/.zshrc, depending on your shell


Finally, verify the installation:
java -version
This should display the installed version of Java 8.
Let me know if you need any more help!
== TOMCAT 8 ON UBUNTU 24.04 ==




Line 60: Line 37:
First, make sure your system is up to date:
First, make sure your system is up to date:


'''sudo apt update'''
{{Font color|Color=red|Text='''sudo apt update'''}}


'''sudo apt upgrade'''   
{{Font color|Color=red|Text='''sudo apt upgrade'''}}  


==== '''3. Download Tomcat 8''' ====
==== '''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.
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'''
{{Font color|Color=red|Text='''cd /opt'''}}


'''sudo wget <nowiki>https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.76/bin/apache-tomcat-8.5.76.tar.gz</nowiki>'''
{{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.)
(Note: Make sure to check for the latest available version of Tomcat 8. You can check this on the official Apache Tomcat Archive.)


==== '''4. Extract Tomcat Archive''' ====
==== '''3. Extract Tomcat Archive''' ====
Once the download is complete, extract the tar.gz file:
Once the download is complete, extract the tar.gz file:


'''sudo tar -xvzf apache-tomcat-8.5.76.tar.gz'''
{{Font color|Color=red|Text='''sudo tar -xvzf apache-tomcat-8.5.76.tar.gz'''}}


Rename the extracted folder for easier access:
Rename the extracted folder for easier access:


'''sudo mv apache-tomcat-8.5.76 tomcat'''
{{Font color|Color=red|Text='''sudo mv apache-tomcat-8.5.76 tomcat'''}}


==== '''5. Set Environment Variables (Optional)''' ====
==== '''4. Set Environment Variables (Optional)''' ====
You can set the environment variables for Tomcat, such as CATALINA_HOME, which points to the Tomcat installation directory.
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:
Edit your .bashrc or .profile file:


'''nano /home/<username>/.bashrc'''
{{Font color|Color=red|Text='''nano /home/<username>/.bashrc'''}}


Add the following lines at the end:
Add the following lines at the end:


'''export CATALINA_HOME="/opt/tomcat"'''
{{Font color|Color=red|Text='''export CATALINA_HOME="/opt/tomcat"'''}}


'''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"'''}}
 
{{Font color|Color=red|Text='''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:
After saving the file, run:


'''source /home/<username>/.bashrc'''
{{Font color|Color=red|Text='''source /home/<username>/.bashrc'''}}


==== '''6. Set Permissions''' ====
==== '''5. Set Permissions''' ====
Ensure that the tomcat directory is accessible to the user running Tomcat (e.g., for starting and stopping Tomcat):
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'''
{{Font color|Color=red|Text='''sudo chown -R www-data:owners /opt/tomcat'''}}


Previous command didn’t work so I run:
Previous command didn’t work so I run:


'''sudo chmod -R 777 /opt/tomcat'''
{{Font color|Color=red|Text='''sudo chmod -R 777 /opt/tomcat'''}}


==== '''7. Start Tomcat''' ====
==== '''6. Start Tomcat''' ====
Now you can start Tomcat manually by running the startup script:
Now you can start Tomcat manually by running the startup script:


Line 118: Line 96:
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>.
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>.


==== '''8. Configure Tomcat as a System Service (Optional)''' ====
==== '''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.
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:
Create a new service file:


'''sudo nano /etc/systemd/system/tomcat.service'''
{{Font color|Color=red|Text='''sudo nano /etc/systemd/system/tomcat.service'''}}


Add the following content:
Add the following content:




'''[Unit]'''
'''Description=Tomcat 8 servlet container'''
'''After=network.target'''


'''[Service]'''
{{Font color|Color=red|Text='''[Unit]'''}}


'''Type=forking'''
{{Font color|Color=red|Text='''Description=Tomcat 8 servlet container'''}}


'''Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64'''
{{Font color|Color=red|Text='''After=network.target''' }}


'''Environment=CATALINA_HOME=/opt/tomcat'''
{{Font color|Color=red|Text='''[Service]'''}}


'''Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid'''
{{Font color|Color=red|Text='''Type=forking'''}}


'''ExecStart=/opt/tomcat/bin/startup.sh'''
{{Font color|Color=red|Text='''Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64'''}}


'''ExecStop=/opt/tomcat/bin/shutdown.sh'''
{{Font color|Color=red|Text='''Environment=CATALINA_HOME=/opt/tomcat'''}}


'''User=www-data'''
{{Font color|Color=red|Text='''Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid'''}}


'''Group=owners'''
{{Font color|Color=red|Text='''ExecStart=/opt/tomcat/bin/startup.sh'''}}


'''WorkingDirectory=/opt/tomcat'''
{{Font color|Color=red|Text='''ExecStop=/opt/tomcat/bin/shutdown.sh'''}}


'''RestartSec=10'''
{{Font color|Color=red|Text='''User=www-data'''}}


'''Restart=always'''
{{Font color|Color=red|Text='''Group=owners'''}}


{{Font color|Color=red|Text='''WorkingDirectory=/opt/tomcat'''}}


[Install]
{{Font color|Color=red|Text='''RestartSec=10'''}}


WantedBy=multi-user.target
{{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:
Enable and start the service:


'''sudo systemctl enable tomcat'''
{{Font color|Color=red|Text='''sudo systemctl enable tomcat'''}}


'''sudo systemctl start tomcat'''
{{Font color|Color=red|Text='''sudo systemctl start tomcat'''}}


You can check the status of Tomcat:
You can check the status of Tomcat:
Line 177: Line 153:
This will run Tomcat as a system service, which will also automatically start on system boot.
This will run Tomcat as a system service, which will also automatically start on system boot.


==== '''9. Access Tomcat Web Interface''' ====
==== '''8. Access Tomcat Web Interface''' ====
You can now access the Tomcat interface by navigating to:
You can now access the Tomcat interface by navigating to:


Line 183: Line 159:


For more advanced configuration, you can modify files under /opt/tomcat/conf/ (e.g., server.xml).
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!
 
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 =
= Tomcat Configuration =


{{Font color|Color=red|Text=sudo nano /etc/default/tomcat}}


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"'''


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.  


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




sudo nano /etc/tomcat/tomcat-users.xml  
{{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:
add the following elements inside <tomcat-users> element, to enable a web browser based tomcat manager:


<role rolename="admin-gui"/>
'''<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"/>'''
 


<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}}


sudo nano /etc/tomcat/server.xml
in '''<Host>''' element, replace the value of appBase attribute with the following value, to make tomcat monitor that folder for new apps:


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"'''


appBase="/opt/tomcat/webapps"




sudo nano /etc/tomcat/catalina.properties  
 
{{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:
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"
''',"/opt/tomcat/lib/*.jar","/opt/tomcat/conf"'''
 
 




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


sudo systemctl restart tomcat
{{Font color|Color=red|Text=sudo systemctl restart tomcat}}
 




Line 230: Line 215:


<nowiki>http://localhost:8080/</nowiki>
<nowiki>http://localhost:8080/</nowiki>




Line 247: Line 233:




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)


sudo cp mysql-connector-java-5.1.35.jar /opt/tomcat/lib/
{{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.}}


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





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