编译安装 apache2.4.12

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Evils798/article/details/51517062
编译安装apache2.4.12

1.准备工作

操作系统       RHEL 6.7
YUM            本地yum源
IP地址         192.168.10.10

准备好,apache包和其他依赖安装包,本案例tar安装包下载目录在/install

#cd  /install

用 wget从互联网下载安装包 

#wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz   
#wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz 
#wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip 
#wget http://archive.apache.org/dist/httpd/httpd-2.4.12.tar.gz

下载完成后,查看下载的文件,一共四个package
# ls -al 
-rw-r--r--   1 root root   994320 Feb 14  2012 apr-1.4.5.tar.gz
-rw-r--r--   1 root root   769076 May 21  2011 apr-util-1.3.12.tar.gz
-rw-r--r--   1 root root  6853506 Jan 28  2015 httpd-2.4.12.tar.gz
-rw-r--r--   1 root root  1409751 Jun 26  2010 pcre-8.10.zip

安装apache 2.4.12首先需要安装依赖包,否则在进行configure处理apache的时候会出现以下错误,报APR版本过低,如下:

# ./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-so --enable-headers --enable-expires --with-mpm=worker --enable-modules=most --enable-deflate
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... configure: WARNING: APR version 1.4.0 or later is required, found 1.3.9
configure: WARNING: skipped APR at apr-1-config, version not acceptable
no
configure: error: APR not found.  Please read the documentation.

2.删除旧的依赖包

删除旧版本的APR和自带的httpd

  2.1 查询系统自带rpm包

# rpm -qa | grep apr
apr-util-devel-1.3.9-3.el6_0.1.x86_64
apr-1.3.9-5.el6_2.x86_64
apr-util-1.3.9-3.el6_0.1.x86_64
apr-util-ldap-1.3.9-3.el6_0.1.x86_64
apr-devel-1.3.9-5.el6_2.x86_64

# rpm -qa | grep httpd
httpd-tools-2.2.15-45.el6.x86_64
httpd-2.2.15-45.el6.x86_64
httpd-devel-2.2.15-45.el6.x86_64


删除1.3.9的APR,同种方法删除自带的HTTPD

# rpm -e --nodeps apr-1.3.9-5.el6_2.x86_64
# rpm -e --nodeps apr-util-1.3.9-3.el6_0.1.x86_64
# rpm -e --nodeps apr-devel-1.3.9-5.el6_2.x86_64
# rpm -e apr-util-ldap-1.3.9-3.el6_0.1.x86_64
# rpm -e apr-util-devel-1.3.9-3.el6_0.1.x86_64


删除完成后再次使用rpm -qa 进行查询,无输出则删除成功


3.安装依赖包
                      
  3.1 安装apr
  
解压apr包,然后进入解压目录,进行编译安装,其他同理  
           
#tar -zxf apr-1.4.5.tar.gz

# cd apr-1.4.5

# ./configure --prefix=/usr/local/apr 

#make && make install

make install 无报错完成后,查看apr版本

#cd /usr/local/apr/bin

#./apr-1-config --version

1.4.5    #当前版本为1.4.5 

   3.2 安装apr-util
   
解压安装  apr-util
# tar zxvf apr-util-1.3.12.tar.gz 

进入加压目录,./congifure 编译安装

#cd apr-util-1.3.12

#./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config 

#make  && make install

    3.3 安装 pcre

#unzip -o pcre-8.10.zip   

#cd pcre-8.10
   
#./configure --prefix=/usr/local/pcre  
 
#make && make instal 


     3.4 安装apache

#tar zxvf httpd-2.4.12.tar.gz        

进入安装目录

#cd httpd-2.4.12

#./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-so --enable-headers --enable-expires --with-mpm=worker --enable-modules=most --enable-deflate


#make && make install

安装完成后,检查版本

# /etc/init.d/httpd  -version

Server version: Apache/2.4.12 (Unix)
Server built:   May 27 2016 14:05:45


查看安装后的目录,如下:

# tree -L 1 /usr/local/apache2/
/usr/local/apache2/
├── bin
├── build
├── cgi-bin
├── conf
├── error
├── htdocs
├── icons
├── include
├── logs
├── man
├── manual
└── modules


注:如果没有tree 命令,用本地的yum 安装一下即可  

#yum install -y tree                            

4.启动 apache                                           

将apache的启动脚本复制到/etc/rc.d/init.d目录下 
          
#cp /usr/local/apache2/bin/apachectl  /etc/init.d/httpd

启动 apache 

# /etc/init.d/httpd  start

查看启动状态

# ps -ef | grep httpd
root      3334     1  0 19:51 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    3335  3334  0 19:51 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    3336  3334  0 19:51 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    3337  3334  0 19:51 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    3338  3334  0 19:51 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
root      5465  2595  0 23:09 pts/0    00:00:00 grep httpd

使用浏览器输入 http://192.168.10.10 

显示
It Works!

表示已经启动成功


5. 启动脚本

启动脚本给出了启动命令的用法,从apache启动脚本看,apache启动是调用/usr/local/apache2/bin/httpd,

    $HTTPD -k $ARGV 启动是调用HTTPD='/usr/local/apache2/bin/httpd' 

# cat /etc/init.d/httpd|grep -v ^#|grep -v ^$        
ACMD="$1"                                                                
ARGV="$@"                                                                
HTTPD='/usr/local/apache2/bin/httpd'                                     
if test -f /usr/local/apache2/bin/envvars; then                          
  . /usr/local/apache2/bin/envvars                                       
fi                                                                       
LYNX="lynx -dump"                                                        
STATUSURL="http://localhost:80/server-status"                            
ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"                           
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then                                
    $ULIMIT_MAX_FILES                                                    
fi                                                                       
ERROR=0                                                                  
if [ "x$ARGV" = "x" ] ; then                                             
    ARGV="-h"                                                            
fi                                                                       
case $ACMD in                                                            
start|stop|restart|graceful|graceful-stop)                               
    $HTTPD -k $ARGV                                                      
    ERROR=$?                                                             
    ;;                                                                   
startssl|sslstart|start-SSL)                                             
    echo The startssl option is no longer supported.                     
    echo Please edit httpd.conf to include the SSL configuration settings
    echo and then use "apachectl start".                                 
    ERROR=2                                                              
    ;;                                                                   
configtest)                                                              
    $HTTPD -t                                                            
    ERROR=$?                                                             
    ;;                                                                   
status)                                                                  
    $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '      
    ;;                                                                   
fullstatus)                                                              
    $LYNX $STATUSURL                                                     
    ;;                                                                   
*)                                                                       
    $HTTPD "$@"                                                          
    ERROR=$?                                                             
esac                                                                     
exit $ERROR                                                              

猜你喜欢

转载自blog.csdn.net/Evils798/article/details/51517062
今日推荐