lijm1522 发表于 2018-11-17 12:37:36

编译安装httpd apache服务器

  一,下载源码包
  1.1下载apr-util-1.6.1.tar.gz 和apr-1.6.3.tar.gz
  http://apr.apache.org/
  1.2下载httpd源码安装包httpd-2.4.33.tar.gz
  http://httpd.apache.org/download.cgi
  二,拷贝到服务器并解压
  scp Downloads/httpd-2.4.33 root@10.100.5.57:/root
  scp Downloads/apr- root@10.100.5.57:/root
  tar -zxvf apr-1.6.3.tar.gz
  tar -zxvf apr-util-1.6.1.tar.gz
  tar -zxvf httpd-2.4.33.tar.gz
  三,编译安装apr和apr-util
  cp -r httpd-2.4.33 /usr/local/src
  3.1安装apr
  yum -y install gcc #安装gcc
  cd apr-1.6.3
  ./configure --prefix=/usr/local/apr
  make
  make install
  3.2安装apr-util
  cd apr-util-1.6.1
  ./configure --with-apr=/usr/local/apr --prefix=/usr/local/apr-util
  make
  问题: xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录#include
  解决:缺少expat-devel包
  yum install expat-devel
  make install
  3.3 安装httpd
  cd /usr/local/src/httpd-2.4.33/
  ./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/   --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all
  问题1:checking for pcre-config... false
  解决:yum -y install pcre-devel
  问题2:checking for OpenSSL version >= 0.9.8a... FAILED
  解决:yum install openssl-devel
  make
  问题3:make: bison:命令未找到make: flex:命令未找到
  解决:yum -y install bison flex
  问题4:collect2: error: ld returned 1 exit status
  make: 错误 1
  make: 离开目录“/usr/local/src/httpd-2.4.33/support”
  make: 错误 1
  make: 离开目录“/usr/local/src/httpd-2.4.33/support”
  make: 错误 1
  解决:在./configure后加上--with-include-apr后
  cp -r apr-1.6.3 /usr/local/src/httpd-2.4.33/srclib/apr#拷贝apr
  cp -r apr-util-1.6.1 /usr/local/src/httpd-2.4.33/srclib/apr-util拷贝apr-util
  ./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/   --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all -with-included-apr
  make install
  四,启动测试
  /usr/local/apache/bin/apachectl start   #启动httpd
  /usr/local/apache/bin/apachectl stop   #停止httpd
  /usr/local/apache/bin/apachectl restart #重启httpd
  增加环境变量
  vim/etc/profile
  PATH=$PATH:/usr/local/apache/bin
  apachectl start   #启动httpd
  apachectl stop   #停止httpd
  apachectl restart #重启httpd
  cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
  /etc/init.d/httpd operation
  ps -ef |grep httpd
  root   18005   10 17:53 ?      00:00:00 /usr/local/apache/bin/httpd -k start   已开启
  用浏览器访问http://yourip    examplehttp://10.100.5.57


页: [1]
查看完整版本: 编译安装httpd apache服务器