大网数据广告活动
服务器运维问答

Configuring Jetty for FastCGI has worked, but how to add virtual hosts?

· 52CE 我爱测

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 :…

问题原文

原帖链接 · 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-06-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。