さくらのVPSにGoogleのmod_pagespeed入れてみた

原理的に、2倍も速くなったら元が酷いんじゃないか疑惑を感じつつ

あなたのサイトも最高2倍速に?!Google純正のサイト高速化モジュール『mod_pagespeed』だと・・・ - IDEA*IDEA ~ 百式管理人のライフハックブログ

速くなるのはいいことなのでレッツトライ。

さくらのVPS 標準 CentOS5.5 x86-64 にmod_pagespeedをインストールしてみたところあっさり行かなかったので、メモ貼りエントリーします。ここでは、mod_pagespeedの概要は、すっ飛ばしてインストールを進める次第。

サクっとインストールするつもりが公開鍵でつまづいた

% wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_x86_64.rpm
% sudo yum localinstall mod-pagespeed-beta_current_x86_64.rpm

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID xxxxxxxxxxx
Public key for mod-pagespeed-beta_current_x86_64.rpm is not installed

あらま失敗。公開鍵が無いと申されましても....なんかのキー(GPG?)が無いっぽい、って話だと思うのですが。

# Install the repository signing key (see also:
# http://www.google.com/linuxrepositories/aboutkey.html)
install_rpm_key() {
  # Check to see if key already exists.
  rpm -q gpg-pubkey-7fac5991-4615767f > /dev/null 2>&1
  if [ "$?" -eq "0" ]; then
    # Key already exists
    return 0
  fi

よく分からなかったので、mod-pagespeed-beta_current_x86_64.rpmを直接開いて見てみた所、21〜29行目付近のコメントに、キーについての参照先URLがあったので参照。

rpmに自体に、キーの自動取り込みっぽい処理が内包されているような気もするんですが、深追いせずに手動でインストールすることにします。

参考

改めて公開鍵を取りに行く

% rpm --import https://dl-ssl.google.com/linux/linux_signing_key.puberror: https://dl-ssl.google.com/linux/linux_signing_key.pub: import read failed(-1)

ありゃ、横着しても直接取りに行けなかったので

% wget https://dl-ssl.google.com/linux/linux_signing_key.pub
% sudo rpm --import linux_signing_key.pub

これで鍵がインポートできたので、大丈夫なはず。

改めてトライ。

% sudo yum localinstall mod-pagespeed-beta_current_x86_64.rpm
(中略)
Running Transaction
  Installing     : mod-pagespeed-beta                                                     1/1
job 1 at 2010-11-04 10:23

Installed:
  mod-pagespeed-beta.x86_64 0:0.9.0.0-128                                                    

Complete!

無事にインストール完了〜。

すぐに使い始められる

次に、httpd.confをどう設定したものかと思いましたが、その必要はありませんでした。この時点でApacheを再起動すれば、すぐにpagespeedが読み込まれます。

@IT:httpd.confによるWebサーバの最適化(1/3)

httpd.confで Include conf.d/*.conf と書かれている限り、conf.dの中のconfファイルは自動で読み込まれるらしいです。httpd.confを書き換えなくても設定を拡張できていいですね。初めて知りました。LoadModuleはpagespeed.confにちゃんと書いてあります。

初期設定のまま走らせることもできますが、次回の続・mod_pagespeedの各Filterと設定についてで、mod_pagespeedの各Filterの効能についてまとめます。

蛇足:mod_pagespeed_statistics

ちなみに

<Location /mod_pagespeed_statistics>
    Order allow,deny
    Allow from localhost
    SetHandler mod_pagespeed_statistics
</Location>

で設定されている /mod_pagespeed_statistics にアクセスすると、

resource_fetches: 0
total_page_load_ms: 0
page_load_count: 0
cache_extensions: 88
not_cacheable: 0
css_file_count_reduction: 24
css_filter_files_minified: 11
css_filter_minified_bytes_saved: 1681
css_filter_parse_failures: 48
css_elements: 0
image_inline: 51
image_rewrite_saved_bytes: 183
image_rewrites: 28
javascript_blocks_minified: 0
javascript_bytes_saved: 0
javascript_minification_failures: 0
javascript_total_blocks: 0
url_trims: 0
url_trim_saved_bytes: 0
resource_404_count: 0
slurp_404_count: 0
serf_fetch_request_count: 20
serf_fetch_bytes_count: 594238
serf_fetch_time_duration_ms: 131
serf_fetch_cancel_count: 0

のような情報を取得できます。何をどんだけ最適化したかの指標みたいなもんですね。


Author

ahomuAyumu Sato

overflow, Inc.VPoE

東京資本で生きる名古屋の鳥類

Web 技術、組織開発、趣味など雑多なブログ。技術の話題は zenn にも分散して投稿しています。

Bio: aho.mu
X: @ahomu
Zenn: ahomu
GitHub: ahomu

Related

Latest

Archives

Tags

Search