{"id":9682,"date":"2021-09-01T17:53:41","date_gmt":"2021-09-01T17:53:41","guid":{"rendered":"https:\/\/linuxways.net\/?p=9682"},"modified":"2021-09-01T17:53:41","modified_gmt":"2021-09-01T17:53:41","slug":"how-to-install-glassfish-on-centos-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-install-glassfish-on-centos-8\/","title":{"rendered":"How to Install GlassFish on CentOS 8"},"content":{"rendered":"<p>GlassFish is an open-source and Java-supported application server through which users can run Java-based applications. It supports the latest Java platforms such as Enterprise JavaBeans, JavaServer Faces, JPA, JavaServer Pages, JMS, RMI and servlets, etc. Glassfish allows developers to build enterprise applications that are scalable and portable and can integrate with legacy technologies. Users can also install optional components for providing additional services. We will discuss the installation of the GlassFish application server on the CentOS 8 system in this article.<\/p>\n<h2><strong>Prerequisites<\/strong><\/h2>\n<p>Root privileges are required to assign administrative roles and systemd services configurations.<\/p>\n<h2><strong>Installing GlassFish Application Server on CentOS 8<\/strong><\/h2>\n<p>Follow the following key steps to install the GlassFish server on CentOS 8:<\/p>\n<h3><strong>Step 1: Install Java OpenJDK\u00a0<\/strong><\/h3>\n<p>At that time, different Java versions are available for installation. However, for convenience install only the most commonly used LTS OpenJDK Java version OpenJDK 11 and 8. Most of the application supports OpenJDK 11 and some support OpenJDK 8. Therefore, install both Java versions one by one on CentOS 8 system. First, install the OpenJDK 11 by using the below-mentioned command:<\/p>\n<pre>$ sudo dnf install java-11-openjdk-devel<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1093\" height=\"644\" class=\"wp-image-9683\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-539.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-539.png 1093w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-539-300x177.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-539-1024x603.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-539-768x453.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-539-1020x600.png 1020w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/p>\n<p>Once the OpenJDK 11 is installed on your system, type the following command to install OpenJDK 8 on CentOS 8:<\/p>\n<pre>$ sudo dnf install java-1.8.0-openjdk-devel<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1103\" height=\"651\" class=\"wp-image-9684\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-540.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-540.png 1103w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-540-300x177.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-540-1024x604.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-540-768x453.png 768w\" sizes=\"auto, (max-width: 1103px) 100vw, 1103px\" \/><\/p>\n<p>Verify the installation of Java by running the below-given command:<\/p>\n<pre>$ java -version<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1099\" height=\"139\" class=\"wp-image-9685\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-541.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-541.png 1099w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-541-300x38.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-541-1024x130.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-541-768x97.png 768w\" sizes=\"auto, (max-width: 1099px) 100vw, 1099px\" \/><\/p>\n<p>Now, to switch between two Java alternatives use the following command:<\/p>\n<pre>$ update-alternatives --config java<\/pre>\n<p>Using the above command, select the number that Java version you want to use on your system as the default version.<\/p>\n<h3><strong>Step 2: Install GlassFish on CentOS 8 system<\/strong><\/h3>\n<p>First, add a user for Glassfish by running the below-mentioned command using root privileges:<\/p>\n<pre># useradd -s \/sbin\/nologin glassfish<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1086\" height=\"59\" class=\"wp-image-9686\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-542.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-542.png 1086w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-542-300x16.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-542-1024x56.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-542-768x42.png 768w\" sizes=\"auto, (max-width: 1086px) 100vw, 1086px\" \/><\/p>\n<h3><strong>Step 3: Download GlassFish Stable version<\/strong><\/h3>\n<p>Download the GlassFish most stable version according to the requirement on your system using the \u2018wget\u2019 command as follows:<\/p>\n<pre># wget <a href=\"http:\/\/download.oracle.com\/glassfish\/5.0\/release\/glassfish-5.0.zip\">http:\/\/download.oracle.com\/glassfish\/5.0\/release\/glassfish-5.0.zip<\/a><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1104\" height=\"617\" class=\"wp-image-9687\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-543.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-543.png 1104w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-543-300x168.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-543-1024x572.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-543-768x429.png 768w\" sizes=\"auto, (max-width: 1104px) 100vw, 1104px\" \/><\/p>\n<p>We have downloaded glassfish version 5 on this system. You can download the available latest version from the oracle website. The zip file will download on your system.<\/p>\n<h3><strong>Step 4: Unzip the GlassFish release<\/strong><\/h3>\n<p>Unzip the downloaded file by using the unzip command. Type the below-given terminal command to unzip the glassfish zipped file:<\/p>\n<pre># unzip -d \/opt\/ glassfish-5.0.zip<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1102\" height=\"638\" class=\"wp-image-9688\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-544.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-544.png 1102w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-544-300x174.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-544-1024x593.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-544-768x445.png 768w\" sizes=\"auto, (max-width: 1102px) 100vw, 1102px\" \/><\/p>\n<p>Now, assign privileges to the GlassFish user of the \u2018\/opt\/ glassfish5\/\u2019 directory.<\/p>\n<pre># chown -R glassfish:glassfish \/opt\/glassfish5\/<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1090\" height=\"54\" class=\"wp-image-9689\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-545.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-545.png 1090w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-545-300x15.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-545-1024x51.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-545-768x38.png 768w\" sizes=\"auto, (max-width: 1090px) 100vw, 1090px\" \/><\/p>\n<h3><strong>Step 5: Create GlassFish systemd service<\/strong><\/h3>\n<p>Now, create the (glassfish.service) systemd service for running GlassFish server on CentOS 8. Create a file using text editor as follows:<\/p>\n<pre># nano \/usr\/lib\/systemd\/system\/glassfish.service<\/pre>\n<p>Paste the following lines of code in this systemd service file:<\/p>\n<pre>[Unit]\r\n\r\nDescription = GlassFish Server v5.0\r\n\r\nAfter = syslog.target network.target\r\n\r\n[Service]\r\n\r\nUser = glassfish\r\n\r\nExecStart = \/usr\/bin\/java -jar \/opt\/glassfish5\/glassfish\/lib\/client\/appserver-cli.jar start-domain\r\n\r\nExecStop = \/usr\/bin\/java -jar \/opt\/glassfish5\/glassfish\/lib\/client\/appserver-cli.jar stop-domain\r\n\r\nExecReload = \/usr\/bin\/java -jar \/opt\/glassfish5\/glassfish\/lib\/client\/appserver-cli.jar restart-domain\r\n\r\nType = forking\r\n\r\n[Install]\r\n\r\nWantedBy = multi-user.target<\/pre>\n<p>Now, exit from the current displaying window after saving all changes in this file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1091\" height=\"748\" class=\"wp-image-9690\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-546.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-546.png 1091w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-546-300x206.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-546-1024x702.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-546-768x527.png 768w\" sizes=\"auto, (max-width: 1091px) 100vw, 1091px\" \/><\/p>\n<h3><strong>Step 6: Enable and start GlassFish server<\/strong><\/h3>\n<p>Start the GlassFish server and enable it on CentOS 8 system by running the below-mentioned commands:<\/p>\n<pre>$ sudo systemctl start glassfish.service<\/pre>\n<pre>$ sudo systemctl enable glassfish.service<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1093\" height=\"135\" class=\"wp-image-9691\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-547.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-547.png 1093w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-547-300x37.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-547-1024x126.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-547-768x95.png 768w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/p>\n<pre>$ sudo systemctl status glassfish.service<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1103\" height=\"512\" class=\"wp-image-9692\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-548.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-548.png 1103w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-548-300x139.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-548-1024x475.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-548-768x356.png 768w\" sizes=\"auto, (max-width: 1103px) 100vw, 1103px\" \/><\/p>\n<h3><strong>Step 7: Firewall Configuration<\/strong><\/h3>\n<p>Configure the firewall setting. Open the HTTP ports (4848, 8080, and 8181) in the firewall for running the Glassfish server.<\/p>\n<pre>$ sudo firewall-cmd --add-port={4848,8080,8181}\/tcp --permanent<\/pre>\n<pre>$ sudo firewall-cmd --reload<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1102\" height=\"167\" class=\"wp-image-9693\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-549.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-549.png 1102w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-549-300x45.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-549-1024x155.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-549-768x116.png 768w\" sizes=\"auto, (max-width: 1102px) 100vw, 1102px\" \/><\/p>\n<p>The success status should display on the terminal for enabling the firewall settings.<\/p>\n<h3><strong>Step 8: Launch GlassFish server web interface<\/strong><\/h3>\n<p>GlassFish can listen on HTTP as default port 8080 and port 4848 by the administration. So, open the web browser MozilaFirefox and enter one of the following URLs in the address bar.<\/p>\n<pre><a href=\"http:\/\/domain.com:8080\">http:\/\/domain.com:8080<\/a><\/pre>\n<p>Or<\/p>\n<pre><a href=\"http:\/\/ip-address-server:4848\">http:\/\/IP-Address-Server:4848<\/a><\/pre>\n<p>The following glassfish web interface will launch on the system after completing the required login steps automatically.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1204\" height=\"813\" class=\"wp-image-9694\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-550.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-550.png 1204w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-550-300x203.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-550-1024x691.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-550-768x519.png 768w\" sizes=\"auto, (max-width: 1204px) 100vw, 1204px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>We learned how to install the GlassFish application server on CentOS 8 in this article. We have observed how to define systemd services for running Glassfish server and firewall configurations. After launching the GlassFish web interface you can enjoy its benefits and run multiple Java applications on it.<\/p>","protected":false},"excerpt":{"rendered":"<p>GlassFish is an open-source and Java-supported application server through which users can run Java-based applications. It supports the latest Java platforms such as Enterprise JavaBeans, JavaServer Faces, JPA,&hellip;<\/p>","protected":false},"author":1,"featured_media":9766,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[93,512],"class_list":["post-9682","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-centos-8","tag-glassfish"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=9682"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9682\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/9766"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=9682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=9682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=9682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}