网站不断要求下载ruby文件?

我是Ruby开发新手。 我试图安装phusion乘客,并将其与Ubuntu 14.04上的Apache整合。

我完成了此页面的步骤2.3: https : //www.phusionpassenger.com/documentation/Users%20guide%20Apache.html

但是,当我去http://192.168.0.105/suburl/home.rb这样的url,浏览器下载rb文件,而不是作为一个网页。

我迷失在所有的指示。 任何人都可以build议我下一步应该做什么,让我的home.rb只是简单地运行,只是puts "hello world"

这是我的/ etc / apache / sites-enabled / 000-default

 <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, eg #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 

我看到passenger.load也在启用mods的目录中。

通常情况下,当您的浏览器为您提供一个文件下载,这意味着Web服务器不识别文件作为dynamic内容。 这是相同的PHP / python /ruby…

开始保持简单。 selectApache或Nginx运行你的乘客模块。

如果您selectapache,请启用Ubuntu Universe存储库,然后运行:

 apt-get install libapache2-mod-passenger 

另一方面,如果您selectnginx,则必须安装带有内置支持的nginx版本:

 apt-get install ruby-passenger 

另外,您的项目至less需要3个展位

 /var/www/myproject /var/www/myproject/public /var/www/myproject/tmp 

和1个文件:

 /var/www/myproject/config.ru 

您需要将DocumentRoot设置为“public”,但是您的代码开始从config.ru加载。 所以,这是例子apache Vhost:

 <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/myproject/public ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

从您链接的文档中查看4.1。