1.下载 apache
http://mirror.bit.edu.cn/apache/httpd/
2.安装编译依赖包
yum install -y zlib-devel pcre pcre-devel apr apr-devel gcc
3.解压 编译 apche
# tar zxf httpd-2.2.31.tar.gz
# cd httpd-2.2.31
# ./configure \
--prefix=/usr/local/apache2 \ --with-included-apr \ --enable-so \ --enable-deflate=shared \ --enable-expires=shared \ --enable-rewrite=shared \ --with-pcre
# make && make install
4.启动
# /usr/local/apache2/bin/apachectl start
报错:
httpd: apr_sockaddr_info_get() failed for shiwei
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
原因:这个问题应该是没有在 /etc/httpd/conf/httpd.conf 中设定 ServerName。所以apache会用主机上的名称来取代,首先会去找 /etc/hosts 中有没有主机的定义。
解决办法:
(1)可以设定httpd.conf文件中的 ServerName,如下:ServerName localhost:80
(2)在 /etc/hosts 中填入自己的主机名称 bogon,如下:127.0.0.1 shiwei (用户名称)
报错:/usr/local/apache2/bin/apachectl: line 78: 17303 Segmentation fault (core dumped) $HTTPD -k $AR解决:重装 apache5.选项:1)列出静态模块/usr/local/apache2/bin/apachectl -M动态模块在 /apache2/modules/ 目录下静态模块在 /apache2/bin/httpd 里面2)列出静态模块 .c/usr/local/apache2/bin/apachectl -l3)测试配置文件/usr/local/apache2/bin/apachectl -t4)load 配置文件/usr/local/apache2/bin/apachectl graceful