簡體   English   中英

如何使用Apache和Passenger在子域根目錄上部署Rails應用

[英]How to deploy Rails app on subdomain root with Apache and Passenger

我在sub-uri redmine.example.org/redmine上有正在使用的Rails應用程序,我希望在redmine.example.org上使用

/var/www/work/redmine.src is approot
/var/www/work/redmine is symlink to /var/www/work/redmine.src/public

<VirtualHost *:80>
    DocumentRoot /var/www/work
    ServerName redmine.example.org

    ErrorLog /var/log/apache2/redmine-error_log
    CustomLog /var/log/apache2/redmine-access_log combined

    <Directory /var/www/work/redmine>
            AllowOverride all
            Options -MultiViews
            Order allow,deny
            allow from all
    </Directory>

    RackBaseURI /redmine
    <Directory /var/www/work/redmine.src>
            Options -MultiViews
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

我嘗試了許多組合和谷歌搜索時間,但沒有任何效果。

我應該如何更改此配置以在子域根目錄上部署Redmine?

提前致謝。

好吧,這比我想象的要容易。

當我一次又一次地閱讀手冊時,我找到了解決方法: 鏈接到手冊

現在我的配置文件如下所示:

<VirtualHost *:80>
    DocumentRoot /var/www/work/redmine.src/public
    ServerName redmine.example.org

    <Directory /var/www/work/redmine.src/public>
        AllowOverride all
        Options -MultiViews
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

部署sub-uri應用的另一種方法也可能對您有用:

<VirtualHost *:80>
    ProxyPass /sub_uri/ http://localhost:8000/sub_uri/

    DocumentRoot /main_app/public
    <Directory /main_app/public>
       ...
    </Directory>
</VirtualHost>

<VirtualHost *:8000>
  DocumentRoot /sub_uri/public
  <Directory /sub_uri/public>
    ...
    SetEnv RAILS_RELATIVE_URL_ROOT /sub_uri
  </Directory>
</VirtualHost>

我使用發行版本身提供的軟件包(Apache + Redmine + Ruby + Rails + Passenger + MariaDB)在Debian 9.0 Stretch服務器上安裝了Redmine 3.3.1,遵循這些指南:

http://www.redmine.org/projects/redmine/wiki/RedmineInstall http://www.redmine.org/projects/redmine/wiki/InstallRedmineOnDebianStableApacheMysqlPassenger

我想離開www.example.org用於Apache)和redmine.example.org用於Redmine),所以我完成了以下設置。

我保持不變的/etc/apache2/sites-available/000-default.conf並在同一文件夾內創建了一個名為redmine.conf文件:

<VirtualHost *:80>
    ServerName redmine.example.org
    DocumentRoot /usr/share/redmine/public
    PassengerRuby /usr/bin/ruby
    <Directory /usr/share/redmine/public>
        Allow from all
        Options -MultiViews
        Require all granted
    </Directory>
</VirtualHost>

然后,將其鏈接到sites-enabledsites-enabled文件夾,然后重新啟動Apache:

# ln -s /etc/apache2/sites-available/redmine.conf /etc/apache2/sites-enabled/redmine.conf
# systemctl restart apache2

要設置該虛擬主機,我按照以下說明進行操作:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM