rgar12 发表于 2015-5-25 09:48:45

lamp之编译安装httpd

编译安装LAMP顺序:
    httpd--> mysql --> php -->XCache


httpd:
    apr--> apr-util -->httpd

    0.确保安装环境
      #yum groupinstall "Development Tools" "Compatibility Libraries"
      #yum -y install pcre-devel openssl-devel


    1.安装apr和apr-util:
      apr(Apache Protable Runtime)和apr-util和,可以使用rpm包或编译的方式。
      #tar -xf httpd-xxx-deps.tar.bz2
      #cd httpd-xxxx/srclib/apr
      #./configure --prefix=/usr/local/apr
      #make && make install

      #cd ../apr-util
      #./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
      #make && make install


    2.安装httpd
      #tar -xf httpd-xxx.tar.bz2
      #cd httpd-xxx
      #./configure --prefix=/usr/local/httpdXX --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-z --with-pcre --enable-modules=most --enable-mpms-shared=all --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
      #make
      #make install

      编译选项:
            --prefix=/usr/local/httpd 指定文件安装路径
            --sysconfdir=/etc/httpd 指定配置文件目录
            --enable-so 启用模块
            --enable-ssl 启用ssl功能,需要openssl-devel包。

            --enable-deflate 默认的文件压缩机制。需要zlib-devel包。

            --enable-modules=most
                启用模块,可选项有MOULDE-LIST|all|most|few|reallyall

            --enable-mods-shared=most
                以共享的方式启用模块,可选项有MOULDE-LIST|all|most|few|reallyall

            --eanble-mods-static=most
                可选项有MOULDE-LIST|all|most|few|reallyall 以静态方式启用模块,即编译到httpd中。

            --enable-proxy 启用httpd的代理模块

            --enable-proxy-fcgi 允许httpd和php以fastcgi方式下工作

            --enable-mpms-shared=all
                可选项有MPM-LIST|all。以共享模块化方式使用MPM,prefork模式不用编译php,如果是worker或者是event,则php需要编译成zts格式。

            --with-mpm=event
                event|worker|prefork|winnt 指定默认使用某个MPM,不指定默认使用event模式。

            --enable-rewrite 支持url重写

            --enable-cgi
                启用被非线程方式MPM使用的CGI脚本,prefork。

            --enable-cgid
                启用被线程MPM使用的CGI脚本。worker和event模式。

            --with-apr=/usr/local/apr 指定apr的安装位置

            --wiht-apr-util=/usr/local/apr-util 指定apr-util的安装位置。


            --with-z=DIR 指定zlib库的位置,不指定会自动寻找。需要zlib-devel包。


    3.创建软链接以方便多版本共存:
      #ln -sv /usr/local/httpdXX /usr/local/httpd

      注意:多版本共存的情况下,建议修改配置文件中路径为创建好的软链接。这样切换版本时只要重新创建软链接即可。



    4.导出头文件和man文档路径
      #ln -sv /usr/local/httpd/include/ /usr/include/httpd

      #vim /etc/man_db.conf
            MANDATORY_MANPATH    /usr/local/httpd/man

    5.添加服务脚本:
      #cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
      #vim /etc/init.d/httpd
            :1,$s/httpdXX/httpd/g
      #sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
      #sed -i '3a # description: Apache is a World Wide Web server. It is used to server' /etc/init.d/httpd
      #chmod 755 /etc/rc.d/init.d/httpd

    6.添加环境变量:
      #vim /etc/profile.d/httpd.sh
            export PATH=$PAHT:/usr/local/httpd/bin

    7.修改配置文件:
      #vim /etc/httpd/httpd.conf
            :1,$s/httpdXX/httpd/g

    8.启动httpd
      #systemctl start httpd

      或
      #chkconfig --add httpd
      #chkconfig --level 2345 httpd on
      #service httpd start

      #netstat -tnlp |grep httpd 验证80端口是否开放



    编译安装后生成目录:
      /usr/local/httpdXX/
            bin 二级制程序
            build 编译时使用的目录
            cgi-bin cgi程序
            error 错误信息
            htdocs 网页文件存放位置
            icons 图标
            include 头文件位置
            logs 日志文件位置
            man man文件
            manual 手册
            modules 模块
            conf 默认配置文件位置

      /etc/httpd/ 配置文件所在目录
            extra额外的配置文件
                httpd-vhosts.conf 虚拟主机参数
                httpd-ssl.conf ssl的相关参数
                httpd-mpm.conf 定义不同PMP工作参数


页: [1]
查看完整版本: lamp之编译安装httpd