安裝
apt install tomcat9
關閉熱部署
編輯 /etc/tomcat9/server.xml 尋找
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
更改為
<Host name="localhost" appBase="webapps"
unpackWARs="false" autoDeploy="false">
sed -i 's/ unpackWARs="true"/ unpackWARs="false"/' /etc/tomcat9/server.xml
sed -i 's/ autoDeploy="true"/ autoDeploy="false"/' /etc/tomcat9/server.xml
隱藏 Tomcat 版本
編輯 /etc/tomcat9/server.xml
尋找 <Host name= 區間 加入
<!-- Hidden Tomcat Version -->
<Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" showServerInfo="false" />
sed -i '/<\/Host>/i\ \
<!-- Hidden Tomcat Version --> \
<Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" howServerInfo="false" />' \
/etc/tomcat9/server.xml
編輯 /etc/tomcat9/server.xml <Host name= 區間 加入
<!-- Remote IP Valve -->
<Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Real-IP" />
修改 <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %{X-Real-IP}i %l %u %t "%r" %s %b" />
sed -i '/<\/Host>/i\ \
預設 DOCROOT
/var/lib/tomcat9/webapps/ROOT
測試檔
echo 'Hello! <%= config.getInitParameter("defaultGuestName") %>'>test.jsp
日誌檔
/var/log/tomcat9/
沒有留言:
張貼留言