apache源码安装过程

-----------------------------------------------

一、前言

二、环境

 1.系统

 2.源码包

三、安装配置

 1.安装开发工具

 2.卸载RPM包

 3.安装pcre-devel

 4.安装apr

 5.安装apr-util

 6.安装httpd

四、测试

 1.启动

 2.编写脚本

-----------------------------------------------


一、前言

   Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,是世界使用排名第一的Web服务器软件,可以在大多数计算机操作系统中运行,由于其多平台和安全性被广泛使用,是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩展,将Perl/Python等解释器编译到服务器中。

二、环境

1.系统

 CentOS6.4 32位

2.源码包

 apr-1.4.6.tar.gz

 apr-util-1.5.1.tar.gz

 httpd-2.4.4.tar.bz2

源码包下载地址http://pan.baidu.com/s/1iWmdA

三、安装配置

1.安装开发工具

[root@localhost ~]# yum groupinstall "Development tools"
[root@localhost ~]# yum groupinstall "Additional Development"

2.卸载RPM包

[root@localhost ~]# rpm -qa |grep httpd
httpd-tools-2.2.15-26.el6.centos.i686
httpd-2.2.15-26.el6.centos.i686
[root@localhost ~]# yum remove httpd

3.安装pcre-devel

[root@localhost httpd-2.4.4]# yum list all |grep pcre
pcre.i686          7.8-6.el6     @anaconda-CentOS-201303020136.i386/6.4
pcre-devel.i686    7.8-6.el6     c6-media
pcre-static.i686   7.8-6.el6     c6-media
[root@localhost httpd-2.4.4]# yum install pcre-devel

4.安装apr

[root@localhost ~]# tar -zxvf apr-1.4.6.tar.gz -C /usr/local/src/
[root@localhost ~]# tar -zxvf apr-util-1.5.1.tar.gz -C /usr/local/src/
[root@localhost ~]# tar -jxvf httpd-2.4.4.tar.bz2 -C /usr/local/src/
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# cd apr-1.4.6/
[root@localhost apr-1.4.6]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.4.6]# make && make install

 配置库文件

[root@localhost apr-1.4.6]# cd /usr/local/apr
[root@localhost apr]# ls
bin  build-1  include  lib
[root@localhost apr]# cd lib/
[root@localhost lib]# ls
apr.exp  libapr-1.a  libapr-1.la  libapr-1.so  libapr-1.so.0  libapr-1.so.0.4.6  pkgconfig
[root@localhost lib]# vim /etc/ld.so.conf.d/apr.conf
    /usr/local/apr/lib
[root@localhost lib]# ldconfig

 配置头文件

[root@localhost lib]# cd ../include/apr-1/
[root@localhost apr-1]# ls
apr_allocator.h  apr_general.h  apr_network_io.h  apr_signal.h    ......
[root@localhost apr-1]# cd /usr/include/
[root@localhost include]# ln -s /usr/local/apr/include/apr-1/ apr
[root@localhost include]# ll apr
lrwxrwxrwx. 1 root root 29 Feb 13 18:59 apr -> /usr/local/apr/include/apr-1/

5.安装apr-util

[root@localhost apr-1.4.6]# cd ../apr-util-1.5.1/
[root@localhost apr-util-1.5.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[root@localhost apr-util-1.5.1]# make && make install

 配置库文件

[root@localhost apr-util-1.5.1]# cd /usr/local/apr-util/
[root@localhost apr-util]# ls
bin  include  lib
[root@localhost apr-util]# cd lib/
[root@localhost lib]# ls
apr-util-1  libaprutil-1.la  libaprutil-1.so.0.5.1  libexpat.so  ......
[root@localhost lib]# vim /etc/ld.so.conf.d/apr-util.conf
    /usr/local/apr-util/lib
[root@localhost lib]# ldconfig

 配置头文件

[root@localhost lib]# cd ../include/apr-1/
[root@localhost apr-1]# ls
apr_anylock.h  apr_hooks.h        apr_md5.h       apr_sdbm.h    .......
[root@localhost apr-1]# pwd
/usr/local/apr-util/include/apr-1
[root@localhost apr-1]# cd /usr/include/
[root@localhost include]# ln -s /usr/local/apr-util/include/apr-1/ apr-util
[root@localhost include]# ll apr-util
lrwxrwxrwx. 1 root root 34 Feb 13 19:09 apr-util -> /usr/local/apr-util/include/apr-1/

6.安装httpd

[root@localhost apr-util-1.5.1]# cd ../httpd-2.4.4/
[root@localhost httpd-2.4.4]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr-util/bin/apu-1-config
[root@localhost httpd-2.4.4]# make && make install

配置头文件

[root@localhost httpd-2.4.4]# cd /usr/local/apache/
[root@localhost apache]# ls
bin  build  cgi-bin  error htdocs icons include logs man manual  modules
[root@localhost apache]# cd include/
[root@localhost include]# ls
apache_noprobes.h   ap_release.h       http_vhost.h   .....
[root@localhost include]# pwd
/usr/local/apache/include
[root@localhost include]# cd /usr/include/
[root@localhost include]# ln -s /usr/local/apache/include/ apache
[root@localhost include]# ll apache
lrwxrwxrwx. 1 root root 26 Feb 13 19:18 apache -> /usr/local/apache/include/

配置man手册

[root@localhost include]# cd /usr/local/apache/man
[root@localhost man]# ls
man1  man8
[root@localhost man]# vim /etc/man.config
  48 MANPATH /usr/local/apache/man   //添加到48行

四、测试

1.启动

[root@localhost ~]# cd /usr/local/apache/bin
[root@localhost bin]# ./httpd -k start
[root@localhost bin]# netstat -tupln |grep 80
tcp     0      0 :::80       :::*      LISTEN      20027/./httpd

wKiom1L9moSCrGmdAACEuV1DKek695.jpg

2.编写脚本

[root@localhost bin]# cd /etc/init.d/
[root@localhost init.d]# vi httpd


#!/bin/bash
[ -e /etc/init.d/functions ]  &&  . /etc/init.d/functions
prog=/usr/local/apache/bin/httpd
lockfile=/var/lock/subsys/httpd
start () {
     if [ -e $lockfile ];then
       echo "Started httpd."
     else
         echo "Starting httpd:"
         sleep 1
         $prog && echo  "ok" && touch $lockfile
     fi
}
stop () {
     if [ ! -e $lockfile ];then
       echo "Stoped httpd."
     else
       echo -n "Stopping httpd:"
       sleep 1
       killproc  httpd && echo "ok" && rm -rf $lockfile || echo "failer"
     fi
}
status () {
         if [ -e $lockfile ];then
            echo "httpd is running..."
         else
            echo "httpd is stoped..."
         fi
}
case "$1" in
start)
    start
     ;;
stop)
    stop
     ;;
restart)
    stop
    start
     ;;
status)
    status
     ;;
*)
echo "USE ONLY:start|stop|restart|status"
esac


[root@localhost init.d]# chmod a+x httpd  
[root@localhost ~]# service httpd start
Starting httpd:
ok
[root@localhost ~]# service httpd restart
Stopping httpd:                                        [  OK  ]
Starting httpd:
ok
[root@localhost ~]# service httpd stop
Stopping httpd:                                        [  OK  ]
[root@localhost ~]# service httpd status
httpd is stoped...
相关文章
相关标签/搜索