无法可靠地确定服务器的完全限定域名
我刚刚安装了 Apache 2.2.17,这是我第一次使用它。
现在,当我尝试使用命令 service httpd start
启动服务器时,它会显示以下消息:
httpd:无法可靠地确定服务器的完全限定域名,使用 ::1 作为 ServerName
现在我想我必须在通过 Google 搜索时设置 ServerName 和 IP 地址。但我不知道我必须在哪个文件中设置。
我该如何解决这个问题?
I have just installed Apache 2.2.17, and I am using it for the first time.
Now when I try to start the server using the command service httpd start
it gives me the message:
httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName
Now I think I have to set ServerName and the IP address as I search through Google. But I don't know in which file I have to set.
How can I fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
sudo vim /etc/apache2/httpd.conf
ServerName localhost
sudo /etc/init.d 即可。 d/apache2 重新启动
sudo vim /etc/apache2/httpd.conf
ServerName localhost
sudo /etc/init.d/apache2 restart
是的,您应该设置 ServerName:
http://wiki.apache.org/httpd/CouldNotDetermineServerName
http://httpd.apache.org/docs/current/mod/core.html#servername
可以找到有关各种使用的布局的信息httpd 发行版在这里:
http://wiki.apache.org/httpd/DistrosDefaultLayout
在您的情况下,要编辑的文件是 /等/httpd/conf/httpd.conf
Yes, you should set ServerName:
http://wiki.apache.org/httpd/CouldNotDetermineServerName
http://httpd.apache.org/docs/current/mod/core.html#servername
You can find information on the layouts used by the various httpd distributions here:
http://wiki.apache.org/httpd/DistrosDefaultLayout
In your case the file to edit is /etc/httpd/conf/httpd.conf
我没有弄错服务器名称。在导致此警告消息的 VirtualHost 配置中,它是 httpd.conf 顶部附近的通用配置,默认情况下注释。
更改
为:
I was NOT getting the ServerName wrong. Inside your VirtualHost configuration that is causing this warning message, it is the generic one near the top of your httpd.conf which is by default commented out.
Change
to:
在 Debian Squeeze 下;
应该可以正常工作(它确实解决了问题就我而言)
tks noodl 不同布局上的链接。 :)
Under Debian Squeeze;
Should work fine (it did solve the problem in my case)
tks noodl for the link on the different layouts. :)
sudo nano /etc/apache2/httpd.conf
ServerName
ServerName localhost
sudo /usr/sbin/apachectl restart
sudo nano /etc/apache2/httpd.conf
ServerName
in nano editor<Ctrl + W>
ServerName localhost
sudo /usr/sbin/apachectl restart
" 要解决这个问题,需要设置ServerName。
1:
$ vim /etc/apache2/conf.d/name
例如设置添加 ServerName localhost 或任何其他名称:
2: ServerName localhost
重新启动 Apache 2
3:
$ service apache restart
在本示例中,我使用 Ubuntu 11.10.1.125"
" To solve this problem You need set ServerName.
1:
$ vim /etc/apache2/conf.d/name
For example set add ServerName localhost or any other name:
2: ServerName localhost
Restart Apache 2
3:
$ service apache restart
For this example I use Ubuntu 11.10.1.125"
另一种选择是确保完全限定主机名 (FQDN) 列在 /etc/hosts 中。
这对我在 Ubuntu v11.10 上有效,无需更改默认的 Apache 配置。
Another option is to ensure that the full qualified host name (FQDN) is listed in /etc/hosts.
This worked for me on Ubuntu v11.10 without having to change the default Apache configuration.
FQDN 表示通过 DNS 解析的名称。它应该类似于“服务器名称.搜索域”。
您收到的警告只是通知 httpd 无法找到 FQDN,因此它可能无法正常处理基于名称的虚拟主机。因此,请确保在您的 DNS 服务器中注册了预期的 FQDN,或者在点击 DNS 之前在
/etc/hosts
中手动添加条目。FQDN means the resolved name over DNS. It should be like "server-name.search-domain".
The warning you get just provides a notice that httpd can not find a FQDN, so it might not work right to handle a name-based virtual host. So make sure the expected FQDN is registered in your DNS server, or manually add the entry in
/etc/hosts
which is prior to hitting DNS.如果您使用的是 Windows,则会出现不同的情况,
首先打开
c:/apache24/conf/httpd.conf
。Apache 文件夹就足够了,不需要特别指定上面的路径
,之后您必须配置 httpd.conf 文件。
几行之后,出现如下模式:
Here You have to change for the
localhost
。您必须输入 ipv4 地址才能打开 localhost。
请参阅此视频链接,然后再了解更多内容。
更改您的环境变量:
您必须在其中输入路径:
和
系统变量中相同
如果有任何疑问,请随时询问。
If you are using windows there is something different sort of situation
First open
c:/apache24/conf/httpd.conf
.The Apache folder is enough not specifically above path
After that you have to configure httpd.conf file.
Just after few lines there is pattern like:
Here You have to change for the
localhost
.You have to enter ipv4 address for that you can open localhost.
Refer this video link and after that just bit more.
Change your environment variables:
In which you have to enter path:
and
same in the SYSTEM variables
If any query feel free to ask.
有两件事似乎对我有用:
127.0.0.1 localhost mysite.local myothersite.local
ServerName< /code> 在我的 httpd.conf 中改为
0.0.0.0
(localhost 或 127.0.0.1 对我来说不起作用)编辑 /etc/hosts 摆脱了长响应时间并设置 ServerName 摆脱了OP对我的警告。
Two things seemed to do it for me:
127.0.0.1 localhost mysite.local myothersite.local
ServerName
in my httpd.conf to0.0.0.0
(localhost or 127.0.0.1 didn't work for me)Editing /etc/hosts got rid of long response times and setting the ServerName got rid of OP's warning for me.
如果仍然无法解决问题并使用 mac,请按照此操作
1.转到根文件夹 /
3.sudo nano httpd.conf
4.change #servername 为 ServerName 127.0.0.1:8080 按ctrl+o,+return+ctrl x
5.然后重启服务器 apachectl restart
who are still couldnt resolve the problem and using mac then follow this
1.goto the root folder /
3.sudo nano httpd.conf
4.change #servername to ServerName 127.0.0.1:8080 press ctrl+o,+return+ctrl x
5.then restart the server apachectl restart
如果您使用的是 Windows,请删除这些行上的注释并将它们设置为:
为我工作!
If you are using windows, remove comment on these lines and set them as:
Worked for me!
这是我的两分钱。也许这对未来的读者有用。
我在 Docker 容器中使用 Apache 时遇到了这个问题。当我从 Apache Web 服务器的映像启动容器时,当我使用 docker run -it -p 80:80 my-apache-container 启动容器时出现此消息。
但是,在分离模式下启动容器后,使用 docker run -d -p 80:80 my-apache-container ,我能够通过浏览器进行连接。
Here's my two cents. Maybe it's useful for future readers.
I ran into this problem when using Apache within a Docker container. When I started a container from an image of the Apache webserver, this message appeared when I started it with
docker run -it -p 80:80 my-apache-container
.However, after starting the container in detached mode, using
docker run -d -p 80:80 my-apache-container
, I was able to connect through the browser.我使用的是 ubuntu 22.04
我在位置 '/usr/local/apache2' 安装了 apache2
我刚刚编辑了 '/usr/local/apache2/conf/httpd.conf' 文件。
运行以下命令
cd /usr/local/apache2/conf
sudo nano httpd.conf
找到此注释
#ServerName www.example.com:80,在我的例子中,它位于第 197 行
,之后添加此
ServerName localhost >
不要修改此文件中的任何其他内容!
谢谢!
I am using ubuntu 22.04
I installed the apache2 at the location '/usr/local/apache2'
I just edited the '/usr/local/apache2/conf/httpd.conf' file.
run the following commands
cd /usr/local/apache2/conf
sudo nano httpd.conf
find this comment
#ServerName www.example.com:80, in my case it is at line 197
after that add this
ServerName localhost
don't modify anything else in this file!
Thank you!
尝试去做吧。
vi /etc/hosts
添加此行,
而不是 0.0.0.0,输入您的服务器的 IP 地址
Try to do it.
vi /etc/hosts
add this line
Instead of 0.0.0.0 put your IP address of the server
出现以下错误,可能是由于权限问题,以 root 身份重新启动 apache 并且成功了!
Had the following error, it could be due to permissions, had restarted apache as root and it worked!