一个端口上有多个 Ruby 应用程序,RackBaseURI 帮助
我正在尝试让两个 Ruby 应用程序从同一个端口运行。我根本不懂服务器技术,所以请原谅我的无知。我尝试遵循此文档:
http://www.modrails.com/ Documentation/Users%20guide%20Apache.html
第 4.1 - 4.3 节,但我总是把事情搞砸。我试图简化一点,这就是我的情况。我这里有两个简单的机架应用程序:
/Users/dan/webapps/test1 /Users/dan/webapps/test2
他们每个都有“config.ru”文件、public/文件夹和带有“restart.txt”的tmp/文件夹,按照指示。他们都各自工作。
我的 httpd.conf 文件中有以下内容:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/dan/webapps
<Directory /Users/dan/webapps>
Allow from all
</Directory>
RackBaseURI /test1
<Directory /Users/dan/webapps/test1>
Options -MultiViews
</Directory>
RackBaseURI /test2
<Directory /Users/dan/webapps/test2>
Options -MultiViews
</Directory>
</VirtualHost>
我启动 apache,然后将其放入浏览器中: http://localhost/test1< /a>.我得到:
Forbidden
您无权访问此服务器上的 /test1。
我对它不起作用并不感到惊讶,因为我应该设置一个符号链接,但我不知道如何将其应用到我的设置中。这是文档中的示例:
ln -s /webapps/rackapp/public /websites/phusion/rack
您能告诉我如何设置符号链接,如果您发现其他错误,请告诉我?请给出“傻瓜式”答案,这东西让我难以置信。谢谢!
I'm trying to get two Ruby apps to work from the same port. I don't know server technology at all, so forgive my ignorance. I've tried to follow this doc:
http://www.modrails.com/documentation/Users%20guide%20Apache.html
sections 4.1 - 4.3, but I keep messing something up. I've tried to simplify a little, so here is my situation. I have two simple rackup apps here:
/Users/dan/webapps/test1
/Users/dan/webapps/test2
They each have the "config.ru" file, the public/ folder, and the tmp/ folder with "restart.txt", as directed. They both work on their own.
I have the following in my httpd.conf file:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/dan/webapps
<Directory /Users/dan/webapps>
Allow from all
</Directory>
RackBaseURI /test1
<Directory /Users/dan/webapps/test1>
Options -MultiViews
</Directory>
RackBaseURI /test2
<Directory /Users/dan/webapps/test2>
Options -MultiViews
</Directory>
</VirtualHost>
I start apache, and then put this in my browser: http://localhost/test1. I get:
Forbidden
You don't have permission to access /test1 on this server.
I'm not surprised it doesn't work, because I am supposed to set up a symlink but I don't know how to apply that to my setup. Here is the example from the doc:
ln -s /webapps/rackapp/public /websites/phusion/rack
Can you tell me how to set up the symlinks, and let me know if you see anything else wrong? Please give the "for dummies" answer, this stuff boggles my mind. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要创建符号链接,请尝试以下操作:
但是,正如 chris polzer 提到的,您还应该检查您的 apache 用户是否可以从这些目录中读取内容。
如果您不知道如何执行此操作,请发布这些命令的输出:
您可能还需要检查所有父目录的权限。即 /Users、/Users/dan 和 /Users/dan/webapps。请参阅:http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_to_a_virtual_host_8217_s_root_2
To create the symlinks, try this:
However, as chris polzer mentioned, you should also check that your apache user can read from those directories.
If you don't know how to do that, then post the output of these commands:
You may also need to check the permissions of all parent directories. I.e. /Users, /Users/dan, and /Users/dan/webapps. See: http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_to_a_virtual_host_8217_s_root_2
phylae,我认为您可能在符号链接中颠倒了路径。为了使其正常工作,为了清楚起见,我更改了链接名称:
然后是符号链接:
ln -s /Users/dan/webapps/test1/public /Users/dan/webapps/test1link
ln -s /Users/dan/webapps /test2/public /Users/dan/webapps/test2link
然后这些 url 在浏览器中按预期工作。
http://localhost/
http://localhost/ http://localhost / /localhost/test1link
http://localhost/test2link
phylae, I think you may have the paths reversed in the symbolic link. To get it working, I changed the link names for clarity:
and then, the symbolic links:
ln -s /Users/dan/webapps/test1/public /Users/dan/webapps/test1link
ln -s /Users/dan/webapps/test2/public /Users/dan/webapps/test2link
Then these urls work as expected in a browser.
http://localhost/
http://localhost/test1link
http://localhost/test2link