2013-03-01 152 views
13

我有一个rails应用程序,并希望设置谷歌SPDY协议支持。但是,在安装带有SPDY补丁的Nginx并在虚拟主机中启用spdy之后,它不允许我重新启动nginx,而是引发以下错误。如何通过Nginx设置SPDY协议?

Restarting nginx: nginx: [emerg] invalid parameter "spdy" in /etc/nginx/sites-enabled/default:112 
nginx: configuration file /etc/nginx/nginx.conf test failed 

我编了最新的Nginx 1.3.13与SPDY补丁,我在这里提我的安装

wget http://nginx.org/download/nginx-1.3.13.tar.gz 
tar xvfz nginx-1.3.13.tar.gz 
cd nginx-1.3.13 

# Fetch the SPDY patch and apply it 
wget http://nginx.org/patches/spdy/patch.spdy.txt 
patch -p1 < patch.spdy.txt 

./configure \ 
--sbin-path=/usr/local/sbin/nginx \ 
--prefix=/etc/nginx \ 
--conf-path=/etc/nginx/nginx.conf \ 
--error-log-path=/var/log/nginx/error.log \ 
--http-client-body-temp-path=/var/lib/nginx/body \ 
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \ 
--http-log-path=/var/log/nginx/access.log \ 
--http-proxy-temp-path=/var/lib/nginx/proxy \ 
--http-scgi-temp-path=/var/lib/nginx/scgi \ 
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \ 
--lock-path=/var/lock/nginx.lock \ 
--pid-path=/var/run/nginx.pid \ 
--with-debug \ 
--with-http_addition_module \ 
--with-http_dav_module \ 
--with-http_gzip_static_module \ 
--with-http_realip_module \ 
--with-http_stub_status_module \ 
--with-http_ssl_module \ 
--with-http_sub_module \ 
--with-http_xslt_module \ 
--with-http_spdy_module \ 
--with-ipv6 \ 
--with-sha1=/usr/include/openssl \ 
--with-md5=/usr/include/openssl \ 
--with-mail \ 
--with-mail_ssl_module \ 

# wget https://you.googlecode.com/files/ngx_cache_purge-1.6.tar.gz 
--add-module=/software/ngx_cache_purge-1.6 \ 

#http://www.openssl.org/source/openssl-1.0.1e.tar.gz 
--with-openssl='/software/openssl-1.0.1e' 

# Build and install nginx 
make && sudo make install 

它成功地编译没有任何错误的步骤。 结果0F nginx的-V提供了以下

nginx version: nginx/1.3.13 
built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 
TLS SNI support enabled 
configure arguments: --sbin-path=/usr/local/sbin/nginx --prefix=/etc/nginx --conf-   path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-http_spdy_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/software/ngx_cache_purge-1.6 --with-openssl=/software/openssl-1.0.1e 

我的/ etc/nginx的/启用站点配置有

server { 
     listen 443 ssl spdy; 

     ssl_certificate  server.crt; 
     ssl_certificate_key server.key; 

     ... 
    } 

毕竟这全成安装nginx的不SPDY PARAM在网站的服务器块重启启用文件。

有什么建议吗?我很确定在这里错过了一些东西,但无法弄清楚。

+1

SPDY本身并不是很大的好处,但是与TCP/IP调整相结合https://coderwall.com/p/8igwqa – Anatoly 2013-04-16 20:25:46

+0

请关注本文http://www.liberiangeek.net/2014/10/install-latest-version-nginx-ubuntu-14-10/ – AntonAL 2016-03-18 22:13:26

回答

13

更新(2013年11月19日):为nginx的1.4.3修改脚本(并不需要SPDY补丁)

https://gist.github.com/deepak-kumar/7541199#file-compile_nginx_1-4-3_with-spdy-sh

我写Shell脚本的设置

https://gist.github.com/deepak-kumar/5069550#file-compile_nginx_with_spdy-sh

我找到了解决问题的办法。

甚至在编译这个导致问题的1.3.13之前,我已经在我的Ubuntu 12.04上安装了nginx软件包。 $ sudo apt-get install nginx

为了解决这个问题,我确保/etc/init.d/nginx应该使用正确的二进制文件。

我做终端如下:

$ which nginx 
$ /usr/local/sbin/nginx 

经过我现有/etc/init.d/nginx脚本它用错了DAEMON路径,所以我改变了它看起来像这样(的作品)

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 
DAEMON=/usr/local/sbin/nginx # $which nginx 

早些时候,上述值分别为(不起作用)

#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 
#DAEMON=/usr/sbin/nginx 

其余的fi le保持不变。所以基本上我使用了正确的版本二进制。

更新:这个博客也是一个很好的参考点,如果你们有兴趣。 http://blog.bubbleideas.com/2012/08/How-to-set-up-SPDY-on-nginx-for-your-rails-app-and-test-it.html

+0

可能会更容易“apt-get remove nginx”..尽管如此在生产系统上工作时会烧毁你的桥。 – Julian 2013-04-21 23:06:32

+0

是否有更新此nginx 1.6.2的shell脚本。该脚本似乎在Ubuntu 14.0.4上最新的nginx失败。 – marvindanig 2014-10-16 15:47:31

+1

@marvindanig这应该有所帮助,更多的你不需要补丁了,只需在编译时传递--with-http_spdy_module选项http://blog.glaucocustodio.com/2014/11/24/adding-support-to-spdy-协议在Nginx的零宕机时间/ – 2015-05-18 18:45:13