码迷,mamicode.com
首页 > Web开发 > 详细

编译安装httpd apache服务器

时间:2018-04-19 18:22:13      阅读:370      评论:0      收藏:0      [点我收藏+]

标签:编译安装httpd

一,下载源码包
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 root@10.100.5.57:/root
scp Downloads/apr- root@10.100.5.57:/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服务器

标签:编译安装httpd

原文地址:http://blog.51cto.com/13564078/2105494

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!