apache源码包安装

  • 将源码包上传到对应目录下解压并且移动到对应目录下
[root@zhounan src]# ls  apr* http*
apr-1.6.5.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.37.tar.gz
[root@zhounan src]# tar zxvf apr-1.6.5.tar.gz #解压三个包
[root@zhounan src]# tar zxvf apr-util-1.6.1.tar.gz 
[root@zhounan src]# tar zxvf httpd-2.4.37.tar.gz 
  • 安装编译apr
[root@zhounan src]# cd /usr/local/apr-1.6.5
[root@zhounan apr]# ./configure --prefix=/usr/local/apr #安装apr
[root@zhounan apr]# make && make install #编译apr
[root@zhounan apr-1.6.5]# ls /usr/local/apr/ #查看apr安装后生成的文件
bin  build-1  include  lib
  • 安装apr-util
[root@zhounan apr]# cd /usr/local/apr-util-1.6.1
[root@zhounan apr-util]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr #此时需要跟apr安装路径。否则失败
[root@zhounan apr-util]# make && make install
[root@zhounan apr-util-1.6.1]# ls /usr/local/apr-util/ #查看apr-util安装后生成的文件
bin  include  lib

问题:xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录 #include

解决:缺少expat-devel包

yum install expat-devel

  • 安装apache
[root@zhounan httpd-2.4.37]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
[root@zhounan httpd-2.4.37]#make && make install 
[root@zhounan httpd-2.4.37]# ls /usr/local/apache2.4/
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
  • apache目录介绍
    /bin 程序启动目录
    /conf 配置文件所在目录
    /htdocs 访问页存放目录
    /logs 日志目录
    /man 帮助文档目录
    /modules 扩展模块目录

注意:这里需指定apr apr-util的安装路径
上述命令指定了拓展模块 enable-so与enable-mods-shared=most

错误:configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

解决:缺少 pcre-devel包

yum -y install pcre-devel

  • 查看apache拓展模块命令
[root@zhounan httpd-2.4.37]# /usr/local/apache2.4/bin/httpd -M
  • 启动apache
[root@zhounan httpd-2.4.37]# /usr/local/apache2.4/bin/apachectl start

你可能感兴趣的:(Linux)