问题原文
原帖链接 · Alexander Farber · CC BY-SA 3.0
On CentOS 7 Linux I have successfully followed the guide Configuring Jetty for FastCGI.
However the $JETTY_BASE/webapps/jetty-wordpress.xml file in the guide serves a single Wordpress installation located in /var/www/wordpress:
<New id="root" class="java.lang.String">
<Arg>/var/www/wordpress</Arg>
</New>
<Set name="contextPath">/</Set>
<Set name="resourceBase"><Ref refid="root" /></Set>
<Set name="welcomeFiles">
<Array type="string"><Item>index.php</Item></Array>
</Set>
while I have several virtual hosts, each with Wordpress installed in:
- /var/www/wordpress1 (www.site1.com)
- /var/www/wordpress2 (www.site2.com)
- /var/www/wordpress3 (www.site3.com)
Until now I was using Apache with the following httpd.conf (using localhost as the IP address, because Apache/Jetty are behind HAProxy):
<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/wordpress1
ServerName site1.com
ServerAlias *.site1.com
</VirtualHost>
<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/wordpress2
ServerName site2.com
ServerAlias *.site2.com
</VirtualHost>
<VirtualHost 127.0.0.1:8080>
DocumentRoot /var/www/wordpress1
ServerName site3.com
ServerAlias *.site3.com
</VirtualHost>
How to translate the above Apache-config to Jetty IoC XML format?
已采纳解答
原帖链接 · Alexander Farber · CC BY-SA 3.0
I have solved the problem by reading the Configuring Virtual Hosts document and creating 3 XML-files:
- $JETTY_BASE/webapps/site1.xml
- $JETTY_BASE/webapps/site2.xml
- $JETTY_BASE/webapps/site3.xml
With the following content at the top of each file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
<New id="root" class="java.lang.String">
<Arg>/var/www/html/site1.com</Arg>
</New>
<Set name="contextPath">/</Set>
<Set name="virtualHosts">
<Array type="java.lang.String">
<Item>site1.com</Item>
<Item>www.site1.com</Item>
</Array>
</Set>
<Set name="resourceBase"><Ref refid="root" /></Set>
<Set name="welcomeFiles">
<Array type="string">
<Item>index.html</Item>
<Item>index.php</Item>
</Array>
</Set>
And the rest of the file is as in the Configuring Jetty for FastCGI document.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
