Deploy spring boot application in production environment on RHEL 7/8?

--

  1. Create a directory and copy the springboot web application executable jar to it
# mkdir /var/myapp
# cp /Downloads/Demoapp-0.0.1-SNAPSHOT.jar /var/myapp/

2. Create the user who will own and run the web application

# useradd myapp
# passwd myapp
# chown myapp:myapp /var/myapp/Demoapp-0.0.1-SNAPSHOT.jar
# chmod 500 /var/myapp/Demoapp-0.0.1-SNAPSHOT.jar

3. Make the application immutable

# chattr +i /var/myapp/Demoapp-0.0.1-SNAPSHOT.jar

4. Create a systemd service to autostart application on reboot

# vim /etc/systemd/system/myapp.service
[Unit]
Description=myapp
After=syslog.target
[Service]
user=myapp
ExecStart=/var/myapp/Demoapp-0.0.1-SNAPSHOT.jar
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target

5. Enable auto-start of the application.

# systemctl enable myapp.service
# systemctl start myapp.service
# systemctl status myapp.service

--

--

Himanshu Pratap
Himanshu Pratap

Written by Himanshu Pratap

System Administrator and Full stack web developer.

Responses (1)