Which Payara
Payara 7 implements Jakarta EE 11. Payara 6 implements Jakarta EE 10 and runs on Java 11 and 17 as well. If your application uses javax.* imports it needs Payara 5, which is end-of-life: migrate to jakarta.* instead. This guide uses Payara 7 on Java 21 and works the same for Payara 6.
1. Java, user and download
sudo apt update
sudo apt install -y openjdk-21-jdk-headless curl unzip
sudo useradd --system --home-dir /opt/payara --shell /usr/sbin/nologin payara
PAYARA_VERSION=7.XXXX.X # check Maven Central for the current number
cd /tmp
curl -fSLO https://repo1.maven.org/maven2/fish/payara/distributions/payara/${PAYARA_VERSION}/payara-${PAYARA_VERSION}.zip
curl -fsSL https://repo1.maven.org/maven2/fish/payara/distributions/payara/${PAYARA_VERSION}/payara-${PAYARA_VERSION}.zip.sha1; echo
sha1sum payara-${PAYARA_VERSION}.zip
The two checksums must match. To see the versions available, open https://repo1.maven.org/maven2/fish/payara/distributions/payara/maven-metadata.xml.
2. Unpack
The archive contains one top-level folder. Unpack to a temporary place and move that folder, so the name does not matter:
mkdir -p /tmp/payara-x
unzip -q payara-${PAYARA_VERSION}.zip -d /tmp/payara-x
sudo mv /tmp/payara-x/* /opt/payara-${PAYARA_VERSION}
rmdir /tmp/payara-x
sudo ln -sfn /opt/payara-${PAYARA_VERSION} /opt/payara
sudo chown -R payara:payara /opt/payara-${PAYARA_VERSION}
ls /opt/payara
You should see bin, glassfish, README.txt and a few more.
3. Set the heap and the listener address
The domain configuration is the file /opt/payara/glassfish/domains/domain1/config/domain.xml. Look at what is in it first:
grep -n 'Xmx' /opt/payara/glassfish/domains/domain1/config/domain.xml
grep -n 'network-listener ' /opt/payara/glassfish/domains/domain1/config/domain.xml
Set the maximum heap (here 1176 MB, adjust it for your server) and make the HTTP and admin listeners local only, so Nginx is the only way in. The second command replaces an existing address attribute instead of adding another one: a duplicate attribute makes the XML invalid and the server will not start.
DX=/opt/payara/glassfish/domains/domain1/config/domain.xml
sudo cp $DX $DX.orig
sudo sed -i -E 's#<jvm-options>-Xmx[0-9]+[mMgG]</jvm-options>#<jvm-options>-Xmx1176m</jvm-options>#g' $DX
sudo sed -i -E '/<network-listener .*name="(http-listener-1|admin-listener)"/{ s# address="[^"]*"##g; s#<network-listener #<network-listener address="127.0.0.1" #; }' $DX
grep -c 'address=.*address=' $DX # must print 0
If the last command prints anything other than 0, restore the backup (sudo cp $DX.orig $DX) and check the listener lines by hand.
4. systemd service
sudo tee /etc/systemd/system/payara.service >/dev/null <<'EOF'
[Unit]
Description=Payara Server
After=network.target
[Service]
User=payara
Group=payara
Environment=JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
ExecStart=/opt/payara/bin/asadmin start-domain --verbose domain1
ExecStop=/opt/payara/bin/asadmin stop-domain domain1
SuccessExitStatus=143
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now payara
sudo journalctl -u payara -n 30 --no-pager
The --verbose flag keeps the process in the foreground, which is what systemd expects.
5. Deploy the application
sudo install -d -o payara -g payara -m 750 /var/lib/payara-deploy
sudo install -o payara -g payara -m 640 myapp.war /var/lib/payara-deploy/app.war
sudo -u payara /opt/payara/bin/asadmin deploy --force=true --contextroot / --name app /var/lib/payara-deploy/app.war
sudo -u payara /opt/payara/bin/asadmin list-applications
The WAR is copied to a folder the payara user can read; a file in your home folder would be unreadable for it. The first start takes a minute or two, so if deploy says it cannot connect to port 4848, wait a little and run it again. Use the same commands for every new version. Then put Nginx in front, proxying to 127.0.0.1:8080, as in this guide.
Notes
- The admin console listens on port 4848. Keep it on localhost and reach it through an SSH tunnel. Set an admin password with
asadmin change-admin-password, and enable secure admin only if you must access it remotely. - Payara needs more memory than Tomcat. Do not run it on a 2 GB server for production.
Our Payara hosting plans include this installation. Start from €15.30 per month.
Last updated October 29, 2026.