編輯 context.xml 檔案,增加 privileged="true 屬性
# vim /srv/apache-tomcat/conf/context.xml <Context privileged="true"> <!-- Default set of monitored resources --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <!-- Uncomment this to enable Comet connection tacking (provides events on session expiration as well as webapp lifecycle) --> <!-- <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" /> --> </Context>
編輯 web.xml 檔案,取消下面的註釋
# vim /srv/apache-tomcat/conf/web.xml <servlet> <servlet-name>ssi</servlet-name> <servlet-class> org.apache.catalina.ssi.SSIServlet </servlet-class> <init-param> <param-name>buffered</param-name> <param-value>1</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>expires</param-name> <param-value>666</param-value> </init-param> <init-param> <param-name>isVirtualWebappRelative</param-name> <param-value>false</param-value> </init-param> <load-on-startup>4</load-on-startup> </servlet>
配置需要SSI處理的檔案
# vim /srv/apache-tomcat/webapps/ROOT/WEB-INF/web.xml <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0" metadata-complete="true"> <display-name>Welcome to Tomcat</display-name> <description> Welcome to Tomcat </description> <servlet-mapping> <servlet-name>ssi</servlet-name> <url-pattern>*.shtml</url-pattern> <url-pattern>*.html</url-pattern> </servlet-mapping> </web-app>
重新啟動Tomcat
創建測試檔案
# vim webapps/ROOT/index.html <!--#echo var="DATE_LOCAL" -->
驗證測試結果
# curl http://224.25.22.70:8080/ Tuesday, 03-Nov-2015 09:32:30 HKT