如何在 FreeBSD 上为 `apache22` 包配置主机名?

如何在 FreeBSD 上为 `apache22` 包配置主机名?

我正在 VM 上配置开发和测试 FreeBSD 机器。我安装了apache22软件包并重新启动。但守护进程没有启动,并出现以下错误:

%apachectl start
httpd: apr_sockaddr_info_get() failed for test.box
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
%

我的主机名是test.box。因为这是临时测试机,所以没有真正的域名。但我使用了2级名称以避免sshd启动时长时间等待。

但是,我搜索了网络,并修改了/etc/hosts这样的文件(我之前没有碰过这个文件):

# This is original configuration
#::1                    localhost localhost.my.domain
#127.0.0.1              localhost localhost.my.domain

# New configuration    
::1                     localhost test.box
127.0.0.1               localhost test.box
127.0.0.1               test.box test

现在 apache 失败并显示以下错误消息:

%apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using test.box for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
%

我不知道现在需要什么。请告诉我此错误的原因和解决方案。

- - (编辑) - -

权限错误是由于遗漏了 而导致的sudo

答案1

httpd: Could not reliably determine the server's fully qualified domain name, using test.box for ServerName

通常,这只是一个警告,而不是致命错误。可以通过将配置添加到文件来解决apache2.conf

ServerName yourserver.yourdomain.com

我看到有一个权限被拒绝的错误。请确保以超级用户身份调用启动脚本root。另外,请确保没有其他进程正在监听 apache 端口(默认 80)。

答案2

我找到了一个解决方案。/etc/hosts 文件配置不正确。这是正确的配置。

# This is original configuration
#::1                    localhost localhost.my.domain
#127.0.0.1              localhost localhost.my.domain

::1                     localhost.test.box localhost
127.0.0.1               localhost.test.box localhost
127.0.0.1               test.box test

相关内容