Dev:PCH installation

From Kordeus Wiki
Revision as of 08:00, 26 June 2025 by Goranugrincic (talk | contribs)
Jump to navigation Jump to search

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

3. Install Oracle JDK 8 (Optional)

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:

  1. Download the .tar.gz package from the Oracle website.
  2. Extract it to a directory (e.g., /opt).
  3. 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

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

3. 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.)

4. 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

5. 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

6. 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

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

8. 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.

9. 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.


IROC PRODUCTIONsudo nano /etc/tomcat/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 /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:

appBase="/opt/tomcat/webapps"


sudo nano /etc/tomcat/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