我已经给出了包含.jsp文件的PHP项目的一些源代码。 我可以像在我的Mac上设置的XAMPP那样运行它,但是我正努力在家中的Ubuntu安装上实现相同的function。
我需要的是能够将.jsp文件放在我的Apache服务器根目录(/ var / www / html /)中,让Apache使用Tomcat进行任何必要的连接来parsing.jsp文件,并让Apache处理所有其他事情。
我不想把我的.jsp文件或其他任何东西放在Tomcat服务器根目录下,我只想让Tomcatparsing我的Apache服务器根目录中的.jsp文件。
我已经阅读了几篇关于Stack Exchange的文章和问题,并已经实现了以下function:Apache提供了localhost/something/something.jsp (位于/var/www/html/something/something.jsp代码被送到客户端unparsed,而导航到localhost/something/something.php (位于something.jsp旁边)显示默认的“It works!”。 Tomcat的登陆页面。 这不是我想要的。
这是我设置了代理的000-default.conf文件:
<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so ServerAdmin webmaster@localhost DocumentRoot /var/www/html ProxyRequests off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass *.jsp ajp://127.0.0.1:8009/ ProxyPassReverse *.jsp ajp://127.0.0.1:8009/ <Directory "/var/www/html"> AllowOverride All </Directory> # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, eg #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
我怎样才能达到预期的效果?
ProxyPass不能像那样使用。 这更像是一个Location ,迫使一个特定的path(和它下面的所有东西)必须被定向到远程服务器。 一个扩展应该与ProxyPassMatch匹配:
ProxyPassMatch“^ /(。* \。jsp)$”“ajp://127.0.0.1:8009 / $ 1”
另外,您不需要proxy_http_module ,而是使用proxy_ajp_module
编辑 ,你需要一个Tomcat监听端口8009与其根目录(这可能是你的Apache根目录相同),以“parsing”的JSP,有没有办法让一个Apache使用应用程序服务器引擎上它自己既不是一个tomcat服务的页面不在它下面。