WildFly Application Deployment in Standalone mode
Posted by on 31 July 2014 02:03 PM
|
|||||||
Applicable Plans - All Cloud Hosting PlansWildFly Application Deployment in Standalone modeNOTE - this is the WildFly deployment guide. Information on installing and tuning WildFly is found in the WildFly Installation and Tuning User Guide. WildFly is the continuation of the open source JBoss Application Server (JBoss AS) project. The project was renamed by Red Hat in order to differentiate the open source JBoss AS project from the commercial Red Hat JBoss Middleware project. More information about WildFly can be found here - What Is WildFly? One of the main advantages of WildFly is the Undertow web server. Undertow was built to be fast, lightweight, and scalable to over a million connections. If you are deploying a high performance, single purpose application, Undertow is the best choice. More information about Undertow can be found here - Undertow Web Server. WildFly Operating Modes - OverviewThere are two operating modes for WildFly deployment: as a Standalone server, and as a Managed Domain
More information about WildFly Operating Modes can be found here - WildFly Operating Modes. WildFly Deployment in Standalone Server ModeThe default deployment approach for WildFly at eApps is to have Apache as the front-end for WildFly and to use either mod_jk or mod_proxy_ajp to pass requests from the Apache web server to WildFly. This allows the Apache web server to serve static content and applications that require Apache (PHP or HTML applications), and the Undertow web server that is built-in to WildFly to serve JSPs and Servlets. If you do not need to serve PHP or HTML applications and want to maximize the performance of your WildFly server you can turn off and disable the Apache web server. This will allow you to configure the Virtual Server to pass all requests directly to the Undertow web server included with WildFly. This User Guide explains how to configure WildFly to serve applications in Standalone server mode either with or without Apache, and also how to upload and deploy your WAR file using the WildFly Administration Console.
----- With Apache ----- ----- Without Apache ----- ----- Completing Your Deployment using the WildFly Admin Console ----- WildFly Deployment in Standalone Mode with ApacheUsing mod_jk or mod_proxy_ajp you can have the Apache web server as a front-end to WildFly. This is the most common usage at eApps, because it allows you to serve applications that require Apache along with your Java application being served by WildFly. mod_jk and mod_proxy_ajp DeploymentBoth mod_jk and mod_proxy_ajp work by using directives to send requests to the Apache web server to files or applications as specified by the directive. For example, this allows you to pass all requests for .php files to Apache, and all requests for .jsp files to WildFly.
Both mod_jk and mod_proxy_ajp work in a very similar manner. If you have a preferred approach, use that. If you do not have a preferred approach, use mod_jk. Deployment examples using WildFly in Standalone mode with ApacheThere are two ways to deploy applications using WildFly in Standalone mode with Apache:
Deployment example with WildFly serving JSP and Servlet using a WAR file from the domain directory, Apache serving all other contentThis deployment example assumes you have a WAR file called mywebapp.war, using a Virtual Host of eapps-example.com. For this deployment approach to work, you will need to add the following in your WEB-INF/jboss-web.xml file: <jboss-web> mod_jk directives to serve eapps-example.comTo serve eapps-example.com using mod_jk, add the following directive to the VirtualHost block for the website. The mod_jk directives in this example will serve all applications provided by eApps but forward all other requests to WildFly. You can all the directives to the VirtualHost block from the Control Panel or from the command line. Using a Control Panel
Information on how to tell which version of ISPmanager you are using can be found here - ISPmanager versions JkMount /* ajp13 Depending on the applications you have installed, you may need different (or additional or fewer) no-jk settings. If you are using ISPmanager 4, make a note of these three "no-jk" directives: SetEnvIf Request_URI "/manager/ispmgr*" no-jk These are the directives that allow the ISPmanager 4 Control Panel to still be available, even if everything else is being forwarded to WildFly. These must be included if you still want to use ISPmanager 4. Once you have added the settings, click Ok to restart Apache. Using the command line You can also add the directives to the VirtualHost block for the website in the httpd.conf file, and then restart Apache. mod_proxy_ajp directives to serve eapps-example.comTo serve eapps-example.com using mod_proxy_ajp, add the following directive to the VirtualHost block for the website. The mod_proxy_ajp directives in this example will serve all applications provided by eApps but forward all other requests to WildFly. You can all the directives to the VirtualHost block from the Control Panel or from the command line. Using a Control Panel
Information on how to tell which version of ISPmanager you are using can be found here - ISPmanager versions # Directives for your application Depending on the applications you have installed, you may need different (or additional or fewer) ProxyPass settings. If you are using ISPmanager 4, make a note of these three "mod_proxy_ajp" directives: ProxyPass /manager/ispmgr ! These are the directives that allow the ISPmanager 4 Control Panel to still be available, even if everything else is being forwarded to WildFly. These must be included if you still want to use ISPmanager 4. Once you have added the settings, click Ok to restart Apache. Using the command line You can also add the directive to the VirtualHost block for the website in the httpd.conf file, and then restart Apache. Deployment example with WildFly serving JSP and Servlet using a WAR file from a subdirectory, Apache serving all other contentThis deployment example assumes you have a WAR file called mywebapp.war, using a Virtual Host of eapps-example.com. For this deployment approach to work, you will need to add the following in your WEB-INF/jboss-web.xml file: <jboss-web> mod_jk directives to serve eapps-example.com/mywebappTo serve eapps-example.com/mywebapp using mod_jk, add the following directive to the VirtualHost block for the website. The mod_jk directives in this example will serve all applications provided by eApps but forward all other requests to WildFly. You can all the directives to the VirtualHost block from the Control Panel or from the command line. Using a Control Panel
Information on how to tell which version of ISPmanager you are using can be found here - ISPmanager versions JkMount /mywebapp* ajp13 This directive passes all requests for /mywebapp to WildFly, and allows Apache to serve all other content. Once you have added the settings, click Ok to restart Apache. Using the command line You can also add the directive to the VirtualHost block for the website in the httpd.conf file, and then restart Apache. mod_proxy_ajp directives to serve eapps-example.com/mywebappTo serve eapps-example.com/mywebapp using mod_proxy_ajp, add the following directive to the VirtualHost block for the website. The mod_proxy_ajp directives in this example will serve all applications provided by eApps but forward all other requests to WildFly. You can all the directives to the VirtualHost block from the Control Panel or from the command line. Using a Control Panel
Information on how to tell which version of ISPmanager you are using can be found here - ISPmanager versions ProxyPass /mywebapp ajp://localhost:8009/mywebapp Once you have added the settings, click Ok to restart Apache. Using the command line You can also add the directive to the VirtualHost block for the website in the httpd.conf file, and then restart Apache. This directive passes all requests for /mywebapp to WildFly, and allows Apache to serve all other content. WildFly Deployment in Standalone Mode without ApacheIf you do not need to use Apache, you can run WildFly directly from the built-in Undertow web server. This approach is often used when the Virtual Server will do nothing but serve the production Java application - there will be no other applications such as WordPress or Webmail available. In order to run WildFly in Standalone mode without Apache, you will need to disable the Apache web server, and then redirect traffic from the port Apache listens on to the port used by WildFly. If you still wish to use the ISPmanager 4 Control Panel, you can configure it to run using its own web server and port. The ISPmanager 5 Control Panel needs no additional configuration - it is set up to run using its own web server and port by default. Using the WildFly Administration Console, you can deploy your WAR file and set up your WildFly Virtual Host. Then you can set up your application deployment approach depending on how you have configured your WEB-INF/jboss-web.xml file. See the section of this User Guide titled Deploying your application using the WildFly 8 Administration Console for more information on deploying your WAR files. How to disable Apache, set up ISPmanager to run using its own web server, and set up your jboss-web.xml file for you application deployment approach is covered below. Stopping Apache and Configuring the Port RedirectWildFly cannot run on port 80 because root privileges are required. Since WildFly does not have the ability to start as root, bind to port 80, then switch back to a user without administrative privileges it would have to run as root. This creates a security issue for your system. To use WildFly in Standalone mode without Apache, you will need to add a file to the /etc/xinted.d directory that will keep WildFly running on port 8080, and have any requests to port 80 redirected to WildFly. All of this must be done from the command line of the Virtual Server, as the root user. See the SSH User Guide for more information if needed. Stopping ApacheTo stop Apache, you need to stop the httpd service. Once the httpd service is stopped, you will need to prevent it from starting again at the next Virtual Server reboot.
Add the port 80 redirectTo set up the redirect so that requests on port 80 are redirected to port 8080, change directories to /etc/xinetd.d, and create the wildfly file: [root@eapps-example ]# cd /etc/xinetd.d Using a text editor (this example uses the vim editor), add these lines to the wildfly file: # Redirects any requests on port 80 Save and exit the file, and then restart the xinetd service.
Configure ISPmanager 4 to run on its own web server and portISPmanager 4 uses the Apache web server and runs on port 80 by default. If you will want to use the ISPmanager 4 Control Panel while running WildFly without Apache you will need to make the following changes. Note that ISPmanager 5 is already set up to run with its own web server by default - no changes are needed for ISPmanager 5. Information on how to tell which version of ISPmanager you are using can be found here - ISPmanager versions
To start ISPmanager 4 running using its own web server and port, run the following command as the root user: [root@eapps-example ~]# /usr/local/ispmgr/sbin/ihttpd IP_ADDRESS 1500 To make sure that ISPmanager 4 starts at system boot, you will also need to either add or edit a line in /etc/rc.local. Depending on the age of your Virtual Server, your rc.local file may contain the following lines: /var/lock/subsys/local Uncomment the /usr/local/ispmgr/sbin/ihttpd 69.89.2.169 1500 line, and change the IP address to match the main IP address of the Virtual Server. Save and exit the file. If your rc.local file does not already contain the /usr/local/ispmgr/sbin/ihttpd 69.89.2.169 1500 line, add that line to the file, and make sure to use the main IP address of your Virtual Server. Save and exit the file. The file should look like this when you are done. Remember to substitute the main IP address of the Virtual Server for IP_ADDRESS. /var/lock/subsys/local When the Virtual Server is rebooted, this will make sure that ISPmanager 4 is available at the direct URL of https://IP_ADDRESS:1500 (note the https). Deployment examples using WildFly in Standalone mode without ApacheThere are two ways to deploy applications using WildFly in Standalone mode without Apache:
Deployment example with WildFly serving JSP and Servlets using a WAR file from the domain directoryThis deployment example assumes you have a WAR file called mywebapp.war, using a Virtual Host of eapps-example.com. For this deployment approach to work, you will need to add the following in your WEB-INF/jboss-web.xml file: <jboss-web> Deployment example with WildFly serving JSP and Servlets using a WAR file from a subdirectoryThis deployment example assumes you have a WAR file called mywebapp.war, using a Virtual Host of eapps-example.com. For this deployment approach to work, you will need to add the following in your WEB-INF/jboss-web.xml file: <jboss-web> Deploying your application using the WildFly Administration ConsoleTo deploy your application from the WildFly Administration Console, you will need to do the following:
Upload your WAR file (but DO NOT enable it)Log in to the WildFly Administration Console to upload your WAR file. To access the Administration Console, go to http://eapps-example.com:9990 (substitute your domain name or IP address for eapps-example.com). The User Name and Password for the Administration Console is located in a file on the Virtual Server - Once you are logged in to the WildFly Administration Console, click on the Deployments menu at the top of the screen. ![]() In the Deployments screen, click on Add. This opens the Create Deployment dialog, on the Deployment Selection screen. ![]() Click on Choose File, and browse on your local computer to the location of your WAR file. Select it, and click Open. This will show the name of your WAR file in place of No File Chosen. Click Next.
![]() DO NOT CLICK ENABLE. Click on Save. This takes you back to the Deployments screen, showing your WAR file as Deployed, but not Enabled.
![]()
Create the Virtual Host
After you have uploaded and deployed your WAR file, you will need to create the Virtual Host in the WildFly Administration Console. To do this, click on the Configuration tab, and go to Subsystems > Web > HTTP. ![]()
![]()
![]()
Once you have entered the information, click Save. This adds the Virtual Host to WildFly. ![]()
Enable your WAR fileAfter you have added the Virtual Host to WildFly, you can enable the WAR file. Click on Deployments, and then click on the name of the WAR file to highlight it (this will put a small blue triangle to the left of the file name). Click En/Disable to enable the deployment. You will need to confirm that you want to enable the application. Once you have done this, your deployment will be enabled. ![]() At this point your application is enabled and available. Test by going to the URL defined in your deployment method. | |||||||
|