Movatterモバイル変換


[0]ホーム

URL:


Open MagicVox.netOpen MagicVox.net

ヘッダメニュー


Debian squeeze に nginx をインストールしてみた

Permalink URL
http://www.magicvox.net/archive/2012/01042058/
Posted by
ぴろり
Postedat
2012/01/04 20:58
Trackbacks
関連記事(0)
Post Comment
コメントできます
Category
ソフトウェア カテゴリ

 「apt-get install nginx で一発です」ではあまりにあまりなので、ソースを取得してビルドしてインストールしてみました。本当に静的ファイルを返すだけの目的だったので、ビルド オプションを付けてみたりとか。それでも至極簡単でビックリだったんですけどね。

このエントリーをはてなブックマークに追加 

 インストールした環境は、Intel Pentium で動作する本当に最小構成の Debian GNU/Linux 6.0 (squeeze) で、まぁ、目新しい環境だとかそういう点は皆無です。中の人は、Apache は今までかなり弄ったものの、nginx を弄るのは全くの初めてという人。nginx は、一応、Debian のビルド パッケージとして提供されていますので、aptaptitude で一発インストールできます。

# apt-cache show nginxPackage: nginxPriority: optionalSection: webInstalled-Size: 608Maintainer: Jose Parrella <bureado@debian.org>Architecture: amd64Version: 0.6.32-3+lenny3Provides: httpdDepends: libc6 (>= 2.7-1), libpcre3 (>= 7.4), libssl0.9.8 (>= 0.9.8f-5), zlib1g (>= 1:1.1.4)Filename: pool/main/n/nginx/nginx_0.6.32-3+lenny3_amd64.debSize: 268654MD5sum: 8ba00b9fa72c1b6d92ba1f4af5b95e2dSHA1: 24e1652ca0cb77532c25042c66909551aeeb4306SHA256: 8fafcaf3ddcbed09c951c2c1a3fc1a8c25b90d96827bcb556976e1fcb82efddb...

 ただし、バージョンが 0.6.32 と古いこと*1と、ファイル サーバの共有ディレクトリに置かれた静的ファイルを、HTTP 経由で閲覧したいだけの目的で、CGI や PHP を動作させる必要やプロキシなどの機能は全く必要なかったため、勉強も兼ねてソースコードからビルドすることにしました。

$ # ソースコードを取得$ cd ~/src$ wget http://nginx.org/download/nginx-1.0.11.tar.gz...$ # アーカイブを展開$ tar zxfv nginx-1.0.11.tar.gz...$ # configure$ cd nginx-1.0.11$ ./configure..../configure: error: C compiler gcc is not found

 最小構成でインストールされた Debian で、ビルドに必要なコンパイラやライブラリが全く入っていなかったので怒られる(´・ω・`)

$ # ビルドに必要なツールのインストール$ apt-get install gcc make...$ # 気を取り直して configure$ ./configure     --user=www-data     --group=www-data     --without-pcre     --without-http_gzip_module     --without-http_ssi_module     --without-http_userid_module     --without-http_access_module     --without-http_auth_basic_module     --without-http_geo_module     --without-http_map_module     --without-http_split_clients_module     --without-http_referer_module     --without-http_rewrite_module     --without-http_proxy_module     --without-http_fastcgi_module     --without-http_uwsgi_module     --without-http_scgi_module     --without-http_memcached_module     --without-http_limit_zone_module     --without-http_limit_req_module     --without-http_empty_gif_module     --without-http_browser_module     --without-http_upstream_ip_hash_module     --without-mail_pop3_module     --without-mail_imap_module     --without-mail_smtp_module...Configuration summary  + PCRE library is disabled  + OpenSSL library is not used  + using builtin md5 code  + sha1 library is not used  + zlib library is not used  nginx path prefix: "/usr/local/nginx"  nginx binary file: "/usr/local/nginx/sbin/nginx"  nginx configuration prefix: "/usr/local/nginx/conf"  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"  nginx pid file: "/usr/local/nginx/logs/nginx.pid"  nginx error log file: "/usr/local/nginx/logs/error.log"  nginx http access log file: "/usr/local/nginx/logs/access.log"  nginx http client request body temporary files: "client_body_temp"...$ # ビルド$ make...$ # インストール$ make install...

 ...と、ここまで驚くほどに超スムーズ。ファイル サーバとして共有しているディレクトリを、ルートからごっそり公開し、目的のファイルへのナビゲーションは autoindex に丸投げ。

$ # サーバ設定ファイルを編集$ vi /usr/local/nginx/conf/nginx.conf...        charset utf-8;...        location / {            alias   /mnt/;            autoindex on;            autoindex_exact_size off;            autoindex_localtime off;        }...$ # nginx を起動$ /usr/local/nginx/sbin/nginx...

 ...と、最後まで大きな問題もなく完了。ちょっとハマった点は以下。

起動すると autoindex の指定でエラー
 configure でビルド オプションを指定する際に、「どうせ何の機能も使わないぜー」とヘルプに載っていたオプションをコピペで全部指定したところ、--without-http_autoindex_module って指定を見逃して autoindex が使えなくなっていた(馬鹿)
autoindex で日本語ファイル名が文字化けする
 上と同じ勢いで、--without-http_charset_module と指定していて、文字セットを指定できていなかった。

 ちゃんと動作確認できたので、起動スクリプトなどを用意する。

$ # 起動スクリプトを取得$ wget -O /etc/init.d/nginx http://www.debianadmin.com/images/nginx...$ # 起動スクリプトをセットアップ$ chmod 755 755 /etc/init.d/nginx$ update-rc.d -f nginx defaults
このエントリーをはてなブックマークに追加 

  1. *1 この記事の執筆時点での最新 stable バージョンは 1.0.11

この記事のアーカイブ

全ての記事 »
2012年
全てのカテゴリ »
電算室 »ソフトウェア
全てのタグ »
,,
キーワード検索 »
,,

関連記事/トラックバック

関連記事/トラックバックはまだありません

この記事にトラックバックを送るには?

トラックバックURL:

トラックバックスパム対策のため,上記の URL 末尾にあるXXXXXXCAPTCHA コード?に置き換えてからご利用ください。お手数ですがご協力のほど宜しくお願いいたします。

コメントを投稿する

 
 (必須, 匿名可, 公開,トリップが使えます)
 (必須, 匿名可, 非公開,Gravatar に対応しています)
 (必須)
スパム コメント防止のため「投稿確認」欄にランダムな数字CAPTCHAについて を入力してから送信してください。お手数ですがご協力のほど宜しくお願いいたします。
 

Reference

プロフィール

ツール

  • このサイトのフィード
    RSS 1.0
  • この記事のコミュニケーションフィード
    RSS 1.0

entry:1145管理

関連する商品



ナビゲーション

最近の人気記事 これは何?

  1. ぬるぬるローションの製作(703 hits)
  2. Windows PC で Wii リモコンを使う(220 hits)
  3. ぬるぬるローションの製作 その2(190 hits)
  4. Mozilla Thunderbird おすすめアドオン 17 個+α(185 hits)
  5. PIC ことはじめ ~ 7 セグメント LED を使う(183 hits)

いいね!ランキング これは何?

  1. Open Graph Protocol 付きで「いいね!」ボタンを設置する(22 pts)
  2. 【試験公開】「いいね!」ランキングを作る(10 pts)
  3. Mac OS X のフォントを Chicago っぽくする(8 pts)
  4. MovableType で外部の RSS などを取得・整形して表示する(7 pts)
  5. Mozilla Thunderbird おすすめアドオン 17 個+α(5 pts)

最近のコメント/関連記事

記事検索

全ての記事 ...


フッタメニュー

Copyright © 2004-2021Open MagicVox.net. Some rights reserved underCreative Commons License.
Written in Japanese (UTF-8). Japanese fonts are required to view this page.
Generated withMovable Type UC 5.13.367
Total Visits:Total Visits / Today:Today / Yesterday:Yesterday

[8]ページ先頭

©2009-2025 Movatter.jp