Der*_*iel 2 ubuntu ruby-on-rails phusion-passenger apache-2.2
我最近决定尝试使用 Rails。使用 PHP 时,我只是将所有 PHP 项目放在同一目录中。例如,我可能有http://ubuntu/app1
,http://ubuntu/app2
等等。
我为 Rails ( http://ruby.ubuntu
)创建了一个子域,安装了 Rails 和乘客,一切正常。但是,我可能错了,但看起来每个子域只能有一个 Rails 应用程序?
我的虚拟主机如下:
<VirtualHost *:80>
ServerName ruby.ubuntu
ServerAdmin webmaster@localhost
DocumentRoot /var/www/ruby/blog/public
<Directory /var/www/ruby/blog/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
RailsEnv development
</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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我所有的 PHP 和杂项。文件存储在/var/www/main
. 我希望能够将我所有的 Rails 应用程序存储在/var/www/ruby
. 我尝试将 DocumentRoot 更改为/var/www/ruby
,但我认为它没有那么简单。当我浏览到 Rails 应用程序的 Welcome Aboard 页面并单击“关于我的应用程序环境”时,我得到一个 404 页面,但是当 DocumentRoot 设置为公共目录时,我得到了预期的结果。
我不想每次创建新项目时都必须创建一个新的子域。有没有什么办法可以让它这样我就可以存储所有我的应用程序/var/www/ruby
,并浏览到http://ruby.ubuntu
会让我访问所有我的Rails应用程式的呢?这样,如果我想创建一个新的应用程序,我所要做的就是rails new app
,不需要 Apache .htaccess 或 VirtualHost 配置。
小智 5
您可以根据需要提供任意数量的 Rails 应用程序。
如果使用 apache httpd 和乘客,步骤如下:
只需将每个 rails 应用程序的公共文件夹符号链接到 apache 的 DocumentRoot 作为子文件夹。然后在你的 apache 配置中添加一个 RailsBaseURI 指令,告诉乘客给定的文件夹是一个 rails 应用程序。
假设您有两个 Rails 应用程序 rapp1 和 rapp2。假设您的 apache DocumentRoot 是 /var/www/html
ln -s rapp1 /var/www/html/rapp1
ln -s rapp2 /var/www/html/rapp2
Run Code Online (Sandbox Code Playgroud)
现在打开您的 apache 虚拟主机配置文件并添加以下两行
RailsBaseURI /rapp1
RailsBaseURI /rapp2
Run Code Online (Sandbox Code Playgroud)
重新启动您的 apache 服务器,当您访问时http://servername/rapp1
,您的 rails 应用程序将得到服务
归档时间: |
|
查看次数: |
3320 次 |
最近记录: |