1、源码包的安装过程:

(1).上网下载.gz后缀文件 (2).打开WinSCP连接Linux 和 win7,解压缩源码包: tar -zxvf httpd-2.4.33.tar.gz (3).进入解压缩目录 :cd httpd-2.4.33/ (4).输入 ./configure --prefix=/usr/local/apache2 此时报错: checking for pcre-config... false configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ 解决办法: [root@www.linuxidc.com httpd-2.4.1]# yum -y install pcre-devel

./configure 软件配置与检查 定义需要的功能选项 检查系统环境是否符合预装要求 把定义好的功能选项和检测系统环境的信息都写入Makefile文件,用于后续的编辑

(5).编译 make make clean make install 编译安装

此时报错: mod_proxy_balancer.c:25:24: fatal error: apr_escape.h: No such file or directory 原因是 开始没有编译安装apr和apr-util。 解决办法有两个。 第一个是禁止该模块。(来自:http://www.wanjishu.com/p/zn6v8T180330.html) 跳过该错误,后期指定该模块,一般安装不成功,推荐解决该问题; 或者编译参数可以去掉该模块,禁止该模块,添加--disable-proxy; 更换软件版本,考虑到操作系统和软件兼容性问题;

第二个解决办法就是编译安装apr和apr-util(原文地址:http://blog.51cto.com/11060853/2105497) 上面使用的办法,详情: http://www.mamicode.com/info-detail-2263097.html 结果使用这个方式时又报错: rm: cannot remove 'libtoolT': No such file or directory config.status: execu 编辑configure这个文件,将 $RM “$cfgfile” 那行注释掉 ,然后重新编译即可。 然而,等我解决完这些问题之后,再去编译,同样报哪个错误,遂用第一个方法,成功。 ./configure --prefix=/usr/local/apache2 --disable-proxy

(6).运行httpd: /usr/local/apache2/bin/apachectl start 报错: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/apache2/bin/apachectl start restart

(7).关闭防火墙 centos从7开始默认用的是firewalld,这个是基于iptables的,虽然有iptables的核心,但是iptables的服务是没安装的。所以你只要停止firewalld服务即可: sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service 用浏览器打开虚拟机Linux系统地址,如果显示It work!则成功