WildFly 8.2.0 and Java 8 on CentOS 6.6
This post documents how to install and configure WildFly 8.2.0 on CentOS 6.6. We make some changes to move some of the configuration under /etc and also place log files under /var/log and temp files under /tmp just like a well-behaved POSIX application should.
We’ll start by installing Java; download your desired version as an RPM from Oracle and install:
[root@wxyz ~]# rpm -ivh jdk-8u25-linux-x64.rpm
This installs the JDK in /usr/java/jdk1.8.0_25. There is no need to make this the default java used by the system, we'll just configure WildFly to use it.
Next we create a wildfly user on the server to build and run WildFly as:
[root@wxyz ~]# useradd --system \
I assume you already have the WildFly tarball downloaded and ready to go:
[wildfly@wxyz ~]$ tar zxvf wildfly-8.2.0.Final.tar.gz
Now that we have WildFly on the system, we need to configure CentOS to treat it like a service. WildFly comes with some scripts in the bin/init.d directory that will help with this. I am using the standalone server, but it is not difficult to modify the instructions for the domain server. First up is the /etc/wildfly/wildfly.conf file.
[root@wxyz ~]# cd /etc
Next edit the file. We need to define a few environment variables, I am only including the ones I've changed:
# General configuration for the init.d scripts,
Next up we will deposit the init script in /etc/init.d and set the server to start on boot:
[root@wxyz wildfly]# cd /etc/ini t.d/
You will need to edit the wildfly script in two places; first, to change the default location of the wildfly.conf file from /etc/default/wildfly.conf, starting at line 19:
# Load JBoss AS init.d configuration.
As-is the scripts do not allow passing any additional options to the WildFly process, so we need to edit the /etc/init.d/wildfly script to add the $JBOSS_OPTS variable whenever WildFly is starting. Here is the edited snippet for the standalone configuration (I’ve added some line breaks for readability) starting from line 104:
if [ ! -z "$JBOSS_USER" ]; then
Next up we create the log directories and redirect the JBoss log directory to /var/log/wildfly and the tmp directory to /tmp/wildfly
[root@wxyz ~]# mkdir /var/log/wildfly
To get WildFly to use these directories, we set the system properties for them in /etc/wildfly/wildfly.properties:
# System properties for wildfly
At this point you can start the server using the command service wildfly start. You won’t be able to do much however, unless you like browsing via wget since the server is bound to the localhost interface only (and we are working on a headless server, i.e. no GUI web browser). So we’ll need to bind WildFly to all interfaces and open up the CentOS firewall to allow browsing to WildFly and the management console. Keep in mind that this may not be exactly what you want in a production environment or in environment where unknown users might access your server (like shared hosting).
First we’ll edit the /etc/wildfly/wildfly.properties file:
# System properties for wildfly
Depending on how your local network is setup you may need further configuration for WildFly to be completely happy binding to all interfaces. If your DNS recognizes the name of the CentOS server you are working on, congratulations, you are all set. On the other hand, if DNS is not configured for the server, you will need to add an entry to the /etc/hosts file pointing the name of the server to the external IP.
Next we need to open the firewall for ports 8080 (regular WildFly) and 9990 (the management console). Be careful when adjusting the firewall. The commands below use hard-coded line numbers that may not be appropriate for whatever system you are using. If you think you have screwed up your firewall use service iptables restart to reset it. Of course, this won’t work after you issue service iptables save so be extra sure before you save the rules. You will also need to replace 10.0.0.0 with your subnet below.
[root@wxyz ~]# # 8080 for WildFly applications
At this point you should be ready to go. Start up WildFly and try accessing it from your desktop.