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

时间:2016-05-14 22:00:35

标签: apache dns apache2 subdomain virtualhost

我在上班时遇到了一些麻烦。现在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存储库。

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

1 个答案:

答案 0 :(得分:1)

我认为在apache conf文件中你可能需要更改行

  

ServerName git.localhost

  

ServerName git.mydomain.com

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

相关问题