Ubuntu-Apache:乘客根本不启动Rails应用

时间:2018-12-13 08:30:51

标签: ruby-on-rails apache passenger

我正在使用Apache开发Ubuntu 16.04。我尝试使用Phusion Passeger启动我的rails应用程序。但是应用程序根本无法启动,如果输入URL http://poyry.wo.local/kainji和唯一的登录other_vhosts_access.log,我将得到HTML 403“您无权访问此服务器上的/ kainji /” :

poyry.wo.local:80 127.0.0.1 - - [13/Dec/2018:15:19:28 +0100] "GET /kainji/ HTTP/1.1" 403 513 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36" 2265

网站可用目录中有以下文件链接到启用网站的目录中:

<VirtualHost *:80>
  ServerName poyry.wo.local
  DocumentRoot /var/www/html/dev/rails

  <Directory /var/www/html/dev/rails>
    Options -Indexes
    Allow from all
  </Directory>

  PassengerBaseURI /kainji
  <Directory /var/www/html/dev/rails/v2p0-kanji/public>
    RailsEnv    development
    Options     -MultiViews
  </Directory>
</VirtualHost>

如果删除链接,则会显示HTML 404:“在此服务器上找不到请求的URL / kainji。”什么是正确的。

在Apache错误日志中,我看到“乘客”已启动:

[ 2018-12-12 14:17:41.8778 4321/7efdbb745780 age/Wat/WatchdogMain.cpp:1291 ]: Starting Passenger watchdog...
[ 2018-12-12 14:17:41.8885 4324/7f0b49b28780 age/Cor/CoreMain.cpp:982 ]: Starting Passenger core...
[ 2018-12-12 14:17:41.8886 4324/7f0b49b28780 age/Cor/CoreMain.cpp:235 ]: Passenger core running in multi-application mode.
[ 2018-12-12 14:17:41.8908 4324/7f0b49b28780 age/Cor/CoreMain.cpp:732 ]: Passenger core online, PID 4324
[ 2018-12-12 14:17:41.9045 4356/7fd543c3b780 age/Ust/UstRouterMain.cpp:529 ]: Starting Passenger UstRouter...
[ 2018-12-12 14:17:41.9051 4356/7fd543c3b780 age/Ust/UstRouterMain.cpp:342 ]: Passenger UstRouter online, PID 4356
[Wed Dec 12 14:17:42.201857 2018] [ssl:warn] [pid 4318] AH01909: centos1.tibi1959.hu:443:0 server certificate does NOT include an ID which matches the server name
[Wed Dec 12 14:17:42.209447 2018] [mpm_prefork:notice] [pid 4318] AH00163: Apache/2.4.18 (Ubuntu) Phusion_Passenger/5.0.29 OpenSSL/1.0.2g configured -- resuming normal operations
[Wed Dec 12 14:17:42.209484 2018] [core:notice] [pid 4318] AH00094: Command line: '/usr/sbin/apache2'

也可以验证乘客的安装:

$ /usr/bin/passenger-config validate-install
What would you like to validate?
Use <space> to select.
If the menu doesn't display correctly, press '!'

   ⬢  Passenger itself
 ‣ ⬢  Apache

-------------------------------------------------------------------------

Checking whether there are multiple Apache installations...
Only a single installation detected. This is good.

-------------------------------------------------------------------------

 * Checking whether this Passenger install is in PATH... ✓
 * Checking whether there are no other Passenger installations... ✓
 * Checking whether Apache is installed... ✓
 * Checking whether the Passenger module is correctly configured in Apache... ✓

Everything looks good. :-)

怎么了?

1 个答案:

答案 0 :(得分:0)

乍一看,我猜这是由静态文件服务覆盖应用程序引起的。

403错误是由于目录列表被禁用,并且没有index.html文件可显示。

您可能想更改设置静态文件服务的方式,因此url需要“ public”文件夹名称。这样,您可以将应用程序服务器设置为路由到/kainji路径。

也许像这样:

```   ServerName poyry.wo.local   DocumentRoot / var / www / html / dev / rails / kainji / public

PassengerBaseURI / kainji        RailsEnv开发     选项-MultiViews    ```