Site icon Learning & Doing

Cara Install Tomcat 9 pada Amazon Linux

tomcat

“Cara Install Tomcat 9 pada Amazon Linux”

Pengantar

Apache Tomcat adalah server web HTTP JAVA gratis yang dikembangkan oleh Apache Software Foundation. Tomcat adalah implementasi dari Java Servlet, JavaServer Pages, Java Expression Language dan teknologi WebSocket.

Singkatnya Apache Tomcat menjalankan lingkungan server web HTTP di mana program Java khusus yang dikenal sebagai “Java Servlet” dan “Java Server Pages (JSP)” dapat dijalankan. Karena sifatnya yang open-source, Tomcat telah diadopsi secara luas oleh pelanggan Perusahaan. Ini memperkuat platform Pembayaran, platform E-Commerce, lingkungan Cloud di antara banyak kasus penggunaan lainnya.

Install Tomcat 9 pada Amazon Linux

1. Install Java

sudo yum -y update
sudo amazon-linux-extras install java-openjdk11
java -version

2. Buat User tomcat

sudo groupadd --system tomcat
sudo useradd -d /usr/share/tomcat -r -s /bin/false -g tomcat tomcat
$ getent passwd tomcat
tomcat:x:996:994::/usr/share/tomcat:/bin/false

$ getent group tomcat
tomcat:x:994:

3. Install Tomcat 9

sudo yum -y install wget
export VER="9.0.39"
wget https://archive.apache.org/dist/tomcat/tomcat-9/v${VER}/bin/apache-tomcat-${VER}.tar.gz
sudo tar xvf apache-tomcat-${VER}.tar.gz -C /usr/share/
sudo ln -s /usr/share/apache-tomcat-$VER/ /usr/share/tomcat
sudo chown -R tomcat:tomcat /usr/share/tomcat
sudo chown -R tomcat:tomcat /usr/share/apache-tomcat-$VER/ 
sudo tee /etc/systemd/system/tomcat.service<<EOF
[Unit]
Description=Tomcat Server
After=syslog.target network.target

[Service]
Type=forking
User=tomcat
Group=tomcat

Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment='JAVA_OPTS=-Djava.awt.headless=true'
Environment=CATALINA_HOME=/usr/share/tomcat
Environment=CATALINA_BASE=/usr/share/tomcat
Environment=CATALINA_PID=/usr/share/tomcat/temp/tomcat.pid
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M'
ExecStart=/usr/share/tomcat/bin/catalina.sh start
ExecStop=/usr/share/tomcat/bin/catalina.sh stop

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl start tomcat
sudo systemctl enable tomcat

4. Tambahkan rule firewall

sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

5. Setting Tomcat

sudo vim /usr/share/tomcat/conf/tomcat-users.xml

Edit bagian

<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="admin" password="TomcatAdminP@ssw0rd" fullName="Administrator" roles="admin-gui,manager-gui"/>

Install Apache

sudo yum -y install httpd 
sudo vim /etc/httpd/conf.d/tomcat_manager.conf
<VirtualHost *:80>
    ServerAdmin root@localhost
    ServerName tomcat.hendro-wibiksono.com
    DefaultType text/html
    ProxyRequests off
    ProxyPreserveHost On
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
</VirtualHost>
<VirtualHost *:80>
  ServerName ajp.example.com

  ProxyRequests Off
  ProxyPass / ajp://localhost:8009/
  ProxyPassReverse / ajp://localhost:8009/
</VirtualHost>
sudo setsebool -P httpd_can_network_connect 1
sudo setsebool -P httpd_can_network_relay 1
sudo setsebool -P httpd_graceful_shutdown 1
sudo setsebool -P nis_enabled 1
sudo systemctl restart httpd
sudo systemctl enable httpd

Akses GUI via web

http://ip-external atau http://domain

Penutup

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai Cara Install Tomcat 9 pada Amazon Linux. Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

Exit mobile version