Apache2.4.39在CentOS6.10上编译安装

目录

Apache2.4.39在CentOS6.10上编译安装

安装过程
安装过程

第一步:安装开发环境。这是编译安装都需要的步骤。

 yum groupinstall “Development Tools” “Server Platform Development” 

第二步:安装pcre-devel ,通过yum

 yum -y install pcre-devel

第三部:安装apache用到的库文件
(1)apr

        tar xf apr-1.7.0.tar.bz2
	    cd apr
	    ./configure –prefix=/usr/local/apr
        make && make install

(2)apr-util
首先安装expat-devel,否则会报
xml/apr_xml.c:35:19: 错误:expat.h:没有那个文件或目录

 		yum install -y  expat-devel

安装apr-util

		tar xf apr-util-1.6.1.tar.bz2 
        cd apr-util-1.6.1
        ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
        make && make install

第四步:创建用户和组(如果没有的话)
首先使用

		cat /etc/group
		cat /etc/passwd

如果不存在

		groupadd -r apache
        useradd -r -g apache apache

第五步:
对apr1.7和apr-util1.6以上,拷贝解压好的apr和apr-util安装目录全部文件到httpd解压目录下srclib中。我的apache,apr,apr-util都在家目录。

		~#cp -r apr-1.7.0 httpd-2.4.39/srclib/apr
		~#cp -r apr-util-1.6.1 httpd-2.4.39/srclib/apr-util

第六步:编译Apache

		cd httpd-2.4.39
		./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-zlib --enable-modules=most --enable-mpms-shared=all --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-included-apr

–with-included-apr这个选项重要,是跟第五步有关,不加此选项make会报

		 make[2]: [htpasswd] 错误 1

这个错误网上解决方法很多不能适用,估计是版本问题。

最后编译安装

          make && make install

第七部
使用apachectl启动服务时需要修改的

         [root@localtest12:07:53 /etc/profile.d]# vim httpd.sh
              export PATH=/usr/local/apache/bin:$PATH
         [root@localtest12:08:23 /etc/profile.d]# . httpd.sh
         [root@localtest12:09:28 /etc/profile.d]# echo $PATH
         /usr/local/apache/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
         [root@localtest12:09:32 /etc/profile.d]# which apachectl
         /usr/local/apache/bin/apachectl
填坑
填坑
  • 坑一:

编译会报错:
checking for APR… no
configure: error: APR not found. Please read the documentation.
解决方法
CentOS6上带的apr和apr-util版本太旧,只适合apache2.2,必须编译安装高版本的。

  • 坑二:

编译时报错:
xml/apr_xml.c:35:19: 错误:expat.h:没有那个文件或目录
xml/apr_xml.c:66: 错误:expected specifier-qualifier-list before ‘XML_Parser’
xml/apr_xml.c: 在函数‘cleanup_parser’中:
解决方法:
安装expat-devel,使用yum就可以。yum install -y expat-devel

  • 坑三:

configure出现下面报错:
checking which MPM to use by default… event
configure: error: MPM most does not support dynamic loading.
解决方法:
将配置中–enable-mpms-shared=most改成all

  • 坑四:

编译报错:
make[2]: [htpasswd] 错误 1
make[2]: Leaving directory `/usr/local/httpd-2.4.32/support’
make[1]: [all-recursive] 错误 1
解决方法:
见上第五、六步
对apr1.7和apr-util1.6以上,拷贝解压好的apr和apr-util安装目录全部文件到httpd解压目录下srclib中。–with-included-apr加上。

  • 坑五:

报错:configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
解决方法:
yum install -y pcre-devel

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值