记录一下第一次源码安装httpd
操作系统:CentOS 6.5最小化安装(VMware)
准备工作:
1关闭iptables:
service iptables stop
chkconfig iptables off
验证是否关闭
iptables -vnL
2:关闭selinux
setenforce 0
vi /etc/selinux/config
修改红框部分
验证是否关闭
getenforce
3:yum安装一些准备软件,需要gcc编译器,rzsz传输工具(因为源码包我保存在Windows本地,这款软件能够实现Windows到Linux系统之间的文件传输),vim编辑器
yum -y install gcc* lrzsz vim
4:检查系统时间,因为要上传安装源码包,系统的时间要跟源码包的时间一致,不能使源码包的时间超前于系统时间
date
时间不太准确,
这里我将自己本地PC设置为NTP服务器(参考:http://www.jb51.net/os/windows/131624.html)
CentOS上NTP同步一下时间
5使用rz命令把保存在本地的源码包上传到Linux
源码包下载地址:
http://apr.apache.org/
http://mirrors.hust.edu.cn/apache/httpd/
==============================正式编译
# tar xf apr-1.4.6.tar.bz2
# cd apr-1.4.6
# ./configure --prefix=/usr/local/apr
# make && make install
(2) 编译安装apr-util
# tar xf apr-util-1.5.2.tar.bz2
# cd apr-util-1.5.2
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make && make install
(3)编译安装httpd,由于httpd编译过程需要依赖pcre-devel软件包否则会报错libpcre not found的错
,因此我们先yum安装
#yum -y install pcre-devel
# tar xf httpd-2.4.6.tar.bz2
# cd httpd-2.4.6
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=most --with-mpm=event
# make && make install
结果编译的时候报错:出现configure: WARNING: OpenSSL version is too old;checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures;
解决方法:
openssl源码下载地址http://www.openssl.org/source/ 下载源码
#tar -xf openssl-1.0.2.tar.gz
#cd openssl-1.0.2
# ./config --prefix=/usr/local/openssl
# make & make install
再次编译
# cd httpd-2.4.6
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --enable-mods-shared=most --with-mpm=event --with-ssl=/usr/local/openssl
# make && make install
结果编译的时候报错如下
/usr/bin/ld: /usr/local/openssl/lib/libssl.a(s3_srvr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/openssl/lib/libssl.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[4]: *** [mod_ssl.la] Error 1
make[4]: Leaving directory `/root/httpd-2.4.6/modules/ssl'
make[3]: *** [shared-build-recursive] Error 1
make[3]: Leaving directory `/root/httpd-2.4.6/modules/ssl'
make[2]: *** [shared-build-recursive] Error 1
make[2]: Leaving directory `/root/httpd-2.4.6/modules'
make[1]: *** [shared-build-recursive] Error 1
make[1]: Leaving directory `/root/httpd-2.4.6'
make: *** [all-recursive] Error 1
网上查找到(http://www.linuxidc.com/Linux/2014-10/107919p2.htm)
openssl重新编译
openssl编译:
./config --prefix=${destination_dir} -fPIC no-gost no-shared no-zlib
make depend ; make install
再次编译httpd
==============================================稍做修改
一般pid文件放置在如下位置,但是可以看到httpd编译完之后并没有放置于此
ls /var/run/