-1

Introduction

I have a VPS CENTOS 7.9 kvm running WHM and cPanel v98.0.7.

I have a spring boot application to be deployed.

This application was made to be deployed in a sub-domain of a hosted domain in this WHM.

Problem

How do I deploy a spring boot application to a subdomain in cPanel on my VPS?

References

How to host Spring boot application on cpanel?

https://stackoverflow.com/questions/25660899/spring-boot-actuator-application-wont-start-on-ubuntu-vps?r=SearchResults&s=1|118.4887

https://stackoverflow.com/questions/53933273/spring-boot-2-on-vps-cant-be-accessed?r=SearchResults&s=2|112.0267

https://stackoverflow.com/search?q=VPS+spring+boot

KenobiBastila
  • 513
  • 2
  • 13
  • 43

1 Answers1

0

This solution applied to my hostgator VPS. Consider:

ACCOUNT_NAME to be your account name; DOMAIN_NAME to be your domain name. It can also be a subdomain;

  1. Backup your apache settings:

    cp -vp /etc/apache2/conf/httpd.conf{,-BKP}

  2. Uncomment the lines of include in the vhost of the domain. Do it for the HTTP(std) and for the HTTPS(ssl):

    vim /etc/apache2/conf/httpd.conf

  3. Once you accessed the file, search the following lines and remove the #

    Include "/etc/apache2/conf.d/userdata/std/2_4/ACCOUNT_NAME/DOMAIN_NAME/.conf" Include "/etc/apache2/conf.d/userdata/ssl/2_4/ACCOUNT_NAME/DOMAIN_NAME/.conf"

  4. Create the following directories:

    mkdir -p /etc/apache2/conf.d/userdata/std/2_4/ACCOUNT_NAME/DOMAIN_NAME mkdir -p /etc/apache2/conf.d/userdata/ssl/2_4/ACCOUNT_NAME/DOMAIN_NAME

  5. Create a .conf for std and ssl.

    vim /etc/apache2/conf.d/userdata/std/2_4/ACCOUNT_NAME/DOMAIN_NAME/ACCOUNT_NAME.conf

    vim /etc/apache2/conf.d/userdata/ssl/2_4/ACCOUNT_NAME/DOMAIN_NAME/ACCOUNT_NAME.conf

  6. /etc/apache2/conf.d/userdata/std/2_4/ACCOUNT_NAME/DOMAIN_NAME/ACCOUNT_NAME.conf

    RewriteEngine on RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ProxyPass "/" "http://DOMAIN_NAME:10002/"

  7. /etc/apache2/conf.d/userdata/ssl/2_4/ACCOUNT_NAME/DOMAIN_NAME/ACCOUNT_NAME.conf

    ProxyPass "/" "http://DOMAIN_NAME:10002/"

  8. Once you are done, restart the httpd service. service httpd restart

KenobiBastila
  • 513
  • 2
  • 13
  • 43