[Centos]编译安装apache 2.4

来源:互联网 发布:耳机声音放大器软件 编辑:程序博客网 时间:2024/06/06 01:58

安装环境

本次安装使用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 参数,我们可以指定软件安装目录;当我们不需要这个软件时,直接删除软件的目录就行了;

安装步骤

  • 去http://httpd.apache.org/download 下载apache源码
  • apr下载地址 http://apr.apache.org/下载源码(出现configure: error: APR not found)
# 当前下载apr-1.5.2.tar.bz2tar -zxvf apr-x.x.x.tar.gz -C /usr/src/cd /usr/src/apr-1.5.2./configure --prefix=/usr/local/aprmakemake install
  • 去apr-util下载地址 http://apr.apache.org/ 下载源码(出现configure: error: APR-util not found)
# 当前下载apr-util-1.5.4.tar.bz2tar -zxvf apr-util-x.x.x.tar.gz -C /usr/src/cd /usr/src/apr-util-1.5.4./configure --prefix=/usr/local/apr-utilmakemake 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.gztar -zxvf openssl-x.x.x.tar.gz -C /usr/src/cd openssl-1.0.0s./config --prefix=/usr/local/opensslmakemake install# 安装后仍提示错误./config --prefix=/usr/local/openssl -fPIC no-gost no-shared no-zlibmake dependmake install
  • 去pcre下载地址 http://pcre.org/下载源码。
# 当前下载版本pcre2-10.10.tar.bz2tar -zxvf pcre-x.x.tar.gz -C /usr/src/cd /usr/src/pcre2-10.10./configure --prefix=/usr/local/pcremakemake install
  • 安装过程中,多次提示pcre的问题,可以试试执行:
yum install pcre-devel -y
  • 安装apache
# 当前下载使用:httpd-2.4.16.tar.bz2tar -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/opensslmakemake install
  • 设置apache自动启动
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpdchkconfig httpd on# 提示服务不支持chkconfigvi /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
原创粉丝点击