25 August 2017
In this "back to basics tutorial" I'll try to explain how to install properly Payara 4.1 on Centos 7 (it should be fine for Red Hat, Oracle Unbreakable Linux and other *hat distributions).
Why not Docker, Ansible, Chef, Puppet, . . .?. Sometimes the best solution is the easiest :).
The only software requirement to run Payara is to have a JDK installed. CentOS offers a custom OpenJDK build called "headless" that doesn't offer support for audio and video, perfect for cli environments.
You can install it with Yum.
yum install java-1.8.0-openjdk-headless
As mentioned in the official Glassfish documentation, it is convenient to run your application server in a dedicated user for security and administrative reasons.
Although you could be tempted to create a no-login, no-shell user, Payara saves many preferences in user's home directory and the shell/login is actually needed to execute administrative commands like
Payara is hosted at Amazon S3, please double check this link on Payara's website, for this guide I'm installing Payara at server's
cd /opt wget https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/Payara+126.96.36.199/payara-188.8.131.52.zip unzip payara-184.108.40.206.zip
You should execute the above commands as super-user, after that you should change permissions for the Payara directory before any domain start. Otherwise you won't be able to use the server with
chown -R payara:payara payara41
Centos 7 uses systemd as init system, consequently it is possible and actually quite easy to create a systemd unit to start, stop and restart Payara default domain
First, create a file that represents Payara systemd unit.
And add the following content:
[Unit] Description = Payara Server v4.1 After = syslog.target network.target [Service] User=payara ExecStart = /usr/bin/java -jar /opt/payara41/glassfish/lib/client/appserver-cli.jar start-domain ExecStop = /usr/bin/java -jar /opt/payara41/glassfish/lib/client/appserver-cli.jar stop-domain ExecReload = /usr/bin/java -jar /opt/payara41/glassfish/lib/client/appserver-cli.jar restart-domain Type = forking [Install] WantedBy = multi-user.target
Note that Payara administration is achieved with
payara user. You could personalize it to fit your needs.
Optionally you could enable the service to start with the server and/or after server reboots.
systemctl enable payara
Check if all is working properly with the systemd standard commands
systemctl start payara systemctl restart payara systemctl stop payara
As Payara and Glassfish users already know, most administrative tasks in Payara application server are achieved by using cli commands like
asadmin. Hence it is convenient to have all tools available in our administrative
First log-in as Payara user, if you didn't assign a password for the user you could switch to this user using
su as root user.
Later you shoud create or edit the
.bashrc file for the Payara user, the most common location being user's home directory.
cd /home/payara vim .bashrc
And add the following line:
If your setup was done properly you should obtain an environment like in the following screenshot:
asadminworks and displays properly the running domain