qweewq123qwe 发表于 2018-11-17 13:17:03

Apache-2.4.32安装

  WEB服务之Apache
  安装Apache步骤
  第一步解包:
  # tar -xf httpd-2.4.32.tar.gz -C /usr/local/
  第二步切换进去:
  # cd /usr/local/httpd-2.4.32/
  第三步配置、编译、编译安装:
  # ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-zlib --enable-modules=most --enable-mpms-shared=most --with-mpm=event
  直接编译会报错:
  checking for APR... no
  configure: error: APR not found.Please read the documentation.
  用yum 安装apr也没有用,可能是版本问题,下面用编译安装的解决方案:
  Apr软件包下载地址
  http://mirror.bit.edu.cn/apache/apr/apr-1.6.3.tar.gz
  解压缩包:
  安装apr-1.6.3
  # tar xf apr-1.6.3.tar.gz -C /usr/local/src/
  配置编译:
  # cd /usr/local/src/
  # cd apr-1.6.3/
  # ./configure --prefix=/usr/local/apr
  # make && make install
  安装apr-util-1.6.1
  # tar -xf apr-util-1.6.1.tar.gz -C /usr/local/src/
  # cd /usr/local/src/
  # cd apr-util-1.6.1/
  # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  # make && make install
  编译时报错:
  xml/apr_xml.c:35:19: 错误:expat.h:没有那个文件或目录
  xml/apr_xml.c:66: 错误:expected specifier-qualifier-list before ‘XML_Parser’
  xml/apr_xml.c: 在函数‘cleanup_parser’中:
  xml/apr_xml.c:364: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c:365: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c: 在文件层:
  xml/apr_xml.c:384: 错误:expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
  xml/apr_xml.c: 在函数‘apr_xml_parser_create’中:
  xml/apr_xml.c:401: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c:402: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c:410: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c:411: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c:412: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c:424: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c:424: 错误:‘default_handler’未声明(在此函数内第一次使用)
  xml/apr_xml.c:424: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其
  xml/apr_xml.c:424: 错误:所在的函数内也只报告一次。)
  xml/apr_xml.c: 在函数‘do_parse’中:
  xml/apr_xml.c:434: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c:438: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c:442: 错误:‘apr_xml_parser’没有名为‘xp_err’的成员
  xml/apr_xml.c:442: 错误:‘apr_xml_parser’没有名为‘xp’的成员
  xml/apr_xml.c: 在函数‘apr_xml_parser_geterror’中:
  xml/apr_xml.c:500: 错误:‘apr_xml_parser’没有名为‘xp_err’的成员
  xml/apr_xml.c:500: 错误:‘apr_xml_parser’没有名为‘xp_err’的成员
  make: 错误 1
  make: Leaving directory `/usr/local/src/apr-util-1.6.1'
  make: 错误 1
  上述报错解决方案:
  # yum install -y expat-devel
  安装后重新编译:
  # make && make install
  上述包都安装完毕再切入httpd目录下配置编译安装:
  # cd /usr/local/httpd-2.4.32/
  # ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-zlib --enable-modules=most --enable-mpms-shared=most --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ (需要增加指定apr和apr-util的安装路径)。
  出现下面报错:
  checking which MPM to use by default... event
  configure: error: MPM most does not support dynamic loading.
  解决方法:
  将配置中--enable-mpms-shared=most改成all
  修改后配置参数如下:
  # ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-zlib --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
  编译如果报下面的错误:
  make: 错误 1
  make: Leaving directory `/usr/local/httpd-2.4.32/support'
  make: 错误 1
  make: Leaving directory `/usr/local/httpd-2.4.32/support'
  make: *** 错误 1
  解决方法:
  # ln -s /usr/lib64/libm.a /usr/lib/libm.a
  # ln -s /usr/lib64/libm.so /usr/lib/libm.so
  # ln -s /usr/lib64/libexpat.so /usr/lib/libexpat.so
  # make && make install
  编译如果还是报下面的错误:那就是apr和apr-util的版本有问题,centos6应该安装1.5版本的,1.6版本或者版本过低都会有问题
  make: * 错误 1
  make: Leaving directory /usr/local/httpd-2.4.32/support'make: * 错误 1make: Leaving directory/usr/local/httpd-2.4.32/support'
  make: * 错误 1
  重新安装1.5版本的在重新配置增加一个配置项
  # ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-zlib --enable-modules=most --enable-mpms-shared=all --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-included-apr
  如果出现下面报错:
  configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.
  解决方案:
  # cp -fr apr-1.5.1 /usr/local/httpd-2.4.33/srclib/apr
  # cp -fr apr-util-1.5.1/ /usr/local/httpd-2.4.33/srclib/apr-util
  将解压的软件包放入/usr/local/httpd-2.4.32/srclib/下(去除版本号)
  报错:configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
  解决方案:yum install -y pcre-devel
  解决了问题再重新配置
  # ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-zlib --enable-modules=most --enable-mpms-shared=all --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-included-apr --enable-deflate --enable-expires
  配置完成后编译、编译安装:
  # make && make install
  完成后复制脚本:
  # cp/usr/local/httpd/bin/apachectl /etc/init.d/httpd
  # /etc/init.d/httpd start
  # netstat -anpt|grep httpd
  tcp      0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      55654/httpd
  配置虚拟主机:
  # vim /etc/httpd/httpd.conf
Virtual hosts
  Include /etc/httpd/extra/httpd-vhosts.conf(去掉这行的注释)
  # vim /etc/httpd/extra/httpd-vhosts.conf
  
  Options Indexes FollowSymLinks
  AllowOverride None
  Require all granted
  Require all granted
  
  
  ServerAdmin webmaster@dummy-host.example.com
  DocumentRoot "/var/www"
  ServerName www.benet.com
  ServerAlias benet.com
  ErrorLog "logs/www.benet.com-error_log"
  CustomLog "logs/www.benet.com-access_log" common
  

页: [1]
查看完整版本: Apache-2.4.32安装