[[howto.deployment.installing]]
= Installing Spring Boot Applications

In addition to running Spring Boot applications by using `java -jar` directly, it is also possible to run them as services.



[[howto.deployment.installing.system-d]]
== Installation as a systemd Service

`systemd` is the successor of the System V init system and is now being used by many modern Linux distributions.
Spring Boot applications can be launched by using `systemd` '`service`' scripts.

Assuming that you have a Spring Boot application packaged as an uber jar in `/var/myapp`, to install it as a `systemd` service, create a script named `myapp.service` and place it in `/etc/systemd/system` directory.
The following script offers an example:

[source]
----
[Unit]
Description=myapp
After=syslog.target network.target

[Service]
User=myapp
Group=myapp

Type=exec
ExecStart=/path/to/java/home/bin/java -jar /var/myapp/myapp.jar
WorkingDirectory=/var/myapp
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target
----

IMPORTANT: Remember to change the `Description`, `User`, `Group`, `ExecStart` and `WorkingDirectory` fields for your application.

NOTE: The `ExecStart` field does not declare the script action command, which means that the `run` command is used by default.

The user that runs the application, the PID file, and the console log file are managed by `systemd` itself and therefore must be configured by using appropriate fields in the '`service`' script.
Consult the https://www.freedesktop.org/software/systemd/man/systemd.service.html[service unit configuration man page] for more details.

To flag the application to start automatically on system boot, use the following command:

[source,shell]
----
$ systemctl enable myapp.service
----

Run `man systemctl` for more details.



[[howto.deployment.installing.windows-services]]
== Microsoft Windows Services

A Spring Boot application can be started as a Windows service by using https://github.com/kohsuke/winsw[`winsw`].

A (https://github.com/snicoll/spring-boot-daemon[separately maintained sample]) describes step-by-step how you can create a Windows service for your Spring Boot application.
