apache环境配置 | httpd Could not reliably determine the server's fully qualified domain name

时间:2023-03-09 00:46:22
apache环境配置 | httpd Could not reliably determine the server's fully qualified domain name

apache环境配置 | httpd Could not reliably determine the server's fully qualified domain name

 转 https://blog.****.net/u012104219/article/details/79853797

前言

作为php开发者,你是否遇到这种情况。经常我们会在Linux系统上通过php do.php命令进行程序调试。有时候明明通过命令行方式调试程序成功后,却发现在浏览器请求我们的www.test.com/../do.php却不能够成功执行,报500错误。

这时候执行service httpd restart重启web服务

启动apache遇到错误:“Starting httpd: httpd Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain for ServerName”。 
其实浏览器出现500错误,意味着你没有配置服务可依靠的域名,无需改动你的程序,只要修改配置文件即可。

哎,第一次遇到这个问题,最近还是用的VPN连上服务器,还一直以为是网络的问题,晕死了。。。好难过,不过还好解决了,特别记录这篇博文以便备忘和学习。

正确解决的步骤

1.打开你的httpd.conf配置文件(我的环境环境:vi /etc/httpd/conf/httpd.conf),如果不知道httpd.conf文件在哪里,可以通过打印phpinfo()函数来查看,或者cd /之后通过’locate php.ini’命令进行查找定位。

2.编辑httpd.conf文件,搜索”#ServerName”,添加ServerName localhost:80

[root@server conf]# ls
extra httpd.conf magic mime.types original
[root@server conf]# vi httpd.conf
#ServerName www.example.com:80
ServerName localhost:80
  • 1
  • 2
  • 3
  • 4
  • 5

3.重启服务service httpd restart提示如下两个OK则配置成成功。

Stopping httpd: [  OK  ]
Starting httpd: [ OK ]
  • 1
  • 2

4.在浏览器打开你的网页,即可成功运行。

5.php如何开启报错提醒? 
* 修改php.ini文件,display_errors = Off修改为display_errors = On

参考资料

联系作者

如果你觉得不错的话,不妨打赏一下,这样我就有更大的动