Last active
September 15, 2022 21:00
-
-
Save jniltinho/9a704af6342f95d4f4e3d56e10cafeec to your computer and use it in GitHub Desktop.
Install GlassFish 5 CentOS 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Install GlassFish 5 64Bits on Linux (CentOS 8) | |
## https://www.oracle.com/br/java/technologies/javase/javase8-archive-downloads.html | |
## https://stackoverflow.com/questions/50374321/why-cant-access-to-glassfish-admin-console-remotely | |
## https://stackoverflow.com/questions/41974198/glassfish-change-admin-password | |
## https://www.osradar.com/how-to-install-glassfish-5-on-rhel-and-centos-8/ | |
## https://linuxways.net/centos/how-to-install-glassfish-on-centos-8/ | |
## https://www.rosehosting.com/blog/how-to-install-glassfish-5-on-centos-7/ | |
## https://gist.github.com/sdmcraft/2c5abbdeccf37e1642e5 | |
## https://download.oracle.com/otn/java/jdk/8u202-b08/1961070e4c9b4e26a04e7f5a083f551e/jdk-8u202-linux-x64.rpm | |
## https://mirrors.huaweicloud.com/java/jdk/8u202-b08/ | |
## https://xping.xyz/file/ | |
sed -i s/^SELINUX=.*$/SELINUX=disabled/ /etc/selinux/config | |
setenforce 0 | |
yum install -y wget unzip net-tools mlocate | |
#wget https://mirrors.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.rpm | |
#rpm -ivh jdk-8u202-linux-x64.rpm | |
wget -c https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz | |
tar xzf jdk-8u202-linux-x64.tar.gz | |
mv jdk1.8.0_202 /opt/ | |
alternatives --install /usr/bin/java java /opt/jdk1.8.0_202/bin/java 2 | |
alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_202/bin/jar 2 | |
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_202/bin/javac 2 | |
alternatives --set jar /opt/jdk1.8.0_202/bin/jar | |
alternatives --set javac /opt/jdk1.8.0_202/bin/javac | |
cat << 'EOF' >> /etc/profile | |
JAVA_HOME=/opt/jdk1.8.0_202 | |
export JRE_HOME=/opt/jdk1.8.0_202/jre | |
export PATH=$PATH:/opt/jdk1.8.0_202/bin:/opt/jdk1.8.0_202/jre/bin | |
EOF | |
source /etc/profile | |
useradd -s /sbin/nologin glassfish | |
wget -c http://download.oracle.com/glassfish/5.0/release/glassfish-5.0.zip | |
unzip -d /opt/ glassfish-5.0.zip | |
chown -R glassfish:glassfish /opt/glassfish5 | |
cat << 'EOF' > /usr/lib/systemd/system/glassfish.service | |
[Unit] | |
Description = GlassFish Server v5.0 | |
After = syslog.target network.target | |
[Service] | |
User = glassfish | |
ExecStart = /usr/bin/java -jar /opt/glassfish5/glassfish/lib/client/appserver-cli.jar start-domain | |
ExecStop = /usr/bin/java -jar /opt/glassfish5/glassfish/lib/client/appserver-cli.jar stop-domain | |
ExecReload = /usr/bin/java -jar /opt/glassfish5/glassfish/lib/client/appserver-cli.jar restart-domain | |
Type = forking | |
[Install] | |
WantedBy = multi-user.target | |
EOF | |
systemctl start glassfish | |
systemctl enable glassfish | |
sed -i 's/^PATH=*/PATH=\/opt\/glassfish5\/bin:/g' ~/.bash_profile | |
source ~/.bash_profile | |
cat << 'EOF' > /opt/pwdfile | |
AS_ADMIN_PASSWORD=glassfish512345678 | |
EOF | |
cat << 'EOF' > /opt/tmpfile | |
AS_ADMIN_PASSWORD= | |
AS_ADMIN_NEWPASSWORD=glassfish512345678 | |
EOF | |
## Enable Secure Admin | |
asadmin --user=admin --passwordfile=/opt/tmpfile change-admin-password | |
asadmin --user=admin --passwordfile=/opt/pwdfile enable-secure-admin | |
systemctl restart glassfish | |
## Note** we may unable to access the Glassfish Admin Console after enabling the secure login due to older version of Grizzly | |
## module so we will update Grizzly using below commands to access Glassfish admin console. | |
cd /opt/glassfish5/glassfish/modules/endorsed | |
mv grizzly-npn-bootstrap.jar grizzly-npn-bootstrap.jar.1 | |
wget https://search.maven.org/remotecontent?filepath=org/glassfish/grizzly/grizzly-npn-bootstrap/1.9/grizzly-npn-bootstrap-1.9.jar -O grizzly-npn-bootstrap.jar | |
chown glassfish:glassfish grizzly-npn-bootstrap.jar | |
systemctl restart glassfish | |
## https://SERVER-IP-OR-DOMAIN-NAME:4848/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment