编译安装httpd apache服务器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了编译安装httpd apache服务器相关的知识,希望对你有一定的参考价值。

一,下载源码包
1.1下载apr-util-1.6.1.tar.gz 和apr-1.6.3.tar.gz
http://apr.apache.org/
1.2下载httpd源码安装包httpd-2.4.33.tar.gz
http://httpd.apache.org/download.cgi
二,拷贝到服务器并解压
scp Downloads/httpd-2.4.33 [email protected]:/root
scp Downloads/apr- [email protected]:/root
tar -zxvf apr-1.6.3.tar.gz
tar -zxvf apr-util-1.6.1.tar.gz
tar -zxvf httpd-2.4.33.tar.gz
三,编译安装apr和apr-util
cp -r httpd-2.4.33 /usr/local/src
3.1安装apr
yum -y install gcc #安装gcc
cd apr-1.6.3
./configure --prefix=/usr/local/apr
make
make install
3.2安装apr-util
cd apr-util-1.6.1
./configure --with-apr=/usr/local/apr --prefix=/usr/local/apr-util
make
问题: xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录 #include <expat.h>

解决:缺少expat-devel包

    yum install expat-devel

make install
3.3 安装httpd
cd /usr/local/src/httpd-2.4.33/
./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all
问题1:checking for pcre-config... false
解决:yum -y install pcre-devel
问题2:checking for OpenSSL version >= 0.9.8a... FAILED
解决:yum install openssl-devel
make
问题3:make[2]: bison:命令未找到 make[2]: flex:命令未找到
解决:yum -y install bison flex

问题4:collect2: error: ld returned 1 exit status
make[2]: [htpasswd] 错误 1
make[2]: 离开目录“/usr/local/src/httpd-2.4.33/support”
make[1]: [all-recursive] 错误 1
make[1]: 离开目录“/usr/local/src/httpd-2.4.33/support”
make: [all-recursive] 错误 1

解决:在./configure后加上--with-include-apr后
cp -r apr-1.6.3 /usr/local/src/httpd-2.4.33/srclib/apr #拷贝apr

cp -r apr-util-1.6.1 /usr/local/src/httpd-2.4.33/srclib/apr-util 拷贝apr-util

./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all -with-included-apr

make install

四,启动测试

/usr/local/apache/bin/apachectl start #启动httpd
/usr/local/apache/bin/apachectl stop #停止httpd
/usr/local/apache/bin/apachectl restart #重启httpd
增加环境变量
vim /etc/profile
PATH=$PATH:/usr/local/apache/bin
apachectl start #启动httpd
apachectl stop #停止httpd
apachectl restart #重启httpd

cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd

/etc/init.d/httpd operation

ps -ef |grep httpd

root 18005 1 0 17:53 ? 00:00:00 /usr/local/apache/bin/httpd -k start 已开启

用浏览器访问http://yourip example http://10.100.5.57

技术分享图片

以上是关于编译安装httpd apache服务器的主要内容,如果未能解决你的问题,请参考以下文章

centos 服务器编译安装apache+php

centos7安装httpd服务编译安装apache要注意的事情

centos7安装httpd服务编译安装apache要注意的事情

编译安装Apache服务

Apache(httpd)的简介安装以及如何使用

Linux源码编译安装apache httpd2.4.48