???紵 发表于 2018-11-21 12:36:38

centos源码编译apache

  服务器 172.18.1.211         CentOS release 6.2 (Final)   2.6.32-220.7.1.el6.i686
  客户机172.18.18.212
  

  1;在服务器上编译apache httpd的安装包可以去官网下载,最新的是http2.4
  假设我服务器的那些依赖包都安装好了 下面是准备工作
  # rpm -qa |grep httpd//查看我服务器原来有没有安装过httpd,如果有就要卸载
  httpd-tools-2.2.15-39.el6.centos.i686
  httpd-2.2.15-39.el6.centos.i686
   # rpm -e --nodeps httpd-2.2.15-39.el6.centos.i686          //卸载httpd --nodeps表示不卸载它的依赖软件
  

   因为编译apache需要一个apr 和apr-util 依赖包 而我又习惯性的将这两个依赖包编译到/usr/local/apr和 /usr/local/apr-util下 所以原来的这个我也要卸载掉
  # rpm -e --nodeps apr-1.3.9-3.el6_1.2.i686
  # rpm -e --nodeps apr-util-1.3.9-3.el6_0.1.i686

  

  再查看下他的安装包,发现原来的那两个apr包都卸载掉了
  # rpm -qa |grep apr

  apr-util-ldap-1.3.9-3.el6_0.1.i686
  

   1,1编译安装apr 和apr-util
     我通过rz -y将两个文件传到服务器上去,并解压


  

  编译apr和apr-util
         创建3个目录
      # mkdir -p /usr/local/apr
      # mkdir -p /usr/local/apr-util
      # mkdir -p /usr/local/apache
  

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

      # cd apr-util-1.5.3
  # ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr
  # make && make install
  如果没提示错误就编译好了
  

  

  2;编译apache
  # cd httpd-2.4.12
  # ./configure \
      --prefix=/usr/local/apache \
      --enable-so \
      --enable-deflate \
      --enable-expires \
      --enable-headers \
      --enable-modules=most \
      --with-mpm=worker \
      --enable-rewite \
  --with-apr=/usr/local/apr \
  --with-apr-util=/usr/local/apr-util
  

  # make && make install

  如果没有报错就成功了 至于安装哪些模块 可以./configure --help查看
  

   配置服务器启动脚本和配置文件,在httpd包下找httpd.init 文件并且复制到/etc/init.d/
  # cp build/rpm/httpd.init /etc/init.d/httpd
  

  
   配置脚本及授权
  # chmod 700 /etc/init.d/httpd
  # vi /etc/init.d/httpd
  
  httpd=${HTTPD-/usr/sbin/httpd}          修改成 httpd=${HTTPD-/usr/local/apache/bin/httpd}
    pidfile=${PIDFILE-/var/run/${prog}.pid}修改成pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}
      lockfile=${LOCKFILE-/var/lock/subsys/${prog}}
    RETVAL=0

  

  
  
  

   配置/usr/local/apache/conf/httpd.conf和apache运行的进程用户
  www:x:500:500::/home/www:/sbin/nologin    //我这已经有个www用户了 就用这个用户做进程运行用户
   # vi /etc/httpd/conf/httpd.conf

     User www
  Group www
  ServerName localhost:80

  

   查看服务器状态
  # service httpd status

  httpd is stopped

  

  启动服务器
  service httpd start

  

  在chkconfig服务列表中增加httpd服务
  # chkconfig --add httpd

  # chkconfig --level 35 httpd on

  # chkconfig --list |grep httpd
  httpd          0:off1:off2:off3:on4:off5:on6:off
  




页: [1]
查看完整版本: centos源码编译apache