在 Aliyun ECS 上用 Nginx + Passenger 部署 Rails 应用时安装 Passenger 的问题
created_at: 2017-02-14  

问题

第一次部署Rails应用,参照资料1 资料2 资料3 资料4等资料在服务器上装好了ruby, rvm, 相关依赖等,但在安装passenger时,参照此官方文档,安装了秘钥和HTTP支持,也添加了APT源: sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'

但在执行 sudo apt-get update时遇到以下错误:

Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial InRelease
Hit:2 http://mirrors.aliyun.com/ubuntu xenial InRelease
Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security InRelease [102 kB]
Get:4 http://mirrors.aliyun.com/ubuntu xenial-security InRelease [102 kB]      
Get:5 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates InRelease [102 kB]
Get:6 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease [102 kB]       
Get:7 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-proposed InRelease [253 kB]
                                     ……
                                     ……
Get:45 http://mirrors.aliyun.com/ubuntu xenial-proposed/universe i386 Packages [31.6 kB]
Get:46 http://mirrors.aliyun.com/ubuntu xenial-proposed/universe Translation-en [12.9 kB]
Ign:47 https://oss-binaries.phusionpassenger.com/apt/passenger xenial InRelease 
Ign:48 https://oss-binaries.phusionpassenger.com/apt/passenger xenial Release   
Ign:49 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main amd64 Packages
Ign:50 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main i386 Packages 
Ign:51 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main all Packages
Ign:52 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en_US
Ign:53 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en
Ign:49 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main amd64 Packages
Ign:50 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main i386 Packages
Ign:51 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main all Packages
Ign:52 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en_US
Ign:53 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en
Ign:49 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main amd64 Packages
Ign:50 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main i386 Packages
Ign:51 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main all Packages
Ign:52 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en_US
Ign:53 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en
Ign:49 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main amd64 Packages
Ign:50 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main i386 Packages
Ign:51 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main all Packages
Ign:52 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en_US
Ign:53 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en
Ign:49 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main amd64 Packages
Ign:50 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main i386 Packages
Ign:51 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main all Packages
Ign:52 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en_US
Ign:53 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en
Err:49 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main amd64 Packages
  Bad header line
Ign:50 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main i386 Packages
Ign:51 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main all Packages
Ign:52 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en_US
Ign:53 https://oss-binaries.phusionpassenger.com/apt/passenger xenial/main Translation-en
Fetched 6,467 kB in 2min 3s (52.4 kB/s)
Reading package lists... Done
W: The repository 'https://oss-binaries.phusionpassenger.com/apt/passenger xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch https://oss-binaries.phusionpassenger.com/apt/passenger/dists/xenial/main/binary-amd64/Packages  Bad header line
E: Some index files failed to download. They have been ignored, or old ones used instead.

与passenger相关的都是Ign或者Err了,然后报的Bad header line也不知道是怎么回事,总之到apt-get update这步永远也不能成功执行。

服务器系统是Ubuntu 16.04 LTS,我在本地物理机上相同系统也试了,没有出现这个问题,passenger可以成功安装,所以应该不是服务器系统或者APT源的问题。有人遇到过这种情况吗,google, stackoverflow 试了各种方法折腾了一天一夜也没解决,准备放弃 改用Puma了。BTW,用老的方法passenger-install-nginx-module也不行,downloading Nginx 之后就会卡住不动了。

解决方法

不得不说社区真强大,提问没多久就得到了@darkbaby123的解答:

说说我前段时间碰到的类似问题,希望对你有帮助。当时也是装第三方 apt 源不成功,不过错误类型 是 apt-get update 报 403 。后来发现是阿里云的主机对 apt 配置了代理,应该是为了让内网 机器访问自家的源加速,但影响了第三方源的获取。

代理配置在 /etc/apt/apt.conf 里,把它注释掉再 update 就没问题了,注释用 # 号: Acquire::http::Proxy "http://mirrors.aliyun.com/";

原文地址

0 赞  
back
no comment yet
回复成功

回复成功

请输入内容