Ruby on Rails 应用程序的虚拟主机设置 (mod Passenger)

Ruby on Rails 应用程序的虚拟主机设置 (mod Passenger)

我正在尝试在 apache 下安装 Redmine。apache 服务器在本地网络上运行。我的 apache 设置由单个虚拟主机组成。我可以使用以下路径进入不同的目录:

http://ip_address/folder_of_the_project_1

在这种情况下,如何设置虚拟主机以使 redmine 正常工作?这是我当前的虚拟主机设置:

NameVirtualHost *
<VirtualHost *>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/
    RailsBaseURI /redmine
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

    <Directory /var/www/>
            Options FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    <Directory /var/www/redmine/public>                
            Options FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.        
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

谢谢你,Ingo86

答案1

将 DocumentRoot 指向您的 Redmine 公共目录,并将 RailsBaseURI 指向 /。

下面是我正在使用的 Ubuntu 服务器的一个示例:

<VirtualHost *:80>
  ServerName redmine.int.example.com
  ServerAlias redmine
  DocumentRoot /var/www/redmine/public

  RailsBaseURI /
  RailsEnv production

  PassengerMaxPoolSize 4

  <Directory /var/www/redmine/public>
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>

  LogLevel info
  ErrorLog /var/log/apache2/redmine-error.log
  CustomLog /var/log/apache2/redmine-access.log combined
</VirtualHost>

答案2

你试过了吗RailsBaseURI /redmine/public代替RailsBaseURI /redmine? 万一。

答案3

有人建议将 DocumentRoot 指向 redmine 目录的根目录,如下所示:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName golem.it
    DocumentRoot "/var/www/redmine/public"

    <Directory /var/www/redmine/public>
            AllowOverride all
            Options -MultiViews
    </Directory>
</VirtualHost>

上述方法当然有效,但是它既没有回答所提出的具体问题,也没有提供不需要从其他应用程序完全窃取 documentroot 的通用解决方案。

我发现的解决方案需要创建一个名为 redmines 的到 /var/www/redmine-2.2/public 的符号链接(请注意,它不是 redmine 而是 redmines,因为可能存在 Passenger 命名错误!),解决方案如下所示(忽略 ssl 部分):

NameVirtualHost *:443
<VirtualHost *:443>
    ServerName golem.it
    DocumentRoot "/var/www"
    Options +Indexes
    Options +ExecCGI

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

    PassengerAppRoot /var/www/redmine-2.2
    RailsBaseURI /redmines
    Alias /redmine /var/www/redmines
    <Directory /var/www/redmines>
            AllowOverride All
            Options -MultiViews
    </Directory>

    SSLEngine On
    SSLCertificateFile /etc/apache2/dwewe.crt
    SSLCertificateKeyFile /etc/apache2/wefew.key
    SSLCACertificateFile /etc/apache2/wefer/ca.crt
    SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
</VirtualHost>

相关内容