日期:2014-05-16  浏览次数:21317 次

设置一个虚拟主机在Apache

在Apache设置虚拟主机

Setting up a virtual host in the Apache web server is not exactly a PHP topic, but many PHP developers use the Apache web server to test web pages on their development machine.建立一个在Apache Web服务器的虚拟主机是不完全是一个PHP的话题,但是许多PHP开发人员使用Apache Web服务器,以测试他们的开发机器上的网页。

There is a lot of information around on how to do this, but the first time I tried it, I found the existing information to be more confusing than helpful.有一个要做到这一点很多资料市内如何,但我第一次试了一下,我发现了现有的信息更有助于混乱比。 Hopefully, this page will simplify the process a bit.我们希望,此网页将简化程序一点。 Please note that this information pertains to setting up a virtual host in Apache on a Windows machine for use as a local testing server.请注意,此信息关于设立作为测试服务器上的本地虚拟主机在Apache上使用的Windows机器。 Setting up a virtual host for an actual production server is beyond the scope of this article and you should refer to the official Apache documentation for that.实际生产中设置一个虚拟主机服务器超出了本文的范围,这一点,你应该参考官方Apache文件这样做的。

Configuring Apache配置Apache

The first file we'll need to edit is the Apache httpd.conf file.第一个文件,我们需要修改是Apache httpd.conf文件。 If you installed the Apache software using the download from the Apache web site , you should have a menu item that will open this file for editing.如果你安装了Apache软件下载使用从Apache网站 ,你应该有一个菜单项,将打开该文件进行编辑。 Click Start->Programs->Apache HTTP Server->Configure Apache Server->Edit the Apache httpd.conf Configuration File.单击开始->“程序-> Apache的HTTP服务器>”配置Apache服务器->“编辑Apache的httpd.conf配置文件。 If you don't have that start menu item, start your text editor and open the file.如果你没有这样的启动菜单项,启动文本编辑器并打开该文件。 It will be in a sub-folder named conf of your Apache folder.这将是在一个子文件夹命名为你的Apache conf文件夹。 For example, mine is here:例如,我是在这里:

C:\Program Files\Apache Group\Apache\conf\httpd.conf

Notes for Apache Server Versions Since 2.2为Apache Server版本说明自2.2

Configuration配置

Note that Apache changed the preferred method for configuring the Apache server with the release of Apache 2.2.请注意,改变了Apache的配置与2.2版本的Apache Apache服务器的首选方法。 For versions beginning with 2.2, the peferred configuration is more modular.对于版本2.2开始,peferred配置更模块化。 Setting up a virtual host as described here will still work with the newer versions, but to follow the