{"id":62,"date":"2024-06-23T10:55:26","date_gmt":"2024-06-23T02:55:26","guid":{"rendered":"http:\/\/www.iunfair.com\/wordpress\/?p=62"},"modified":"2024-06-23T11:06:26","modified_gmt":"2024-06-23T03:06:26","slug":"%e5%9c%a8debian%e4%b8%8a%e5%ae%89%e8%a3%85tomcat-9","status":"publish","type":"post","link":"https:\/\/www.iunfair.com\/wordpress\/2024\/06\/23\/%e5%9c%a8debian%e4%b8%8a%e5%ae%89%e8%a3%85tomcat-9\/","title":{"rendered":"\u5728Debian 12 \u4e0a\u5b89\u88c5Tomcat 9"},"content":{"rendered":"\n<p>\u5b89\u88c5JDK\uff08\u53ef\u5b89\u88c5oracle JDK\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install openjdk-17-jdk\njava -version<\/code><\/pre>\n\n\n\n<p>\u6dfb\u52a0\u7528\u6237\u5e76\u521b\u5efa\u76ee\u5f55<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>useradd -r -d \/opt\/tomcat9 -s \/bin\/false tomcat\nmkdir \/opt\/tomcat9<\/code><\/pre>\n\n\n\n<p>\u4e0b\u8f7dtomcat\u5305\uff0c\u89e3\u538b\u7f29\u5e76\u8bbe\u7f6e\u6743\u9650<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#VER=9.0.80\nwget https:\/\/dlcdn.apache.org\/tomcat\/tomcat-9\/v${VER}\/bin\/apache-tomcat-${VER}.tar.gz\n\ntar xzf apache-tomcat-${VER}.tar.gz -C \/opt\/tomcat9 --strip-components=1\nls -alh1 \/opt\/tomcat9\/\n\n#Ensure that tomcat user owns the directories, work, temp, webapps and logs;\nchown -R tomcat: \/opt\/tomcat9\/{logs,temp,webapps,work}\n\n#Next, you need to set the group ownership of the rest of the files\/directories within the Tomcat 9 directory to tomcat.\nchown -R :tomcat \/opt\/tomcat9\/\n\n#Assign tomcat group the read permissions on the Tomcat 9 configuration files directory.\nchmod -R g+r \/opt\/tomcat9\/conf\n\n#Next, assign the group ownership the execution permissions on the Tomcat 9 configuration files directory.\nchmod g+x \/opt\/tomcat9\/conf<\/code><\/pre>\n\n\n\n<p>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#To begin with, set the CATALINA_HOME environment variable to the above created Tomcat directory where the binary files exist.\necho 'export CATALINA_HOME=\"\/opt\/tomcat9\"' > \/etc\/profile.d\/tomcat9.sh\n\n#Also, you need to set JRE_HOME (JRE) or JAVA_HOME (JDK) environment variable for the Java version you have installed.\n#You can find the path with update-java-alternatives command.\nupdate-java-alternatives -l\n\njava-1.17.0-openjdk-amd64      1711       \/usr\/lib\/jvm\/java-1.17.0-openjdk-amd64\nHence,\n\n#echo 'export JAVA_HOME=\"\/usr\/lib\/jvm\/java-1.17.0-openjdk-amd64\"' >> \/etc\/profile.d\/tomcat9.sh \n\n#Reload the environment variables set above.\nsource \/etc\/profile.d\/tomcat9.sh<\/code><\/pre>\n\n\n\n<p>\u8bbe\u7f6e\u7ba1\u7406\u8d26\u6237<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/opt\/tomcat9\/conf\/tomcat-users.xml<\/code><\/pre>\n\n\n\n<p>\u8bbe\u7f6e\u8fdc\u7a0bip<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>vim \/opt\/tomcat9\/webapps\/manager\/META-INF\/context.xml\n<\/strong>...\n  &lt;Valve className=\"org.apache.catalina.valves.RemoteAddrValve\"\n          allow=\"127\\.\\d+\\.\\d+\\.\\d+|::1|0:0:0:0:0:0:0:1|192.168.43.96\" \/>\n...\n<strong>vim \/opt\/tomcat9\/webapps\/host-manager\/META-INF\/context.xml\n<\/strong>...\n  &lt;Valve className=\"org.apache.catalina.valves.RemoteAddrValve\"\n         allow=\"127\\.\\d+\\.\\d+\\.\\d+|::1|0:0:0:0:0:0:0:1|192.168.43.96\" \/>\n...<\/code><\/pre>\n\n\n\n<p>\u542f\u52a8tomcat9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Tomcat can be run by executing the startup script, \/opt\/tomcat9\/bin\/startup.sh.\n#If you are accessing Apache Tomcat externally, you need to open port 8080 on UFW.\n<strong>ufw allow 8080\n<\/strong>\n#Running Tomcat 9 startup script\n<strong>\/opt\/tomcat9\/bin\/startup.sh\n<\/strong>\n#You can now access your Tomcat 9 using the address, http:\/\/server-IP:8080\n<\/code><\/pre>\n\n\n\n<p>\u521b\u5efa\u670d\u52a1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>vim \/etc\/systemd\/system\/tomcat9.service<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=Apache Tomcat 9 Web Application Server\nDocumentation=https:\/\/tomcat.apache.org\/tomcat-9.0-doc\/index.html\nAfter=network.target\n\n&#91;Service]\nType=forking\nUser=tomcat\nGroup=tomcat\n\nEnvironment=JAVA_HOME=\/usr\/lib\/jvm\/java-1.17.0-openjdk-amd64\nEnvironment=\"CATALINA_HOME=\/opt\/tomcat9\"\nEnvironment=\"CATALINA_BASE=\/opt\/tomcat9\"\nEnvironment=\"JAVA_OPTS=-Djava.awt.headless=true\"\n\nExecStart=\/opt\/tomcat9\/bin\/startup.sh\nExecStop=\/opt\/tomcat9\/bin\/shutdown.sh\n\n\n&#91;Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#Start and enable the service;\nsystemctl daemon-reload\nsystemctl enable --now tomcat9<\/code><\/pre>\n\n\n\n<p>\u68c0\u67e5\u72b6\u6001<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status tomcat9<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u25cf tomcat9.service - Apache Tomcat 9 Web Application Server\n     Loaded: loaded (\/etc\/systemd\/system\/tomcat9.service; enabled; preset: enabled)\n     Active: active (running) since Tue 2023-08-29 14:34:13 EDT; 3min 36s ago\n       Docs: https:\/\/tomcat.apache.org\/tomcat-9.0-doc\/index.html\n   Main PID: 22759 (java)\n      Tasks: 30 (limit: 2304)\n     Memory: 74.5M\n        CPU: 3.615s\n     CGroup: \/system.slice\/tomcat9.service\n             \u2514\u250022759 \/usr\/lib\/jvm\/java-1.17.0-openjdk-amd64\/bin\/java -Djava.util.logging.config.file=\/opt\/tomcat9\/conf\/logging.properties -Djava.util.logging.manager>\n\nAug 29 14:34:13 debian systemd&#91;1]: Starting tomcat9.service - Apache Tomcat 9 Web Application Server...\nAug 29 14:34:13 debian startup.sh&#91;22752]: Tomcat started.\nAug 29 14:34:13 debian systemd&#91;1]: Started tomcat9.service - Apache Tomcat 9 Web Application Server.\nWell, that is all on how to install Apache Tomcat 9 on Debian 12.\n<\/code><\/pre>\n\n\n\n<p>\u539f\u6587\u5730\u5740\uff1ahttps:\/\/kifarunix.com\/how-to-install-tomcat-9-on-debian-12\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5JDK\uff08\u53ef\u5b89\u88c5oracle JDK\uff09 \u6dfb\u52a0\u7528\u6237\u5e76\u521b\u5efa\u76ee\u5f55 \u4e0b\u8f7dtomcat\u5305\uff0c\u89e3\u538b\u7f29\u5e76\u8bbe\u7f6e\u6743\u9650 \u8bbe\u7f6e\u73af\u5883\u53d8&hellip; <a class=\"more-link\" href=\"https:\/\/www.iunfair.com\/wordpress\/2024\/06\/23\/%e5%9c%a8debian%e4%b8%8a%e5%ae%89%e8%a3%85tomcat-9\/\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u5728Debian 12 \u4e0a\u5b89\u88c5Tomcat 9<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-linux","entry"],"_links":{"self":[{"href":"https:\/\/www.iunfair.com\/wordpress\/wp-json\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.iunfair.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iunfair.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iunfair.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iunfair.com\/wordpress\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":4,"href":"https:\/\/www.iunfair.com\/wordpress\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/www.iunfair.com\/wordpress\/wp-json\/wp\/v2\/posts\/62\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/www.iunfair.com\/wordpress\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iunfair.com\/wordpress\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iunfair.com\/wordpress\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}