Skip to content

Linux system admin task before introducing Spring Boot

Mohamed Hassan (JOHN) edited this page Apr 3, 2025 · 9 revisions

Assuming you have the username of a sys-admin role to the target-deployment-machine.

Preparing the target-deployment-machine:

  • Open your terminal, then navigates to the target-deployment-machine

    • ssh <EXAMPLE_USERNAME>@<IP_ADDRESS_OF_TARGET_DEPLOYMENT_MACHINE>
  • Download the app-server archive from its official website whether you're working with apache-tomcat or glassfish using wget

    • wget <DOWNLOAD_URL_OF_APACHE_TOMCAT_ARCHIVE> OR
    • wget <DOWNLOAD_URL_OF_GLASSFISH_ARCHIVE>
  • Unarchive it using tar or unzip

    • tar xf <APACHE_TOMCAT_ARCHIVE>.tar OR
    • unzip <GLASSFISH_ARCHIVE>.zip
  • Move the unarchived app-server into /opt directory

    • mv <APACHE_TOMCAT_DIRECTORY_PATH> /opt OR
    • mv <GLASSFISH_DIRECTORY_PATH> /opt
  • Add jdbc connection pool in:

  • Set an environment variable in the system that refers to the app-server directory path that you already unarchived:

    • sudo nano /etc/environment open the /etc/environment file as root-user using nano
      • TOMCAT_HOME refers to the path of app-server directory
        • TOMCAT_HOME="/opt/<APACHE_TOMCAT_DIRECTORY>" write this environment variable, then save and exit the file
      • OR
      • GLASSFISH_HOME refers to the path of app-server directory
        • GLASSFISH_HOME="/opt/<GLASSFISH_DIRECTORY>" write this environment variable, then save and exit the file
    • source /etc/environment reload the environment

Manual software deployment mechanism:

  • Open your terminal, then navigates to the target-deployment-machine

    • ssh <EXAMPLE_USERNAME>@<IP_ADDRESS_OF_TARGET_DEPLOYMENT_MACHINE>
  • Cleaning phase:

    • Undeploy the running app from the app-server whether you're working with apache-tomcat or glassfish
  • Moving the latest version of deployment-package (WAR file) into the target-deployment-machine phase:

    • Generate the WAR file
      • configure maven's pom.xml
        • add this xml element <packaging>war</packaging> that has project xml element as a parent
      • run mvn clean package
        • check the "target" directory under the project's directory, you shall find appName.war file get generated
    • Move it into the target-deployment-machine
      • scp /SOURCE_PATH_OF_WAR_FILE <EXAMPLE_USERNAME>@<IP_ADDRESS_OF_TARGET_DEPLOYMENT_MACHINE>:/DESTINATION_PATH_OF_WAR_FILE
  • Start up the deployment-package phase:

    • Navigate to the app-server directory
    • Use app-server specific commands to start it up properly whether you're working with apache-tomcat or glassfish
      • $TOMCAT_HOME/bin/catalina.sh start OR
      • $GLASSFISH_HOME/bin/asadmin start-domain

Tomcat:

Undeploy a WAR file

cd $TOMCAT_HOME/bin
./catalina.sh undeploy
./catalina.sh stop

Deploy a WAR file

cp <DEPLOYMENT_PACKAGE_NAME>.war $TOMCAT_HOME/webapps
cd $TOMCAT_HOME/bin
./catalina.sh start

Glassfish:

Undeploy a WAR file

cd $GLASSFISH_HOME/bin
./asadmin undeploy 

Deploy a WAR file

cd $GLASSFISH_HOME/bin
./asadmin deploy ../../<DEPLOYMENT_PACKAGE_NAME>.war


ubuntu1

Clone this wiki locally