关于Ruby on Rails:Nginx和乘客依赖问题(数字海洋部署)

Nginx and passenger dependencies issue (Digital Ocean Deployment)

我正在尝试遵循本指南

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-nginx-on-ubuntu-14-04

运行此命令后要继续学习本教程时:

1
sudo apt-get install nginx-extras passenger

我收到此错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Reading package lists... Done
Building dependency tree

Reading state information... Done
passenger is already the newest version.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
nginx-extras : Depends: perlapi-5.18.2 but it is not installable
Depends: libperl5.18 (>= 5.18.2) but it is not installable
Recommends: passenger (< 4.0.60) but 1:4.0.59-1~trusty1 is to be installed
E: Unable to correct problems, you have held broken packages.

我认为我无法安装nginx-extras,有人可以帮我吗?


我在Ubuntu 14.10上遇到了相同的问题

1
sudo nano /etc/apt/sources.list.d/passenger.list

评论
deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main

ctrl x
?
输入

1
2
3
sudo apt-get update

sudo apt-get install nginx nginx-extras

然后,如果还可以,

1
sudo nano /etc/apt/sources.list.d/passenger.list

插入
deb https://oss-binaries.phusionpassenger.com/apt/passenger wheezy main

ctrl x
?
输入

1
2
3
sudo apt-get update

sudo apt-get install passenger

Voila!


如果您使用的是Ubuntu 16.04,请执行以下操作

1
2
3
4
5
6
7
8
9
10
# Install our PGP key and add HTTPS support for APT
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates

# Add our APT repository
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

# Install Passenger + Nginx
sudo apt-get install -y nginx-extras passenger


由于这个问题,我使用了nginx-full而不是nginx-extras。我正在运行14.10,因为我想要Postgres 9.4。

我一直遇到很多奇怪的错误,并且我不小心遵循了APT指示,按照乘客的指示进行操作。哎呀所以我最初遵循@ Maciej-adamczewski的回答,但是他要添加Debian 7乘客安装而不是Ubuntu 14.04安装。这把我搞砸了。

这是我为我排序的方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sudo apt-mark showhold  # apparently I had nothing in here
sudo apt-get autoclean
sudo apt-get update && sudo apt-get upgrade
# I hoped upgrade would get rid of that error re: nginx-extras
# it didn't at all, so decided to scrap and start over

sudo apt-get purge nginx*  # to get rid of everything nginx
sudo apt-get remove nginx*  # paranoia
sudo apt-get purge passenger
sudo apt-get remove passenger  # paranoia again
sudo apt-get autoremove

sudo apt-get update
sudo apt-get install nginx-full passenger

景气!让Nginx正常运行。

在Digital Ocean上没有说明,但是如果直接安装RVM而不是ruby,则需要找出rvm ruby??的位置:

1
2
rvm use
passenger-config --ruby-command

然后复制粘贴表示为passenger_ruby /usr/local/...的nginx信息,并覆盖/etc/nginx/nginx.conf文件中的原始passenger_ruby行。

稍后,当您创建站点时,请确保在服务器块中为nginx添加passenger_enabled on;

这个家伙的疯狂道具:在DO

上设置rails


当我遇到此错误时,是因为我要安装的乘客版本与ubuntu的版本不匹配。检查您是否在Ubuntu 14.04上。

如果不是,则需要更改/etc/apt/sources.list.d/passenger.list中的行deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main以匹配您的ubuntu版本。

然后运行sudo apt-get update


可能是ubuntu版本错误,请尝试使用以下命令:

1
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'