使用XAMPP托管多个本地站点 [英] Hosting multiple local sites with XAMPP

查看:87
本文介绍了使用XAMPP托管多个本地站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用XAMPP,因此对某些人来说可能很简单.

I'm new to using XAMPP so this may be simple to some people.

我有一些php项目,我希望能够在本地调试并在浏览器中查看(不是同时进行,但每次我想使用不同的项目时都不必更改配置文件/复制项目文件夹)

I have a few php projects that I would like to be able to debug locally and view in the browser (not concurrently, but without having to change config files/copy project folders each time I want to work on a different project).

在IIS上,您可以设置多个站点来从您的计算机上进行服务,而我正在XAMPP中寻找类似的内容.使用IIS时,我向Windows主机文件中添加了多个记录,因此我可以通过键入友好的Web样式地址(例如 http ://myproject1.dev )

On IIS, you could set up multiple sites to serve from your machine, and I'm looking for something similar in XAMPP. When using IIS, I added multiple records to the Windows hosts file so I could access the locally hosted sites by typing friendly web-style addresses (like http://myproject1.dev)

谢谢.

推荐答案

格雷格,您快到了-您需要(如Moses所说的)来设置虚拟主机.

Greg, you're almost there--you need (like Moses said) to setup virtual hosts.

因此,如果您的Windows主机文件具有

So if your Windows hosts file has

127.0.0.1    localhost
127.0.0.1    mysite-dev.com
127.0.0.1    anothersite-dev.com

您的虚拟主机文件(httpd-vhosts.conf)可能类似于:

Your virtual hosts file (httpd-vhosts.conf) might look like:

<VirtualHost *:80>
  DocumentRoot C:/xampp/htdocs/
  ServerName localhost
</VirtualHost>

<VirtualHost *:80>

    ServerName mysite-dev.com

    DocumentRoot "C:/sites/mysite-dev"

    <Directory "C:/sites/mysite-dev">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

<VirtualHost *:80>

    ServerName anothersite-dev.com

    DocumentRoot "C:/sites/anothersite-dev"

    <Directory "C:/sites/anothersite-dev">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

进行任何更改后,请不要忘记重新启动Web服务器.

Don't forget to restart the web server after you make any changes.

这篇关于使用XAMPP托管多个本地站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆