从maven开始和结束Apache webserver

时间:2012-02-21 04:26:16

标签: .htaccess maven webserver

我有一个旧的网络项目,我目前正在进行复仇。这是为Apache httpd编写的,这意味着许多规则都包含在许多.htaccess文件中(重定向,重写),而页面使用服务器端包含。我试图在HTAccessHandler中使用jetty,但这并不关心重写/重定向。我想我现在需要使用httpd来正确处理,但有没有办法启动从maven嵌入的apache webserver?或者你知道一个可以处理所有.htaccess属性的java webserver实现吗?

干杯, 启

2 个答案:

答案 0 :(得分:2)

为了回答自己,我现在使用antrun插件启动Apache httpd二进制文件,并使用Apache正在创建的pid文件调用系统特定的kill命令。我正在为我的项目提供一个httpd.conf文件,我在其中过滤maven属性,包括目标端口,日志位置和pidfile名称和位置。系统特定值由os系列激活的maven配置文件设置。 apache httpd的主文件夹将在users settings.xml文件中设置。这看起来像:

        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>Starting Apache</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target name="Starting Apache">
                            <mkdir dir="${project.build.directory}/logs" />
                            <echo>Starting Apache httpd:</echo>
                            <exec executable="${apache.home}/${apache.executable}" spawn="true">
                                <arg value="-f" />
                                <arg value="${project.build.directory}/httpd.conf" />
                            </exec>
                        </target>
                    </configuration>
                </execution>
                <execution>
                    <id>Stopping Apache</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target name="Stopping Apache">
                            <echo>Stopping Apache httpd:</echo>
                            <loadfile property="PID" srcFile="${project.build.directory}/httpd.pid">
                                <filterchain>
                                    <striplinebreaks />
                                </filterchain>
                            </loadfile>
                            <exec executable="${kill.executable}" failonerror="true">
                                <arg value="${kill.argument1}" />
                                <arg value="${kill.argument2}" />
                                <arg value="${kill.argument3}" />
                                <arg value="${PID}" />
                            </exec>
                        </target>
                    </configuration>
                </execution>
            </executions>
        </plugin>

答案 1 :(得分:0)

我查看了各种新闻组,因为我们在社区中有相同的功能请求

我们将在接下来的日子里开始开发一个httpd插件。然而,我试图在谷歌找到一些东西,但似乎没有涵盖这个主题的插件。开发一个启动和停止apache的插件应该相当简单。从Maven java开始,我很清楚为什么几乎每个人都喜欢tomcat或者码头。

针对php-maven的2.0版本

插件类似于jetty和tomcat插件(相同的目标,类似的设置)。第一个版本将取决于单独的apache安装,并且只能设置虚拟主机或设置文档根目录。对于简单配置和开发机器,这将是正常的。

观看http://www.php-maven.org/rss.xmlhttps://groups.google.com/forum/?fromgroups#!forum/maven-for-php了解新闻。

但请在http://trac.php-maven.org/ticket/47(需要注册)或我们的Google论坛上提交您的意愿。