Learn how to install Payara Server on CentOS 7 with our detailed step-by-step guide. Follow our instructions to set up Payara Server on your CentOS 7 server quickly and efficiently. #centlinux #linux #java
Table of Contents
What is Payara Server?
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. Version 5.1 is the latest release of this project.
Payara Server is an open-source, enterprise-ready application server for deploying and managing Java applications. It is a commercially supported fork of the GlassFish application server and is designed to provide a robust and reliable platform for Java EE (Enterprise Edition) applications. Here’s a detailed overview of Payara Server, including its features, benefits, and common use cases:
Key Features
- Java EE / Jakarta EE Compatibility:
- Standard Compliance: Supports the full Java EE / Jakarta EE specification, allowing developers to build and deploy applications using standard APIs and technologies.
- Enhanced Performance and Stability:
- Performance Improvements: Offers optimizations and performance enhancements over the original GlassFish server.
- Reliability: Designed for production environments with stability improvements and bug fixes.
- Enterprise Support:
- Commercial Support: Offers commercial support options with services such as technical support, consulting, and training.
- Clustering and High Availability:
- Load Balancing: Supports clustering for load balancing and failover, ensuring high availability and scalability for applications.
- Management Console:
- Web-Based Interface: Includes an intuitive web-based admin console for managing server settings, applications, and deployments.
- Monitoring and Management:
- Advanced Monitoring: Provides tools for monitoring server performance, application health, and resource usage.
- Security Features:
- Comprehensive Security: Supports features like SSL/TLS encryption, authentication, and authorization for secure application deployments.
- MicroProfile Support:
- Microservices Framework: Supports MicroProfile for developing and deploying microservices-based applications.
- Docker and Kubernetes Integration:
- Containerization: Supports deployment in Docker containers and Kubernetes clusters for modern application architectures.
- Developer-Friendly:
- Open Source: Available as open-source software, allowing developers to contribute to the project and customize the server for their needs.
Common Use Cases
- Enterprise Applications: For deploying large-scale enterprise Java EE applications.
- Web Services: Hosting web services and RESTful APIs.
- Microservices Architectures: Building and managing microservices-based applications.
- Development and Testing: A reliable platform for developing and testing Java applications.
Recommended Online Training: Learn Bash Shell in Linux for Beginners
Linux Server Specification
In this article, we will install Payara Server on CentOS 7 and deploy a Java App on that Application Server.
We have provisioned a CentOS 7 virtual machine on CentOS 7.
- Hostname – payara-01.example.com
- IP Address – 192.168.116.169 /24
- Operating System – CentOS 7.6
- Payara Server – 5.1
Install OpenJDK on CentOS 7
Connect with payara-01.example.com using ssh as root user.
Payara 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-1.8.0.212.b04-0.el7_6.x86_64" >> /etc/profile # . /etc/profile # env | grep JAVA_HOME JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
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)
Install Payara Server on CentOS 7
Create a user to own Payara software.
# useradd -s /sbin/nologin payara
Payara 5.1 software 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.
[Unit] Description = Payara Server v5.1 After = syslog.target network.target [Service] 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 [Install] 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
Configure Linux Firewall
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 success # firewall-cmd --reload success
Access Payara Server Web UI
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 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 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] BUILD SUCCESS [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 Application Server 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.
If you are new to Linux and facing difficulty in working at Linux Bash prompt. We recommend that, you should read The Linux Command Line, 2nd Edition: A Complete Introduction by William Shotts.
Final Thoughts
If you found this guide on installing Payara Server on CentOS 7 useful and need more help or a customized setup, don’t hesitate to contact me on Fiverr. I offer professional installation and configuration services for Payara Server and other software. Visit my Fiverr profile here to learn more and get started with your project today!