且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

部署同一个Apache服务器上的网站2

更新时间:2023-11-22 19:24:28

最简单的方法是做基于域名的虚拟主机,使用子域名如你所说。那么,你写的:

Easiest way would be to do name-based virtual hosting, using a subdomain as you suggested. So where you write:

<VirtualHost *:80>
  ServerName localhost
</VirtualHost>

只需输入您的子域名来代替:

Simply enter your subdomain instead:

<VirtualHost *:80>
  ServerName mysubdomain.mycompany.com
</VirtualHost>

然后

阿帕奇应该从'主'分离到子域名的任何请求的虚拟主机自动运行。

Apache should then separate any requests to that subdomain from the 'main' virtualhost automatically.

编辑:

另外,它可以应用挂载轨到子目录,以及(你使用客运假设。)这里是根据我自己的本地临时环境的例子。我通过在的Phusion网站

Alternatively it is possible to mount your rails app to a subdirectory as well (assuming you're using Passenger.) Here's an example based on my own local staging environment. I got this working by following the instructions at the Phusion website

<VirtualHost *:80>
  ServerName localhost

  # We will mount our application under http://localhost/myapp
  RailsBaseURI /myapp

  # This can be anywhere on the system, I just happened to use /home/www
  <Directory /home/www/myapp>
    # Here you can add any directives necessary for your app, like for example..
    SetEnv GEM_HOME /home/user/.rvm/gems/ree-1.8.7-2012.02
  </Directory>
</VirtualHost>

现在你要做的一件事,那就是作出的/ home /网络/ MyApp的一个链接到实际应用的公共目录。因此,让我们说,你有你自己的应用HOMEDIR您必须输入:

Now you have to do one more thing, and that's make /home/www/myapp a link to the public dir of the actual application. So let's say you have the application in your own homedir you would have to type this:

cd /home/www
ln -s /home/myuser/myapp/public myapp

如果你输入ls -l命令它应该显示:

If you then type ls -l it should show:

lrwxrwxrwx 1 myuser myuser 18 Jun 10 16:41 devb -> /home/myuser/myapp/public

我觉得应该是它。

I think that should be it.