Apache インストール ノート ========================== Apache_ は多くのプラットフォームで利用可能な、人気のあるWebサーバーです。 PhalconのためのApacheの設定 ------------------------------ 次の設定は、 PhalconをApacheで使う際の設定例です。ここでは主に、使いやすいURLと :doc:`router component `. を 使用できるようにmod_rewriteモジュールを設定する方法についてフォーカスしています。 一般的にアプリケーションは下記のような構造になります。 .. code-block:: php test/ app/ controllers/ models/ views/ public/ css/ img/ js/ index.php メインドキュメントルート下のディレクトリ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ これは最も一般的なケースで、アプリケーションはドキュメントルート下の任意のディレクトリにインストールされています。 このケースでは、2つの .htaccess ファイルを使います。1つめはアプリケーションコードを隠すためにすべてのリクエストを アプリケーションのドキュメントルート (public/) へリダイレクトします。 .. code-block:: apacheconf # test/.htaccess RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule ((?s).*) public/$1 [L] 2つめの .htaccess ファイルは、public/ ディレクトリに配置し、すべてのURIを public/index.php ファイルにリライトします。 .. code-block:: apacheconf # test/public/.htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L] もし .htaccessファイルを使用したくない場合は、これらの設定を Apacheのメインの設定ファイルに移動させることができます。 .. code-block:: apacheconf RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule ((?s).*) public/$1 [L] RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L] バーチャルホスト ^^^^^^^^^^^^^^^^ そしてこの2つめの設定では、Virtual Host 内に Phalconアプリケーションをインストールすることができます。 .. code-block:: apacheconf ServerAdmin admin@example.host DocumentRoot "/var/vhosts/test/public" DirectoryIndex index.php ServerName example.host ServerAlias www.example.host Options All AllowOverride All Allow from all .. _Apache: http://httpd.apache.org/ >= Apache 2.4: .. code-block:: apacheconf ServerAdmin admin@example.host DocumentRoot "/var/vhosts/test/public" DirectoryIndex index.php ServerName example.host ServerAlias www.example.host Options All AllowOverride All Require all granted .. _Apache: http://httpd.apache.org/