[Centos]编译安装apache 2.4

安装环境

本次安装使用Centos6.7最小化安装。
查看centos版本:

lsb_release -a
// 或者
rpm -q centos-release

编译环境

  • 根据安装软件不同,可能需要安装gcc perl python glibc gtk make automake
  • 已经安装了所依赖的包,但是系统找不到:
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
// 或者
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
  • 编译安装软件的方法:

大多以tar.gz 和tar.bz2打包软件,大多是通过 ./configure ;make ;make install 来安装的;有的软件是直接make;make install ;
我们可以通过./configure –help 来查看配置软件的功能;大多软件是提供./configure 配置软件的功能的;少数的也没有,如果没有的就不用./configure ;直接make;make install 就行了;
./configure 比较重要的一个参数是 –prefix ,用–prefix 参数,我们可以指定软件安装目录;当我们不需要这个软件时,直接删除软件的目录就行了;

安装步骤

# 当前下载apr-1.5.2.tar.bz2
tar -zxvf apr-x.x.x.tar.gz -C /usr/src/
cd /usr/src/apr-1.5.2
./configure --prefix=/usr/local/apr
make
make install
# 当前下载apr-util-1.5.4.tar.bz2
tar -zxvf apr-util-x.x.x.tar.gz -C /usr/src/
cd /usr/src/apr-util-1.5.4
./configure --prefix=/usr/local/apr-util
make
make install
  • openssl源码下载地址http://www.openssl.org/source/ 下载源码(出现configure: WARNING: OpenSSL version is too old;
    configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
# 当前下载openssl-1.0.0s.tar.gz
tar -zxvf openssl-x.x.x.tar.gz -C /usr/src/
cd openssl-1.0.0s
./config --prefix=/usr/local/openssl
make
make install

# 安装后仍提示错误
./config --prefix=/usr/local/openssl -fPIC no-gost no-shared no-zlib
make depend
make install
# 当前下载版本pcre2-10.10.tar.bz2
tar -zxvf pcre-x.x.tar.gz -C /usr/src/
cd /usr/src/pcre2-10.10
./configure --prefix=/usr/local/pcre
make
make install
  • 安装过程中,多次提示pcre的问题,可以试试执行:
yum install pcre-devel -y
  • 安装apache
# 当前下载使用:httpd-2.4.16.tar.bz2
tar -zxvf httpd-x.x.x.tar.gz -C /usr/src
./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --with-ssl=/usr/local/openssl
make
make install
  • 设置apache自动启动
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
chkconfig httpd on
# 提示服务不支持chkconfig
vi /etc/init.d/httpd
#!/bin/bash下增加
chkconfig:345 61 61 # 此行的345参数表示,在哪些运行级别启动,启动序号(S61);关闭序号(K61)
  • 打开apache的server-status和server-info
vi /usr/local/apache2/conf/httpd.conf
# 删除httpd-info.conf前#号
vi /usr/local/apache2/conf/extra/httpd-info.conf
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from localhost
</Location>

ExtendedStatus On

<Location /server-info>
    SetHandler server-info
    Order deny,allow
    Deny from all
    Allow from localhost
</Location>

参考文档:
1. 编译安装apache


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值