简体   繁体   English

在Apache上配置虚拟主机

[英]Configure virtual host on Apache

I have a VPS with a single IP address and with Virtualmin/Webmin installed. 我有一个具有单个IP地址并安装了Virtualmin / Webmin的VPS。 I have created a virtual host *example.com *that will answer to www.example.com (the domain already points to the IP address of the VPS). 我创建了一个虚拟主机* example.com *,它将回答www.example.com (域已经指向VPS的IP地址)。 However, when I access www.example.com I am not seeing the website I have uploaded for example.com but rather the default server: 但是,当我访问www.example.com时,我看不到为example.com上传的网站,而是默认服务器:

It works! 有用!

This is the default web page for this server. 这是此服务器的默认网页。

The web server software is running but no content has been added, yet. Web服务器软件正在运行,但尚未添加任何内容。

What should I do? 我该怎么办? Do I have to configure DNS or something? 我是否必须配置DNS或其他内容?

Yes, you will need to configure DNS for your www.* site if it has not been done already. 是的,如果尚未配置www。*网站,则需要为其配置DNS。 This www.* alias may have been created automatically when you set up the domain in DNS, but perhaps you will need to specify it explicitly. 当您在DNS中设置域时,该www。*别名可能是自动创建的,但是也许您需要明确指定它。

Seeing the message "It works!" 看到消息“它有效!” is a common issue. 是一个普遍的问题。 Apache has a default virtual host which you may want to disable. Apache具有您可能要禁用的默认虚拟主机。 Exactly how to do that depends on the platform of your web server (it's a good idea to mention the platform and version when asking questions). 确切的操作方式取决于您的Web服务器的平台(在提出问题时最好提及平台和版本)。

For example, if you have shell access to a Debian or Ubuntu machine, you can use the command: 例如,如果您具有对Debian或Ubuntu计算机的shell访问权限,则可以使用以下命令:

sudo a2dissite default sudo a2dissite默认

In virtualmin there may also be an option for this, see for example http://www.virtualmin.com/node/15854 在virtualmin中,可能还有一个选项,例如,参见http://www.virtualmin.com/node/15854

Once you have DNS set up and the www.* domain responding correctly to pings with IP of your server, you will also need to make sure that the virtual host definition for your site includes the www.* alias. 一旦设置了DNS,并且www。*域正确响应了使用服务器IP的ping,您还需要确保站点的虚拟主机定义包括www。*别名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM