-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
  • 539
  • 4
  • 16
  • 52

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}

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

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

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

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

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

ProxyPass "/" "http://DOMAIN_NAME:10002/"
  1. Once you are done, restart the httpd service.

service httpd restart

KenobiBastila
  • 539
  • 4
  • 16
  • 52