1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # Search Package Apache Tomcat 8 sudo apt update sudo apt search tomcat8* # List tomcat8 /bionic-updates ,bionic-security 8.5.39-1ubuntu1~18.04.1 all Apache Tomcat 8 - Servlet and JSP engine tomcat8-admin /bionic-updates ,bionic-security 8.5.39-1ubuntu1~18.04.1 all Apache Tomcat 8 - Servlet and JSP engine -- admin web applications tomcat8-common /bionic-updates ,bionic-security 8.5.39-1ubuntu1~18.04.1 all Apache Tomcat 8 - Servlet and JSP engine -- common files tomcat8-docs /bionic-updates ,bionic-security 8.5.39-1ubuntu1~18.04.1 all Apache Tomcat 8 - Servlet and JSP engine -- documentation tomcat8-examples /bionic-updates ,bionic-security 8.5.39-1ubuntu1~18.04.1 all Apache Tomcat 8 - Servlet and JSP engine -- example web applications tomcat8-user /bionic-updates ,bionic-security 8.5.39-1ubuntu1~18.04.1 all Apache Tomcat 8 - Servlet and JSP engine -- tools to create user instances # Install Apache Tomcat 8, It will install [jre] and [tomcat8-common] with. sudo apt install tomcat8 # Check Apache Tomcat 8 Status sudo systemctl status tomcat8 # File Location /var/lib/tomcat8/ /etc/tomcat8/ |
Check http://your-domain:8080 at your web browser
Install tomcat8-admin Package
1 | sudo apt install tomcat8-admin |
Create user admin at file "/etc/tomcat/tomcat-users.xml" by add rolename, username and password
- Application Manager use http://your-domain:8080/manager
- Host Manager use http://your-domain:8080/host-manager
1 2 3 4 5 6 7 8 | <? xml version = "1.0" encoding = "UTF-8" ?> < tomcat-users xmlnx="...> < role rolename = "admin-gui" /> < role rolename = "manager-gui" /> < user username = "admin" password = "admin" role = "admin-gui,manager-gui" /> </ tomcat-users > |
Application Manager
Host Manager
Change Web Server Port 8080 To 80
We have 2 choice to change port1. Config at server.xml
Web Server config store in /etc/tomcat/server.xmlTo change web port we have to config this file
1 2 3 4 5 6 7 8 9 10 11 | # About line 70 at Connector tag port 8080 < Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" /> # Change 8080 to 80 < Connector port = "80" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" /> # Save and Restart Apache Tomcat 8 |
2. Use iptables to forward 8080 to 80
Reference: Linux port redirection with iptables1 2 3 4 5 6 7 8 9 | # 80 is source port to 8080 is destination port # eth0 is name of network interface sudo iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 80 -j REDIRECT --to-port 8080 # list iptables rule and sudo iptables -t nat -L PREROUTING # remove iptables rule / 1 is line number sudo iptables -t nat -D PREROUTING 1 |
Add Certification for HTTPS Protocal
Reference: Convert pfx to jks | Install SSL Tomcat 8.0 | Install SSL Tomcat 7.0For Tomcat 8.5 Following This Step
1.Convert .pfx to .jks
1 2 | keytool -importkeystore -srckeystore source .pfx -srcstoretype PKCS12 -destkeystore destination.jks -deststoretype JKS |
2. Config server.xml file
1 2 3 4 5 6 7 8 9 10 11 12 13 | # About line 90 at Connector tag port 8443 uncomment and edit 2 value # certificateKeystoreFile and add certificateKeystorePassword if keystore have password < Connector port = "8443" protocol = "org.apache.coyote.http11.Http11NioProtocol" maxThreads = "150" SSLEnabled = "true" > < SSLHostConfig > < Certificate certificateKeystoreFile = "conf/certificate.cert.jks" certificateKeystorePassword = "12345678" type = "RSA" /> </ SSLHostConfig > </ Connector > # Save file and restart apache tomcat |
Example Config in Tomcat 7.0
1 2 3 4 5 6 | < Connector port = "8443" protocol = "HTTP/1.1" SSLEnabled = "true" sslProtocol = "TLS" scheme = "https" secure = "true" clientAuth = "false" maxThreads = "150" keystoreFile = "conf/certificate.pfx" keystoreType = "PKCS12" keystorePass = "12345678" /> |
Reference: Deploy as Root
ไม่มีความคิดเห็น:
แสดงความคิดเห็น