简体   繁体   中英

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

I have working Rails app on sub-uri redmine.example.org/redmine and I want it on 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>

I tried many combination and googled hours, but nothing works.

How should I change this config to deploy redmine on subdomain root?

Thanks in advance.

Well, it was easier, than I supposed.

When I read the manual again and again I found solution: link to manual

Now my config file looks like this:

<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>

Another way to deploy sub-uri app, might work for you too:

<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>

I installed Redmine 3.3.1 on a Debian 9.0 Stretch server using the packages provided by the distribution itself (Apache + Redmine + Ruby + Rails + Passenger + MariaDB) more or less following those guides:

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

I would like to leave www.example.org "for Apache" and redmine.example.org "for Redmine", so I ended up with the following setup.

I left /etc/apache2/sites-available/000-default.conf untouched and created a file named redmine.conf inside that same folder:

<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>

Then, I've linked it to the sites-enabled folder and restarted Apache:

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

To set up that virtual host, I followed the directions here:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM