使用brew安装带有http-image-filter-module的Nginx的步骤

基本上很简单!我参考了只使用Nginx进行实时图像转换的方法。

立刻尝试

当查看上述网站时,
./configure –with-http_image_filter_module

只需在指令上加以指定即可。我原本打算这样做,但是由于之前使用Homebrew安装了nginx,我决定查找Homebrew的相关资讯。

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

嗯?没有图像过滤器吗…。

只需要替换单词‘ビルド’和‘homebrew での管理’即可:如果您下载源代码并进行构建,那应该是可以的,但既然已经方便地使用homebrew进行管理,最好不要破坏这个。

无论如何,我勉强尝试了一下。

修改公式

请将”/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’ ← これを足す

确认

列举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

哇!进来了。

进行安装

使用以下命令在本地安装nginx: 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 库重新尝试。

安装libgd使用brew命令。

这边顺利地完成了。

在中国本土进行中文语义重组无论只需一个选择:使用带有图像过滤器的命令 brew install 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
==> 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 可以被简化成以下几种方式:

1. 查看Nginx版本及编译信息:nginx -V
2. 获取Nginx版本和配置信息:nginx -V
3. 显示Nginx版本和编译配置:nginx -V
4. 输出Nginx版本和编译选项: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

我終於完成任務了。

作者在的结尾中提到

我修改了公式,但它已经存在于git存储库中,所以可能会出现一些微妙的问题。虽然可以将公式更改的pull请求发送过去,但我并没有发送,因为这个模块已经存在很久了,却没有被收录进去,我想可能有某种原因。

然后,当我在那附近进一步调查时,我发现还有这种方法。

在安装Homebrew时,通过相对简单的方法使用”–add-module”来安装nginx。