Search code examples
apachemsys2

how to build apache httpd 2.* and beyond on msys2


httpd build on msys2 fails with the following error:

xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory

On real linux distros, installing the expat-devel package seems to solve the problem see here, more precisely, expat-devel is an apr-util prerequisite and at least its headers ar missing on msys2.

So how to build httpd with msys since no expat-devel package or headers is available ? When configuring httpd --with-included-apr, where do apr-utils look for expat headers or how to configure that ?

more precisely the CHANGES-APR-UTIL-1.6 documentation says

Changes with APR-util 1.6.0

*) The expat dependency of apr-util is no longer built with apr-util. Install expat (including development headers and libraries) first before building apr-util.

where should expat headers and libs be installed in httpds build directory tree ?


Solution

  • I finally had to build expat separately, then other errors arised and found a solution thanks to this link for missing libtool and to that link for the effective way to build expat without generating export redefinition.

    let find the full build script here:

    pacman -S make gcc libcrypt perl unzip libtool msys/libcrypt-devel
    
    cd OpenSSL_1_1_1-stable
    curl http://mirrors.standaloneinstaller.com/apache/httpd/httpd-2.4.38.tar.gz --output httpd-2.4.38.tar.gz
    tar xvf  httpd-2.4.38.tar.gz
    
    cd $HOME
    git clone --branch OpenSSL_1_1_1-stable https://github.com/openssl/openssl.git
    mv openssl  OpenSSL_1_1_1-stable
    cd OpenSSL_1_1_1-stable
    ./configure gcc --prefix=$HOME/openssl
    make
    make install
    
    cd $HOME
    wget https://github.com/libexpat/libexpat/releases/download/R_2_2_6/expat-2.2.6.tar.bz2
    tar xjvf expat-2.2.6.tar.bz2
    cd $HOME/expat-2.2.6
    ./configure --prefix=$HOME/httpd --exec-prefix=$HOME/httpd
    make
    make install
    
    cd $HOME
    curl http://mirrors.standaloneinstaller.com/apache//apr/apr-1.6.5.tar.gz --output apr-1.6.5.tar.gz
    tar xvf apr-1.6.5.tar.gz
    curl http://mirrors.standaloneinstaller.com/apache//apr/apr-util-1.6.1.tar.gz --output apr-util-1.6.1.tar.gz
    tar xvf apr-util-1.6.1.tar.gz
    cd $HOME/apr-1.6.5
    ./configure --prefix=$HOME/httpd
     make
     make install
    cd $HOME/apr-util-1.6.1
     ./configure --prefix=$HOME/httpd --with-apr=$HOME/httpd --with-expat=$HOME/httpd 
     make
     make install
    
    cd $HOME
    wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
    tar xvf pcre-8.43.tar.gz
    cd pcre-8.43
    ./configure --prefix=$HOME/pcre
    make 
    make install
    
    cd $HOME
    wget https://github.com/nghttp2/nghttp2/releases/download/v1.37.0/nghttp2-1.37.0.tar.gz
    tar xvf nghttp2-1.37.0.tar.gz
    cd $HOME/nghttp2-1.37.0
    ./configure  --exec-prefix=$HOME/httpd --prefix=$HOME/httpd
    make 
    make install
    
    cd $HOME/httpd-2.4.38
     ./configure --prefix=$HOME/httpd --with-expat==$HOME/httpd --with-apr-util=$HOME/httpd --with-apr=$HOME/httpd --with-pcre=$HOME/pcre --enable-ssl --enable-ssl-staticlib-deps --with-ssl=$HOME/openssl --enable-proxy --enable-proxy-connect --enable-proxy-http --enable-proxy-balancer --enable-http2 --enable-nghttp2-staticlib-deps --with-nghttp2=$HOME/nghttp2
    make
    make install
    

    The build process completed successfully, but usefull to say that the runtime can't be used since httpd is not able to load its dynamic modules as described here