1. quercus をダウンロードします:
http://quercus.caucho.com/
もちろん、原則的には新しいバージョンの方が PHP のサポートが優れているため、最新バージョンが最適ですが、私がテストしたところ最新の 4.0.25 には問題があったため、バージョン 4.0.18 に切り替えました。
ダウンロードする WAR 形式のファイルを選択し、Winrar を使用して解凍し、WEB-INFlib jar を warWEB にコピーします。 -GAE プロジェクトの下の INFlib ディレクトリ
2 .Quercus を設定する:
appengine-web.xml で php ファイルのサポートを設定する:
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><</span><span class="tag-name">static-files</span><span class="tag">></span><span> </span></span></li> <li><span> <span class="tag"><</span><span class="tag-name">exclude</span><span> </span><span class="attribute">path</span><span>=</span><span class="attribute-value">"/**.php"</span><span> </span><span class="tag">/></span><span> </span></span></li> <li class="alt"><span><span class="tag"></</span><span class="tag-name">static-files</span><span class="tag">></span><span> </span></span></li> <li><span><span class="tag"><</span><span class="tag-name">resource-files</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span> <span class="tag"><</span><span class="tag-name">include</span><span> </span><span class="attribute">path</span><span>=</span><span class="attribute-value">"/**.php"</span><span> </span><span class="tag">/></span><span> </span></span></li> <li><span><span class="tag"></</span><span class="tag-name">resource-files</span><span class="tag">></span><span> </span></span></li> </ol>
web.xml にサーブレットを追加する:
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><</span><span class="tag-name">servlet</span><span class="tag">></span><span> </span></span></li> <li><span> <span class="tag"><</span><span class="tag-name">servlet-name</span><span class="tag">></span><span>Quercus Servlet</span><span class="tag"></</span><span class="tag-name">servlet-name</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span> <span class="tag"><</span><span class="tag-name">servlet-class</span><span class="tag">></span><span>com.caucho.quercus.servlet.GoogleQuercusServlet</span><span class="tag"></</span><span class="tag-name">servlet-class</span><span class="tag">></span><span> </span></span></li> <li><span><span class="tag"></</span><span class="tag-name">servlet</span><span class="tag">></span><span> </span></span></li> </ol>
php ファイルにマッピングを追加します:
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><</span><span class="tag-name">servlet-mapping</span><span class="tag">></span><span> </span></span></li> <li><span> <span class="tag"><</span><span class="tag-name">servlet-name</span><span class="tag">></span><span>Quercus Servlet</span><span class="tag"></</span><span class="tag-name">servlet-name</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span> <span class="tag"><</span><span class="tag-name">url-pattern</span><span class="tag">></span><span>*.php</span><span class="tag"></</span><span class="tag-name">url-pattern</span><span class="tag">></span><span> </span></span></li> <li><span><span class="tag"></</span><span class="tag-name">servlet-mapping</span><span class="tag">></span><span> </span></span></li> </ol>
3. URL 書き換えの実装 (UrlRewriteFilter によって実装):
UrlRewriteFilter をダウンロードし、プロジェクトの warWEB-INFlib ディレクトリに urlrewritefilter-*.jar をコピーします
web.xml に URL フィルタリングを追加します
<ol class="dp-xml"> <li class="alt"><span><span> </span><span class="tag"><</span><span class="tag-name">filter</span><span class="tag">></span><span> </span></span></li> <li><span> <span class="tag"><</span><span class="tag-name">filter-name</span><span class="tag">></span><span>UrlRewriteFilter</span><span class="tag"></</span><span class="tag-name">filter-name</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span> <span class="tag"><</span><span class="tag-name">filter-class</span><span class="tag">></span><span>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</span><span class="tag"></</span><span class="tag-name">filter-class</span><span class="tag">></span><span> </span></span></li> <li><span><span class="tag"></</span><span class="tag-name">filter</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span><span class="tag"><</span><span class="tag-name">filter-mapping</span><span class="tag">></span><span> </span></span></li> <li><span> <span class="tag"><</span><span class="tag-name">filter-name</span><span class="tag">></span><span>UrlRewriteFilter</span><span class="tag"></</span><span class="tag-name">filter-name</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span> <span class="tag"><</span><span class="tag-name">url-pattern</span><span class="tag">></span><span>/*</span><span class="tag"></</span><span class="tag-name">url-pattern</span><span class="tag">></span><span> </span></span></li> <li><span> <span class="tag"><</span><span class="tag-name">dispatcher</span><span class="tag">></span><span>REQUEST</span><span class="tag"></</span><span class="tag-name">dispatcher</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span> <span class="tag"><</span><span class="tag-name">dispatcher</span><span class="tag">></span><span>FORWARD</span><span class="tag"></</span><span class="tag-name">dispatcher</span><span class="tag">></span><span> </span></span></li> <li><span><span class="tag"></</span><span class="tag-name">filter-mapping</span><span class="tag">></span><span> </span></span></li> </ol>
戦争ウェブ-INF ディレクトリ 新しい URL 書き換え構成ファイルを作成します: urlrewrite.xml
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><?</span><span class="tag-name">xml</span><span> </span><span class="attribute">version</span><span>=</span><span class="attribute-value">"1.0"</span><span> </span><span class="attribute">encoding</span><span>=</span><span class="attribute-value">"utf-8"</span><span class="tag">?></span><span> </span></span></li> <li> <span><!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN" </span></li><li class="alt"><span> "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd"<span class="tag">></span><span> </span> </li> <li><span> </span></li> <li class="alt"><span><span class="tag"><</span><span class="tag-name">urlrewrite</span><span class="tag">></span><span> </span></span></li> <li><span> <span class="tag"><</span><span class="tag-name">rule</span><span> </span><span class="attribute">enabled</span><span>=</span><span class="attribute-value">"true"</span><span> </span><span class="attribute">match-type</span><span>=</span><span class="attribute-value">"regex"</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span> <span class="tag"><</span><span class="tag-name">note</span><span class="tag">></span><span>UrlRewrite</span><span class="tag"></</span><span class="tag-name">note</span><span class="tag">></span><span> </span></span></li> <li><span> <span class="tag"><</span><span class="tag-name">condition</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"request-filename"</span><span> </span><span class="attribute">operator</span><span>=</span><span class="attribute-value">"notfile"</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"notfile"</span><span> </span><span class="attribute">next</span><span>=</span><span class="attribute-value">"and"</span><span class="tag">/></span><span> </span></span></li> <li class="alt"><span> <span class="tag"><</span><span class="tag-name">condition</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"request-filename"</span><span> </span><span class="attribute">operator</span><span>=</span><span class="attribute-value">"notdir"</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"notdir"</span><span> </span><span class="attribute">next</span><span>=</span><span class="attribute-value">"and"</span><span class="tag">/></span><span> </span></span></li> <li><span> <span class="tag"><</span><span class="tag-name">from</span><span class="tag">></span><span>/(.*)</span><span class="tag"></</span><span class="tag-name">from</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span> <span class="tag"><</span><span class="tag-name">to</span><span> </span><span class="attribute">last</span><span>=</span><span class="attribute-value">"true"</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"forward"</span><span class="tag">></span><span>/index.php</span><span class="tag"></</span><span class="tag-name">to</span><span class="tag">></span><span> </span></span></li> <li><span> <span class="tag"></</span><span class="tag-name">rule</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span><span class="tag"></</span><span class="tag-name">urlrewrite</span><span class="tag">></span><span> </span></span></li> <li><span> </span></li> </ol>
このルールは、.htaccess:
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
のルールと同等です。 RewriteRule ^ (.*)$index.php/$1
注: このルールにより、GAE ローカル管理 http://localhost:8888/_ah/admin/ が無効になる可能性があり、時間の制約により修正されません。 .
4. テスト:
プロジェクトの war ディレクトリに新しいindex.php ファイルを作成します:
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><?</span><span class="tag-name">php</span><span> </span></span></li><li><span>echo '<span class="tag"><</span><span class="tag-name">pre</span><span class="tag">></span><span>'; </span></span></li> <li class="alt"><span>print_r($_SERVER); </span></li> <li><span><span class="tag">?></span><span> </span></span></li> </ol>
index.php をウェルカム ファイルとして設定したので、http://localhost を直接開きます。 8888/
効果は写真の通りです 表示:
いくつかの参考資料を添付します: caucho.com/2009/04/28/quercus- on-the-google-app-engine/http://blog.caucho.com/2009/05/31/quercus-on-google-app-engine/ http://tuckey.org/urlrewrite/ #documentationPHP の皆さん、まだ何を迷っているのですか?急いでください~