Wednesday, 22 May 2019

How to Install Payara Server 5.1 on CentOS 7

Install Payara Server 5.1 on CentOS 7

Payara Server is a fork of famous open-source application server i.e. GlassFish Server. Payara Server was created in year 2014, as a drop in replacement for GlassFish after Oracle announced to discontinue commercial support for GlassFish. Payara server is sponsored by Payara Services Ltd since April 2016. Payara Server 5.1 is the latest release of this project.

In this article, we will install Payara Server 5.1 on CentOS 7 and deploy a Java App on Payara Server.


Table of Contents:


System Specification:

We have provisioned a CentOS 7 virtual machine on CentOS 7.

  • Hostname - payara-01.example.com
  • IP Address - /24
  • Operating System - CentOS 7.6
  • Payara Server - 5.1

Install Payara Server 5.1 on CentOS 7

Installing OpenJDK 8 on CentOS 7:

Connect with payara-01.example.com using ssh as root user.

Payara Server is a Java based application server and it requires JRE (Java Runtime Environment). Therefore, we are installing OpenJDK using yum command.

# yum install -y java-1.8.0-openjdk

Set Java related enironment variables.

# echo "export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-" >> /etc/profile
# . /etc/profile
# env | grep JAVA_HOME

Verify Java installation by checking its version.

# java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)


Installing Payara Server 5.1 on CentOS 7:

Create a user to own Payara software.

# useradd -s /sbin/nologin payara

Payara Server 5.1 can be downloaded from Payara website.

# cd /tmp
# curl -O https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/5.191/payara-5.191.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  140M  100  140M    0     0   288k      0  0:08:17  0:08:17 --:--:--  450k

Extract downloaded file in /opt directory.

# unzip payara-5.191.zip -d /opt/

Adjust ownership of the /opt/payara5 directory.

# chown -R payara:payara /opt/payara5/

Create a Systemd service for Payara Server.

# vi /usr/lib/systemd/system/payara.service

and add following directives therein.

Description = Payara Server v5.1
After = syslog.target network.target

User = payara
ExecStart = /usr/bin/java -jar /opt/payara5/glassfish/lib/client/appserver-cli.jar start-domain
ExecStop = /usr/bin/java -jar /opt/payara5/glassfish/lib/client/appserver-cli.jar stop-domain
ExecReload = /usr/bin/java -jar /opt/payara5/glassfish/lib/client/appserver-cli.jar restart-domain
Type = forking

WantedBy = multi-user.target

Enable and start payara.service.

# systemctl enable payara.service
Created symlink from /etc/systemd/system/multi-user.target.wants/payara.service to /usr/lib/systemd/system/payara.service.
# systemctl start payara.service

Payara server uses following Service ports.

4848 - Administration Console
8080 - HTTP Service
8181 - HTTPS Service

Allow above service ports in Linux firewall.

# firewall-cmd --permanent --add-port={4848,8080,8181}/tcp
# firewall-cmd --reload

Browse URL http://payara-01.example.com:8080 using a client's browser.


Payara Server 5.1 is installed and running on designated port.

Add Payara server binaries to PATH environment variable.

# sed -i 's/^PATH=*/PATH=\/opt\/payara5\/bin:/g' ~/.bash_profile
# . ~/.bash_profile

Set password for Payara Server 5.1 Admin user.

# asadmin --port 4848 change-admin-password
Enter admin user name [default: admin]>Enter the admin password>
Enter the new admin password>
Enter the new admin password again>
Command change-admin-password executed successfully.

By default, Payara Server Admin Console is running as a clear text HTTP service. Run following command to enable secure administration console.

# asadmin --host payara-01.example.com --port 4848 enable-secure-admin
Enter admin user name>  admin
Enter admin password for user "admin">
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.

Restart payara.service.

# systemctl restart payara.service

Browse URL https://payara-01.example.com:4848 using a client's browser. You may encounter a security certificate warning; just ignore it and continue.



Login with admin user and password.


We are at the dashboard of Payara Server Administration Console.


Deploy a Java App in Payara Server 5.1:

There are many Java applications available on GitHub. We are also downloading a Simple Java App. Although this Java App is for the demonstration purpose of BoxFuse, however we can use it for testing purpose of Payara Server as well.

But first, we need git to clone the project and Apache Maven to compile and build the project. Therefore, we are installing both of these tools using yum command.

# yum install -y git maven

Use git to clone the required project.

# git clone https://github.com/boxfuse/boxfuse-sample-java-war-hello
Cloning into 'boxfuse-sample-java-war-hello'...
remote: Enumerating objects: 74, done.
remote: Total 74 (delta 0), reused 0 (delta 0), pack-reused 74
Unpacking objects: 100% (74/74), done.

Now, Build the project using Apache Maven.

# cd boxfuse-sample-java-war-hello
# mvn package
[INFO] Packaging webapp
[INFO] Assembling webapp [hello] in [/root/boxfuse-sample-java-war-hello/target/hello-1.0]
[INFO] Processing war project
[INFO] Copying webapp resources [/root/boxfuse-sample-java-war-hello/src/main/webapp]
[INFO] Webapp assembled in [83 msecs]
[INFO] Building war: /root/boxfuse-sample-java-war-hello/target/hello-1.0.war
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7:48.082s
[INFO] Finished at: Tue May 21 14:09:56 PKT 2019
[INFO] Final Memory: 14M/35M
[INFO] ------------------------------------------------------------------------

Check currently deployed applications on Payara server.

# asadmin list-applications
Enter admin user name>  admin
Enter admin password for user "admin">
Nothing to list.
No applications are deployed to this target server.
Command list-applications executed successfully.

Deploy the WAR file in Payara server 5.1 as follows.

# asadmin deploy target/hello-1.0.war
Enter admin user name>  admin
Enter admin password for user "admin">
Application deployed with name hello-1.0.
Command deploy executed successfully.

Again check list of deployed Java Apps.

# asadmin list-applications
Enter admin user name>  Enter admin password>
hello-1.0  <web>
Command list-applications executed successfully.

Now, it displays our recently deployed Java App in the list.

Browse URL http://payara-01.example.com:8080/hello-1.0 from a client's browser.


We have successfully installed Payara Server 5.1 on CentOS 7 and deployed a Simple Java App on Payara Server.

If you find this article useful? Consider supporting us by Buy Me A Coffee

No comments:

Post a Comment

© 2023 CentLinux. All Rights Reserved.