解决apache启动错误"httpd:Could not reliably determine..."

来源:互联网 发布:九章算法 大数据 编辑:程序博客网 时间:2024/05/16 15:39

以下总结在配置及启动apache2时出现报错的处理方法

一、启动apache遇到错误:httpd: Could not reliably determine the server's fully qualified domain name

[root@server httpd-2.2.4]# /usr/local/apache/bin/apachectl start
 
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
 
1)进入apache的安装目录:(视个人安装情况而不同) [root@server ~]# cd /usr/local/apache/conf
 
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
3)再重新启动apache 即可。

[root@server ~]# /usr/local/apache/bin/apachectl restart


二、重启报错apache2 address already in use:make_sock:could not bind to address [::]:80

此错误为端口被占用,只有进入root用户,才可以查看所有端口被占用的情况。

$su

#netstat -lnp | grep 80

tcp 0      x x.x.x.x:8084        ...   listen   1167/mono

tcp 0      x x.x.x.x:80          ...   listen   1194/inetd

udp 0      x x.x.x.x:2080        ...   listen   14427/drcomauthsvr

查看知道是Inetd占用了80端口

#kill 1194

#exit //退出root用户

$sudo apapche2ctl -k start

启动成功!

三、在安装完apache2之后的默认index.html网页里面输入文字显示乱码,修改AddDefaultCharset 也没有用,即使在网页头部添加meta,指定charset=GB2312|GBK也没有用

注意,亲,此处因为默认文档的字号为h1,大号字体,中文无法显示,此处修改为小号字体即可,本人修改为h5,乱码消失,正常显示中文!

四、在网页运行html文件调用cgi程序时,提示找不到cgi程序以及找到程序后得不到想要的结果。

首先查看apache2配置文件,在/etc/apache2/site-enables查看系统默认的cgi-bin目录,可以在这个里面根据需要来修改默认cgi-bin目录。apt安装完后默认的cgi-bin目录是在/usr/lib/cgi-bin/

具体是修改ScriptAlias参数,如果你不知道你的类似site-enables的目录在哪,毕竟各个版本有些不一样,可以直接搜索ScriptAlisa这个参数,因为不管哪个版本,这个参数基本没改动。

        经过以上修改找到程序后,发现得不到想要的结果,那么可能是由于编译环境的差异造成的,这个时候可能要根据你的编译环境来修改你写的源代码。

0 0
原创粉丝点击