所以基本上我在我的服务器上创建子域时遇到问题。我在 Ubuntu 12.04 服务器上运行 apache2,并使用 No-IP.com 设置了动态 IP。
我有 mydomain.com 工作,但想创建 test.mydomain.com 指向我的 /var/www/ 目录(我的网站的所有内容都位于该目录)中的子文件夹。
我修改了apache vhosts 示例页面上的代码并将其放入我的 httpd.conf 文件中:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost localhost:80
<VirtualHost localhost:80>
DocumentRoot /var/www/
ServerName mydomain.com
# Other directives here
</VirtualHost>
<VirtualHost localhost:80>
DocumentRoot /var/www/test
ServerName test.mydomain.com
# Other directives here
</VirtualHost>
当我尝试重新启动服务时:
sudo /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
任何帮助是极大的赞赏。如果我忘记包含任何必要的信息,请告诉我。
更新 我尝试使用 *:80 但仍然出现错误,这就是我切换到 localhost 的原因。
sudo /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Thu Nov 21 15:03:51 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Thu Nov 21 15:03:51 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
更新我弄清楚发生了什么。我的 ports.conf 文件中有一个匹配的配置条目。一旦我删除它,一切正常。