码头 7.4.2 + Quercus 4.0.18:如何从 webapp 目录外部读取 PHP 文件
使用此代码...
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class OneWebApp
{
public static void main(String[] args) throws Exception
{
String jetty_home = "C:/Software/jetty";
Server server = new Server(8080);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setWar(jetty_home+"/quercus-4.0.18.war");
server.setHandler(webapp);
server.start();
server.join();
}
}
...我可以从 webapp 目录读取 PHP 文件: C:\Documents and Settings\mydir\Local Settings\Temp\jetty-0.0.0.0-8080-quercus-4.0.18.war-_ -any-\webapp
如何配置 Jetty 在另一个目录中查找 PHP 文件?例如:C:\Projects\phpfiles
对于 Apache,我只需在配置中执行如下操作:
Alias /phpfiles "C:\Projects\phpfiles"
<Directory C:\Projects\phpfiles>
Order allow,deny
Allow from all
AllowOverride All
</Directory>
Using this code...
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class OneWebApp
{
public static void main(String[] args) throws Exception
{
String jetty_home = "C:/Software/jetty";
Server server = new Server(8080);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setWar(jetty_home+"/quercus-4.0.18.war");
server.setHandler(webapp);
server.start();
server.join();
}
}
... I can read PHP files from the webapp directory: C:\Documents and Settings\mydir\Local Settings\Temp\jetty-0.0.0.0-8080-quercus-4.0.18.war-_-any-\webapp
How can I configure Jetty to look for the PHP files in another directory? For example: C:\Projects\phpfiles
With Apache, I would simply do something like this in the config:
Alias /phpfiles "C:\Projects\phpfiles"
<Directory C:\Projects\phpfiles>
Order allow,deny
Allow from all
AllowOverride All
</Directory>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 war 路径更改为:
phpfiles 目录需要包含 Web 应用程序的结构(至少包含 WEB-INF/web.xml)。您需要将 quercus 依赖项包含在 WEB-INF/lib 中,或者只是将依赖项添加到您的类路径中(因为它是嵌入的)。依赖项和 web.xml 可以在 quercus-*.war 中找到。
如果你需要有多个php文件的源目录,我认为这是不支持的。您需要扩展 QuercusServletImpl 并实现/覆盖 getPath(HttpServletRequest req)。
You can change the war path to:
The directory phpfiles will need to contains the structure of a web application (minimally include WEB-INF/web.xml). You'll need to either include the quercus dependencies in WEB-INF/lib or simply add the dependencies in your classpath (since it's embedded). The dependencies and web.xml can be found in quercus-*.war.
If you need to have multiple source directories of php files, which I don't think is support. You would need to extends QuercusServletImpl and implement/override getPath(HttpServletRequest req).