centos中apache使用问题

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

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

[[email protected] 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的安装目录:(视个人安装情况而不同) [[email protected] ~]# cd /usr/local/apache/conf
 
2)编辑httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80

[[email protected] conf]# ls  extra  httpd.conf  magic  mime.types  original  [[email protected] conf]# vi httpd.conf  #ServerName www.example.com:80  ServerName localhost:80  

3)再重新启动apache 即可。

[[email protected] ~]# /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也没有用

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

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

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

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

原文出处:csdn -> https://blog.csdn.net/yqj234/article/details/83019841

本站所发布的一切资源仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如果侵犯你的利益,请发送邮箱到 [email protected],我们会很快的为您处理。