很久没有写过博客了,今天心血来潮记录下源码安装httpd的过程,如果有错误希望大家提出来,也好改进,谢谢广大博友j_0058.gifj_0058.gifj_0058.gif

     

       安装环境:     Asianux3     内核版本:Asianux    3.1

       软件包:     httpd-2.4.12

                          pcre-8.20

                          apr-1.5.2

                          apr-util-1.5.4

       安装步骤:

              1.环境检查:系统是否安装有apr apr-util pcre软件包

                   #rpm -qa apr

                   apr-1.2.7-11

                   #rpm -qa apr-util

                   apr-util-1.2.7-7AXS3

                   #rpm -qa pcre

                   pcre-6.6-2.7

      这些软件系统有自带,但是也不能卸载与其他软件还有依赖关系,所以需要安装其他软件,并且安装到不同的路径下

              2.开始安装前压迫先安装好开发工具库,查看系统是否已安装

                   #yum grouplist

                   基本系统

                   开发

                   gnome库

                我的系统已经安装,如果没有安装则执行

                   #yum groupinstall "开发工具 开发库"    命令进行安装

              3.检查完环境既可以开始安装,要先安装pcre 软件,将软件包拷贝到服务器

                   #tar -jxf pcre-8.20.tar.bz2               //解压pcre软件包

                   #ls                                                   //查看当前目录下会多出一个pcre-8.20目录

                   #cd pcre-8.20                                 //切换进pcre目录

                   #./configure  --perfix=/usr/local/pcre

                                                                          //编译病指定pcre安装目录

                   #make

                   #make check                                  //验证make结果,不是必须步骤

                   #make install              

                   #ls  /usr/local/pcre                         //查看/usr/local/pcre   

                   bin     include  lib    share

               pcre安装完成。

               4.安装apr软件

                    #tar zxf apr-1.5.2.tar.gz                 //解压apr软件包

                    #cd apr-1.5.2

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

                                                                          //编译apr.指定安装路径

                    #make

                    #make install

                    #ls /usr/local/apr

                    bin     include  lib    build-1

                apr软件包安装完成

                5.安装apr-util软件

                    #tar zxf apr-util-1.5.4.tar.gz         //解压util软件包

                    #cd apr-util-1.5.4

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

                                   //编译util软件包,指定安装目录并制定apr软件安装目录。因为util依赖apr软件

                    #make

                    #make install

                    #ls /usr/local/apr-util

                    bin     include  lib   

                 apr-util软件安装完成

                 6.就要安装httpd软件了,安装前还要检查selinux是否被禁用(disabled)

                    #vim /etc/selinux/config

                    SELINUX=disabled

                    #tar jxf httpd-2.4.12.tar.bz2          //解压软件包

                    #cd httpd-2.4.12

                    #./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/use/local/pcre --sysconfdir=/etc/httpd --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most                           //编译,指定apr,apr-util  和pcre安装路径和模块选择,必须的模块得有so,rewirte ssl,cgi

                    #make

                    #make install

                    #ls /usr/local/apache/bin           //查看bin目录,apachetl是启动脚本

                    ab     checkgid     envvers-std      htdbm     httpd     rotatelogs      apachectl   

                    dbmmanage       fcgistarter       htdigest     httxt2dbm    apxs      envvare

                    htcacheclean         htpasswd       logresolve

                 7.启动httpd服务

                    #/usr/local/apache/bin/apachectl  start         //启动httpd服务

                    #netstat -anput|grep  httpd                            //查看80端口

                    tcp       0       0   :::80             :::*              LISTEN          6211/httpd          

                  用浏览器访问默认首页    http:10.10.0.251    结果打开的是欢迎界面,并没有显示it works

                  修改    #vim /etc/httpd/conf/httpd.conf      下的这一项,首页文件路径

                            DocumentRoor  "/usr/local/apache/htdocs"                   

                   再次打开,OK看到了   it    works   !!!

               再此更正一下,在后来启动服务时,会有报错,但是当时却没有,可能是什么地方有其他配置把,现在 说一下报错信息和解决办法:

               报错信息如下:

              httpd: Syntax error on line 144 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/mod_dir.so into server: /usr/local/apache2/modules/mod_dir.so: undefined symbol: apr_array_clear

               总是提示apr的错误,重新编译也不行,后来添加 --with-included-apr  参数,在重新编译,并且还要把apr和apr-util的的源码复制到http-2.4.12/srclib目录下才可以

                  #cp  -rf apr-1.5.2 httpd-2.4.12/srclib/apr

                  #cp  -rf apr-util-1.5.4 httpd-2.4.12/srclib/apr-util

              ok ,重新启动就没有问题了


                 安装过程中遇到的问题:提示如下,

                 util_pcre.c: In function 'ap_regcomp':
                 util_pcre.c:128: error: 'PCRE_DUPNAMES' undeclared (first use in this function)
                 util_pcre.c:128: error: (Each undeclared identifier is reported only once
                 util_pcre.c:128: error: for each function it appears in.)

                问题在于pcre软件没有装上,在make的时候就会有这个提示,安装pcre软件后就可以了

                2. 在选择模块的时候可以使用./configure  --help  命令来选择所需要的模块