我的 apache 虚拟主机设置有什么问题?
What is wrong with my apache Virtual host setup?
我已经像 apache 文档中显示的那样设置了虚拟主机:
NameVirtualHost Localhost:8080
<VirtualHost Localhost:8080>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot D:\Users\daniel_diezel\Apache24\htdocs
</VirtualHost>
<VirtualHost Localhost:8080>
ServerName www.otherdomain.tld
DocumentRoot D:\Users\daniel_diezel\Apache24\htdocs
</VirtualHost>
保存并启动 httpd.exe 后,启动 Apache 时出现以下错误:
`
(OS 10013)Der Zugriff auf einen Socket war aufgrund der Zugriffsrechte des Sockets unzulõssig。 : make_sock: 无法绑定到地址 0.0.0.0:80
没有可用的侦听套接字,正在关闭
无法打开日志`
但是,如果我将端口更改为 8080,它就可以正常工作了。
但问题不是,当 apache 启动时,当我在浏览器中键入 https://domain.ltd 时找不到服务器,但如果我选择 Localhost:8080,它会显示网站上的索引文件。
我能做些什么来修复它?
似乎有两个不同的问题。根据您的文件结构,我假设您使用的是 Windows.
端口使用
端口 80 可能已被使用。打开 CMD 并输入 netstat -ano
并找到除系统进程(通常为 PID 4)之外的所有使用端口 80 的进程。使用命令 tasklist
识别进程,并使用前面步骤中的端口 80 查找 PID。
现在打开您的任务管理器并停止所有与保留您的系统无关的进程 运行。现在端口绑定错误应该消失了。
访问本地域名
domain.tld 由您配置的 DNS 提供商解析,因此可以在互联网上查找。如果你想在本地解析域名(在访问 DNS 之前),你必须将它添加到你的主机文件中。
使用您选择的编辑器打开 C:/Windows/drivers/etc/hosts
并添加以下行:
127.0.0.1 domain.tld
现在一切都应该按预期工作。如果你想使用不同的端口,你也可以使用 127.0.0.1:port domain.tld
我已经像 apache 文档中显示的那样设置了虚拟主机:
NameVirtualHost Localhost:8080
<VirtualHost Localhost:8080>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot D:\Users\daniel_diezel\Apache24\htdocs
</VirtualHost>
<VirtualHost Localhost:8080>
ServerName www.otherdomain.tld
DocumentRoot D:\Users\daniel_diezel\Apache24\htdocs
</VirtualHost>
保存并启动 httpd.exe 后,启动 Apache 时出现以下错误:
`
(OS 10013)Der Zugriff auf einen Socket war aufgrund der Zugriffsrechte des Sockets unzulõssig。 : make_sock: 无法绑定到地址 0.0.0.0:80 没有可用的侦听套接字,正在关闭 无法打开日志`
但是,如果我将端口更改为 8080,它就可以正常工作了。 但问题不是,当 apache 启动时,当我在浏览器中键入 https://domain.ltd 时找不到服务器,但如果我选择 Localhost:8080,它会显示网站上的索引文件。 我能做些什么来修复它?
似乎有两个不同的问题。根据您的文件结构,我假设您使用的是 Windows.
端口使用
端口 80 可能已被使用。打开 CMD 并输入 netstat -ano
并找到除系统进程(通常为 PID 4)之外的所有使用端口 80 的进程。使用命令 tasklist
识别进程,并使用前面步骤中的端口 80 查找 PID。
现在打开您的任务管理器并停止所有与保留您的系统无关的进程 运行。现在端口绑定错误应该消失了。
访问本地域名
domain.tld 由您配置的 DNS 提供商解析,因此可以在互联网上查找。如果你想在本地解析域名(在访问 DNS 之前),你必须将它添加到你的主机文件中。
使用您选择的编辑器打开 C:/Windows/drivers/etc/hosts
并添加以下行:
127.0.0.1 domain.tld
现在一切都应该按预期工作。如果你想使用不同的端口,你也可以使用 127.0.0.1:port domain.tld