[英]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 我在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>
I tried many combination and googled hours, but nothing works. 我尝试了许多组合和谷歌搜索时间,但没有任何效果。
How should I change this config to deploy redmine on subdomain root? 我应该如何更改此配置以在子域根目录上部署Redmine?
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: 部署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>
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: 我使用发行版本身提供的软件包(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 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. 我想离开www.example.org
用于Apache)和redmine.example.org
用于Redmine),所以我完成了以下设置。
I left /etc/apache2/sites-available/000-default.conf
untouched and created a file named redmine.conf
inside that same folder: 我保持不变的/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>
Then, I've linked it to the sites-enabled
folder and restarted Apache: 然后,将其链接到sites-enabled
了sites-enabled
文件夹,然后重新启动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: 要设置该虚拟主机,我按照以下说明进行操作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.