linux - 创建虚拟主机Centos

标签 linux apache centos

如何在cent os中创建虚拟主机?

我在/etc/httpd/conf/httpd.conf 文件中做了一些改动

<VirtualHost local.mydomain.com>
ServerAdmin webmaster@mydomain.com
DocumentRoot /var/www/html/test/
ServerName local.mydomain.com
ServerAlias local.mydomain.com
</VirtualHost>

在/etc/hosts 文件中

127.0.0.1       dexs01 localhost.localdomain6 localhost #existing lines
::1             localhost6.localdomain6 localhost #existing lines
127.0.0.1       local.mydomain.com       local.mydomain.com #my addition

然后我重新启动了我的 Apache 服务器 那么这有什么问题呢?

最佳答案

你必须在 VirtualHost 中定义指令 IP 和端口:

<VirtualHost *:80>
  ...
  ServerName local.mydomain.com
  ...
</VirtualHost>

其余的看起来不错。
注意:在您的情况下,您不需要 ServerAlias指令,因为它与您的 ServerName 匹配。

关于linux - 创建虚拟主机Centos,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8668612/

相关文章:

c - 在 Linux 中 "which source"什么都不返回?

javascript - 使用网页登录apache服务器

apache - 如何仅通过子域进行子文件夹独占访问

apache - 在 apache 2.4.x 上配置 mod_proxy_wstunnel

linux - 通过C程序写入文件

linux - 在 fedora 20 上安装 checkinstall

c - 为什么inbuf = xmalloc(insize + page_size - 1)?

java - 将 MultiPartFile 转换为 XWPFDocument

PHP脚本复制

dns - 百胜错误 - centos 7.1 x86_64