In order to start the wildfly service automatically whenever your server gets restarted, one needs to configure the wildfly as a service. One has to perform different steps for different flavors of linux.
RPM based Linux ( Red hat and Centos)
In order to run wildfly as a service, one will need to copy wildfly-init-redhat.sh file into /etc/init.d/wildfly folder. One will need to create a default directory in etc folder in order to put the config file (wilfly.conf) in the folder for system to be able to read the configured java parameters.
- cp WILDFLY_HOME/bin/init.d/wildfly-init-redhat.sh /etc/init.d/wildfly
- mkdir –p /etc/default
- cp WILDFLY_HOME/bin/init.d/wildfly.conf /etc/default
Then one will need to go to the default directory and required to edit the java parameters as shown below.
- cd /etc/default
Edit file wildfly.conf and uncomment following parameters by removing #. Also, need to change the values of the parameters as below.
- vi /etc/default/wildfly.conf
- JAVA_HOME=/usr/java/jdk1.7.0_21 (Configure the default path of JDK Installed in your system, here it's /usr/java/jdk1.7.0_21 )
- JBOSS_HOME=/usr/share/wildfly.8.0.0.Final ( Location of Wildfly folder)
- JBOSS_USER=root (Change user from 'wildfly' to 'user' having rights on wildfly folder. Recommended user is the 'root' user)
- JBOSS_MODE=standalone (Only uncomment this line)
- JBOSS_CONFIG=standalone.xml (Only uncomment this line)
- JBOSS_CONSOLE_LOG="/var/log/wildfly/console.log (Only uncomment this line)
Sometimes due to lack of full permissions to wildfly folder, system throws an error. In order to avoid that one will require to give full permissions to wildfly/bin/standalone.sh file as well as to /etc/init.d/wildfly file.
- chmod 777 wildfly/bin/standalone.sh
- chmod 755 /etc/init.d/wildfly
Now, your service has been configured. In order to start the wildfly service automatically whenever your server gets restarted, please perform following steps.
- chkconfig --add wildfly
- chkconfig --level 2345 wildfly on
To start the service -
- Use command /etc/init.d/wildlfy start or service wildfly start command to start wildfly service
Debian based Linux ( Ubuntu )
In order to run wildfly as a service, one will need to copy wildfly-init-debian.sh file into /etc/init.d/wildfly folder. One will need to create a default directory in etc folder (if it's not available) in order to put the config file (wilfly.conf) in the folder for system to be able to read the configured java parameters.
- cp WILDFLY_HOME/bin/init.d/wildfly-init-debian.sh /etc/init.d/wildfly
- mkdir –p /etc/default
- cp WILDFLY_HOME/bin/init.d/wildfly.conf /etc/default/wildfly
Edit file wildfly.conf and uncomment following parameters by removing #. Also, need to change the values of the parameters as below.
- vi /etc/default/wildfly.conf
- JAVA_HOME=/usr/java/jdk1.7.0_21 (Configure the default path of JDK Installed in your system, here it's /usr/java/jdk1.7.0_21 )
- JBOSS_HOME=/usr/share/wildfly.8.0.0.Final ( Location of Wildfly folder)
- JBOSS_USER=root (Change user from 'wildfly' to 'user' having rights on wildfly folder. Recommended user is the 'root' user)
- JBOSS_MODE=standalone (Only uncomment this line)
- JBOSS_CONFIG=standalone.xml (Only uncomment this line)
- JBOSS_CONSOLE_LOG="/var/log/wildfly/console.log (Only uncomment this line)
In case of Debian, we are required to change the ownership of wildfly file. Do the folowing-
- sudo chown root:root /etc/init.d/wildfly
Sometimes due to lack of full permissions to wildfly folder, system throws an error. In order to avoid that one will require to give full permissions to below folders & files.
- sudo chown -R root:root /wildfly
- chmod 755 wildfly
- chmod 755 /etc/init.d/wildfly
- chmod 755 -R wildfly/bin/
Now, your service has been configured. In order to start the wildfly service automatically whenever your server gets restarted, please perform following steps.
- sudo chmod +X /etc/init.d/wildfly
- sudo update-rc.d wildfly defaults
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article