apache環境配置 | httpd Could not reliably determine the server's fully qualified domain name
前言
作為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
參考資料
- php開啟與關閉錯誤提示適用於沒有修改php.ini的權限php技巧腳本之家
- 解決apache啟動錯誤:Could not reliably determine the server’s fully qualified domain name - CSDN博客
聯系作者
- CSDN博客:http://blog.csdn.net/u012104219
- 知乎專欄:https://zhuanlan.zhihu.com/frankfeekr
- Github:https://github.com/frank-lam
- Email:frank_lin@whu.edu.cn
如果你覺得不錯的話,不妨打賞一下,這樣我就有更大的動