以下总结在配置及启动 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 http://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 这个参数,因为不管哪个版本,这个参数基本没改动。
经过以上修改找到程序后,发现得不到想要的结果,那么可能是由于编译环境的差异造成的,这个时候可能要根据你的编译环境来修改你写的源代码。
相关文章
- ThinkPad x13 Gen1傲腾H10重装系统的麻烦(0)
- Win10系统电脑进入安全模式的四种方法,让你轻松应对各种问题(0)
- 使用Jetson_benchmark进行性能测试(0)
- 【Python】修改Windows中 pip 的缓存位置与删除 pip 缓存(1)
- 记录问题解决的连接(0)