MovableType (MTOS) 4.2 ダイナミックパブリッシング
MovableType(MTOS ( MovableType Open Source))4.2にてダイナミックパブリッシングへの対応についての解説です。
MovableTypeでは通常、再構築してページを生成します。 エントリー数が多い場合や、テンプレートが複雑な場合にはすべてを再構築する場合大変時間が掛かることがあります。
再構築タイプのメリットとしてはhtmlページにて表示できるためページの表示が速く、サーバへの負荷も非常に低いためアクセス数の多いサイトなどでメリットがあります。
ですが多くの人にはそのメリットよりもデメリットの方が目立ってきました。 再構築問題の解決としてページを動的に表示する方法が標準で利用できるようになりました。
標準のダイナミックパブリッシングはPerlではなくphpにて動作します。
またmod_rewrite(URL書き換え機能)も利用するようになっています。
テンプレートの変更
スタティックからダイナミックに
MovableTypeログイン後メニューからテンプレートページに移動します。

右下のアクションにある「公開プロファイルを設定」をクリックします。

今回はダイナミックパブリッシング(すべてのテンプレートをダイナミックパブリッシングします)を選択します。
選択するとテンプレートが再構築されてテンプレートがスタティックからダイナミックに変更されます。

以上でMovableTypeテンプレートはダイナミックテンプレートに変更されました。
mtview.phpと.htaccess
以上の作業を行うと公開ディレクトリにmtview.phpと.htaccessおよびtemplates_cが生成されます。
mtview.phpは動的にページを表示するためのphpプログラムで、.htaccessファイルはブログURLをmtview.phpで動作するための設定が記述されています。
シフトウェブでは一部設定は既にサーバ上に記述され動作しているので、その部分をコメントアウトします。
.htaccess
以下はデフォルトの.htaccessです。
## %%%%%%% Movable Type generated this part; don't remove this line! %%%%%%%
# Disable fancy indexes, so mtview.php gets a chance...
Options -Indexes +SymLinksIfOwnerMatch
<IfModule mod_rewrite.c>
# The mod_rewrite solution is the preferred way to invoke
# dynamic pages, because of its flexibility.
# Add mtview.php to the list of DirectoryIndex options, listing it last,
# so it is invoked only if the common choices aren't present...
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.htm default.htm default.html default.asp /blog/mtview.php
</IfModule>
RewriteEngine on
# don't serve mtview.php if the request is for a real directory
# (allows the DirectoryIndex lookup to function)
RewriteCond %{REQUEST_FILENAME} !-d
# don't serve mtview.php if the request is for a real file
# (allows the actual file to be served)
RewriteCond %{REQUEST_FILENAME} !-f
# anything else is handed to mtview.php for resolution
# passthrough query parameters
RewriteRule ^(.*)(\?.*)?$ /blog/mtview.php$2 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
# if mod_rewrite is unavailable, we forward any missing page
# or unresolved directory index requests to mtview
# if mtview.php can resolve the request, it returns a 200
# result code which prevents any 4xx error code from going
# to the server's access logs. However, an error will be
# reported in the error log file. If this is your only choice,
# and you want to suppress these messages, adding a "LogLevel crit"
# directive within your VirtualHost or root configuration for
# Apache will turn them off.
ErrorDocument 404 /blog/mtview.php
ErrorDocument 403 /blog/mtview.php
</IfModule>
## ******* Movable Type generated this part; don't remove this line! *******
修正箇所をコメントアウトします
Options -Indexes +SymLinksIfOwnerMatch
を
#Options -Indexes +SymLinksIfOwnerMatch
とします。
上記を修正するにはFTPクライアントソフトで.htaccessをダウンロードして、上記を書き換えアップロードします。
FTPソフトの設定次第ではドットファイル(.htaccess)が見えない場合が有りますので、見える状態にしてダウンロード、修正、アップロードしましょう。
以上でダイナミックパブリッシングへの移行は完了です。 以上で再構築なしでページが表示されるようになります。
お疲れ様でした!


RSS Feed