问题描述
我已经安装在我的本地网络上的Apache2在其上的Ubuntu的服务器。
I have setup on my local network an Ubuntu server with Apache2 on it.
我想在同一台服务器上管理不同的应用程序,当用户请求一个URL的专用应用程序服务。
I would like to manage different applications on the same server, when you request an url a dedicated application is served.
例如。
http://192.168.0.25/my_app_1 -> responds with app1 (for example a Ruby on Rails app)
http://192.168.0.25/my_app_2 -> responds with app2 (for example a php website)
[...]
# where 192.168.0.25 is the IP of the server
我认为,这是由配置的Apache2正确virtualhosts完成。
I think that this is done by configuring correctly the virtualhosts in Apache2.
在这个时刻,APP1的示例配置(即Ruby on Rails的),就像如下:
At this moment, a sample configuration of app1 (i.e. Ruby on Rails) is like the followed:
<VirtualHost 192.168.0.25:80>
DocumentRoot path_to_my_public_app1_folder
<Directory path_to_my_public_app1_folder>
Options -MultiViews
AllowOverride All
</Directory>
RailsEnv production
</VirtualHost>
如何定义子路径?也许这样的事情?
How can define the sub path? Maybe something like this?
<VirtualHost 192.168.0.25/my_app1:80>
我这样做对吗?
因为在这个时刻,我收到404(甚至没有定义的Apache网页这是工作!)
Am I doing it right?Because at this moment I recieve a 404 (not even the custom Apache page "It's work!")
推荐答案
虚拟主机
意味着不同的东西。它可以让你(简称)主办的网站应对不同的名称,例如:
VirtualHost
means something different. It allows you (in short) to host sites responding to different names, e.g.:
http://mydomain.com
http://anotherdomain.com
在同一台服务器上。所以把它作为虚拟appaches,都在同一台机器上,但不同的名称标识。
on the same server. So think of it as virtual appaches, all on the same machine, but identified by different names.
您的用例是不同的。要配置实例 192.168.0.25
以及它如何服务不同的要求。因此,在URL中的主机之后的部分:的http:// HOST / PATH_TO_APP
Your usecase is different. You want to configure the instance 192.168.0.25
and how it serves different requests. So the part after the host in the URL: http://HOST/PATH_TO_APP
有关实例回应 192.168.0.25
你应该在
/etc/apache2/sites-available/default
您可以添加以下内容:
Alias /my_app_1 path_to_my_public_app1_folder
Alias /my_app_2 path_to_my_public_app2_folder
这篇关于阿帕奇virtualhosts:不同的路径供职于同一IP不同的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!