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

查看:16
本文介绍了使用 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)

谢谢.

推荐答案

Greg,你快到了——你需要(就像 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>

进行任何更改后不要忘记重新启动网络服务器.

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

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

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