将子域指向 Apache 2 虚拟主机的问题?

Issues pointing a sub-domain at an Apache 2 virtual host?

我在让它工作时遇到了一些麻烦。现在 DNS 正在为我的域传播,所以我一直在使用常规 IP 地址,如果这有所不同的话。

在我的 /etc/hosts 文件中,我有以下...

ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

127.0.0.1 localhost.localdomain localhost
# Auto-generated hostname. Please do not remove this comment.
111.111.111.11 main.mydomain.com  main
111.111.111.11 git.mydomain.com
::1             localhost ip6-localhost ip6-loopback

我只在该文件中添加了一行,即 111.111.111.11 git.mydomain.com。当我得到这个 VPS 时,剩下的就在那里了。

我还创建了这个 Apache 配置文件 git.conf 并将其添加到 /etc/apache2/sites-available/...

<VirtualHost *:80>
        ServerName git.localhost
        ServerAdmin allen@localhost
        DocumentRoot /home/allen/Sites/Git
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

这只是 Apache 默认使用的 000-default.conf 文件的一个副本,删除了注释并更改了一些信息。

我有 运行 命令 sudo a2ensite git.conf 并重新启动了 Apache 服务器。

此处的目标是为虚拟主机提供服务,该虚拟主机具有用于在子域为 git.

时管理 Git 存储库的 Web 客户端

我在配置文件中有什么错误吗?为了实现此功能,我是否缺少一个步骤?

我认为您可能需要更改 apache conf 文件中的行

ServerName git.localhost

ServerName git.mydomain.com

我也要看看这个https://httpd.apache.org/docs/2.4/vhosts/examples.html