10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

brew で nginx を http-image-filter-module を有効にしてインストールする方法

Posted at

基本的には簡単!リアルタイム画像変換をNginxだけで行う方法を参考にさせていただいた。

早速やってみる

上記のサイトを見ると、
./configure --with-http_image_filter_module

で指定すればいい。とある。
と思ったが homebrew で nginx をインストールしていたので homebrew の方を調べると

brew options nginx

--with-debug
	Compile with support for debug log
--with-gunzip
	Compile with support for gunzip module
--with-passenger
	Compile with support for Phusion Passenger module
--with-spdy
	Compile with support for SPDY module
--with-webdav
	Compile with support for WebDAV module
--devel
	install development version 1.5.9
--HEAD
	install HEAD version

ん?image-filterがない…。

ソースダウロードしてビルドすればいいんだろうけど、せっかく homebrew での管理にできてるのでできればそこは崩したくない。

ということで無理矢理(?)やってみた。

Formula を書き換える

/usr/local/Library/Formula/nginx.rb を以下のように書き換える。というか足す。

option 'with-spdy', 'Compile with support for SPDY module’
option 'with-gunzip', 'Compile with support for gunzip module’
option 'with-image-filter', 'Compile with support for image filter module’ ← この行を足す

args << "--with-http_spdy_module" if build.include? 'with-spdy'
args << "--with-http_gunzip_module" if build.include? 'with-gunzip'
args << "--with-http_image_filter_module" if build.include? 'with-image-filter’ ← これを足す

確認する

brew options nginx

--with-debug
	Compile with support for debug log
--with-gunzip
	Compile with support for gunzip module
--with-image-filter
	Compile with support for image filter module
--with-passenger
	Compile with support for Phusion Passenger module
--with-spdy
	Compile with support for SPDY module
--with-webdav
	Compile with support for WebDAV module
--devel
	install development version 1.5.9
--HEAD
	install HEAD version

おおー入ってる。

インストール実行

brew install nginx —-with-image-filter

==> Installing nginx
==> Downloading http://nginx.org/download/nginx-1.4.4.tar.gz
Already downloaded: /Library/Caches/Homebrew/nginx-1.4.4.tar.gz
==> ./configure --prefix=/usr/local/Cellar/nginx/1.4.4 --with-http_ssl_module --with-pcre --with-ipv6 --sbin-path=/usr/l
checking for GD library in /opt/local/ ... not found

./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.

ライブラリがなくて失敗

GDライブラリをインストールして再チャレンジ

brew install libgd

こちらは難なく終了。

brew install nginx —-with-image-filter

==> Downloading http://nginx.org/download/nginx-1.4.4.tar.gz
Already downloaded: /Library/Caches/Homebrew/nginx-1.4.4.tar.gz
==> ./configure --prefix=/usr/local/Cellar/nginx/1.4.4 --with-http_ssl_module --with-pcre --with-ipv6 --sbin-path=/usr/l
==> make
==> make install
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

To have launchd start nginx at login:
    ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
Then to load nginx now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Or, if you don't want/need launchctl, you can just run:
    nginx
==> Summary
?  /usr/local/Cellar/nginx/1.4.4: 7 files, 888K, built in 14 seconds

一応確認

$ nginx -V

nginx version: nginx/1.4.4
TLS SNI support enabled
configure arguments: --prefix=/usr/local/Cellar/nginx/1.4.4 --with-http_ssl_module --with-pcre --with-ipv6 --sbin-path=/usr/local/Cellar/nginx/1.4.4/bin/nginx --with-cc-opt='-I/usr/local/Cellar/pcre/8.34/include -I/usr/local/Cellar/openssl/1.0.1f/include' --with-ld-opt='-L/usr/local/Cellar/pcre/8.34/lib -L/usr/local/Cellar/openssl/1.0.1f/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/run/nginx.lock --http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp --http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --with-http_gzip_static_module --with-http_image_filter_module

一番最後にある。ミッションコンプリート。

あとがき

今回はFormulaを書き換えてしまったけど、gitのリポジトリになってるので、微妙にモニョモニョする。Formula変更のプルリクとして送ってもいいんだけど、かなり昔からあるモジュールなのに取り込まれてないってことは何らかの理由があるのかなと思って送ってない。

で、その辺で更に調べてたらこんな方法もありました。

Homebrewでnginxを入れるときに比較的簡単に--add-moduleする方法

10
9
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?