Apache2的配置文件, 用PHP扩展名伪装Java网站
增加PHP解析支持
LoadModule php5_module modules/libphp5.so # Use of the "ZTS" build with worker is experimental, and no shared # modules are supported. LoadModule php5_module modules/libphp5-zts.so AddHandler php5-script .php AddType text/html .php # Add index.php to the list of files that will be served as directory # indexes. DirectoryIndex index.php
Add the support of PHP handling
LoadModule php5_module modules/libphp5.so # Use of the "ZTS" build with worker is experimental, and no shared # modules are supported. LoadModule php5_module modules/libphp5-zts.so AddHandler php5-script .php AddType text/html .php # Add index.php to the list of files that will be served as directory # indexes. DirectoryIndex index.php
如果项目中, apache同时配置了与Tomcat的连接, 而且打算用PHP扩展名给java程序做伪装, 就需要注释掉这两行 AddHandler php5-script .php AddType text/html .php 而将这两行添加到需要PHP解析的虚拟目录配置文件下. 例如, 一个使用PHP扩展名伪装的java站点虚拟目录配置为
ServerName mailman.someorg.com # Send servlet for context /servlets-examples to worker named worker1 JkMount /mailman/*.php worker1 JkMount /mailman/* worker1 DocumentRoot /var/www/html/mailman/ DirectoryIndex index.shtml index.html index.htm index.php index.jsp Options +Includes AddType text/html .shtml AddOutputFilter INCLUDES .shtml AddHandler server-parsed .shtml <Directory "/var/www/html/mailman/"> Options FollowSymLinks IncludesNOEXEC AllowOverride None Order allow,deny Allow from all ErrorLog logs/mailman.someorg.com-err_log CustomLog logs/mailman.someorg.com-access_log combined
而一个需要PHP解析支持的虚拟目录配置为
ServerName misc.someorg.com DocumentRoot /var/www/html/misc/ DirectoryIndex index.shtml index.html index.htm default.htm index.php index.jsp Options +Includes AddType text/html .shtml AddOutputFilter INCLUDES .shtml AddHandler server-parsed .shtml AddHandler php5-script .php AddType text/html .php <Directory "/var/www/html/misc/"> Options FollowSymLinks IncludesNOEXEC AllowOverride None Order allow,deny Allow from all ErrorLog logs/misc.someorg.com-err_log CustomLog logs/misc.someorg.com-access_log combined
这些配置都同时打开了对server side include SSI的支持
If you are going to use the .php extension for Java web application, comment out the two lines below
AddHandler php5-script .php AddType text/html .php
And add these two lines to the VirutalHost configuration. For example, the virtual host configuration of a Java website is
ServerName mailman.someorg.com # Send servlet for context /servlets-examples to worker named worker1 JkMount /mailman/*.php worker1 JkMount /mailman/* worker1 DocumentRoot /var/www/html/mailman/ DirectoryIndex index.shtml index.html index.htm index.php index.jsp Options +Includes AddType text/html .shtml AddOutputFilter INCLUDES .shtml AddHandler server-parsed .shtml <Directory "/var/www/html/mailman/"> Options FollowSymLinks IncludesNOEXEC AllowOverride None Order allow,deny Allow from all ErrorLog logs/mailman.someorg.com-err_log CustomLog logs/mailman.someorg.com-access_log combined
While the configuration of a virtual host that need to support PHP is
ServerName misc.someorg.com DocumentRoot /var/www/html/misc/ DirectoryIndex index.shtml index.html index.htm default.htm index.php index.jsp Options +Includes AddType text/html .shtml AddOutputFilter INCLUDES .shtml AddHandler server-parsed .shtml AddHandler php5-script .php AddType text/html .php <Directory "/var/www/html/misc/"> Options FollowSymLinks IncludesNOEXEC AllowOverride None Order allow,deny Allow from all ErrorLog logs/misc.someorg.com-err_log CustomLog logs/misc.someorg.com-access_log combined
The configurations both enabled the support for Server Side Include (SSI)