logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Building & Member Downloads View previous topic :: View next topic
Reply to topic   Topic: How do I compile Apache with all modules?
Author
tanquang



Joined: 21 Mar 2020
Posts: 58
Location: Vietnam

PostPosted: Thu 13 Aug '20 18:26    Post subject: How do I compile Apache with all modules? Reply with quote

I followed this guide to compile Apache: https://www.apachelounge.com/viewtopic.php?t=6462
Here is the command I use to compile:
Code:
cd /D C:\httpd\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=Release -DENABLE_MODULES=i -DINSTALL_PDB=OFF ..
nmake
nmake install

However, some Apache modules like:
    mod_charset_lite
    mod_deflate
    mod_fcgid
    mod_http2
    mod_lua
    mod_proxy_html
    mod_xml2enc

Skipped during compiling, so not compiled into .so files. Sad
How do I edit the command line to compile all of the above modules during compilation? Question
Thanks.
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 346
Location: UK

PostPosted: Mon 17 Aug '20 16:08    Post subject: Reply with quote

That Apache build guide shows you need to pre-build and install a number of base support packages, including PCRE, OpenSSL, APR and APR-Util.

To persuade Apache to build the additional modules you mention, you'll need to pre-build and install a number of additional packages too.
Exactly what you need to pre-build varies from module to module, e.g. for mod_deflate you'll need zlib; for mod_lua you'll need lua; for mod_http2 you'll need nghttp2, etc.

Take a look in the Apache build cmake.log file, and you'll see what features it's currently found, e.g. (hopefully)

-- Summary of feature detection:
-- LIBXML2_FOUND ............ : TRUE
-- LUA51_FOUND .............. : TRUE
-- NGHTTP2_FOUND ............ : TRUE
-- OPENSSL_FOUND ............ : TRUE
-- ZLIB_FOUND ............... : TRUE
-- BROTLI_FOUND ............. : TRUE
-- CURL_FOUND ............... : TRUE
-- JANSSON_FOUND ............ : TRUE
-- APR_HAS_LDAP ............. : TRUE
-- APR_HAS_XLATE ............ : TRUE
-- APU_HAVE_CRYPTO .......... : TRUE

However, beware that some of these extra packages have their own dependencies (some optional), depending on the features you choose to build into them, e.g. nghttp2 is complex and requires zlib and openssl, but will make use of libev, libcares, libxml2, python, etc.

mod_fcgid is a separate package in its own right, and should be built after Apache; similarly with mod_security2.so should you choose to build it. For mod_fcgid (release 2.3.9), if you read the documentation, it comes with its own CMAKE build option, which will create mod_fcgid.so and drop it into the Apache modules folder. Hopefully this will help you get further with your missing modules, let the forum know how you get on.
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 58
Location: Vietnam

PostPosted: Mon 17 Aug '20 18:07    Post subject: Reply with quote

Hi, I compiled Expat, PCRE, OpenSSL, APR and APR-Util before compiling Apache.
The commands I use to compile depend a lot on the tutorial above. I omitted zlib during OpenSSL compilation because I got the
Code:
fatal error: zlib.h: no such file or directory
error.
Having said that, I compile OpenSSL mechanically. I have not found the default option in the OpenSSL documentation. The options come
Code:
enable-camellia no-idea no-mdc2 no-ssl2 no-ssl3
I got in the tutorial.
These are the entire command lines I use to compile them. If you have any correction advice, please do let me. I have no experience in this.
Code:
*********************
** Set Environment **
*********************
Visual Studio 2013: call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64 | amd64 || x86
Visual Studio 2015: call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64 | amd64 || x86

*****************
** Expat Build **
*****************
cd /D C:\httpd\srclib\expat\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=Release ..
nmake
nmake install

****************
** Pcre Build **
****************
cd /D C:\httpd\srclib\pcre\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DPCRE_BUILD_TESTS=OFF -DPCRE_BUILD_PCRECPP=OFF -DPCRE_BUILD_PCREGREP=OFF -DPCRE_SUPPORT_PCREGREP_JIT=OFF -DPCRE_SUPPORT_UTF=ON -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_NEWLINE=CRLF -DINSTALL_MSVC_PDB=OFF ..
nmake
nmake install

*******************
** OpenSSL Build **
*******************
cd /D C:\httpd\srclib\openssl

==================== Compile ====================
perl Configure VC-WIN64A --release --prefix=C:\Apache24 --openssldir=C:\Apache24\conf enable-camellia no-idea no-mdc2 no-ssl2 no-ssl3 no-zlib (x64)
perl Configure VC-WIN32 --release --prefix=C:\Apache24 --openssldir=C:\Apache24\conf enable-camellia no-idea no-mdc2 no-ssl2 no-ssl3 no-zlib (x86)

==================== For OpenSSL 1.0.2 ====================
ms\do_win64a.bat (x64) | ms\do_nasm.bat (x86)
nmake /f ms\ntdll.mak
nmake /f ms\ntdll.mak install

==================== For OpenSSL 1.1.1 ====================
nmake
nmake install

***************
** APR Build **
***************
cd /D C:\httpd\srclib\apr\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=Release -DMIN_WINDOWS_VER=0x0600 -DAPR_HAVE_IPV6=ON -DAPR_INSTALL_PRIVATE_H=ON -DAPR_BUILD_TESTAPR=OFF -DINSTALL_PDB=OFF ..
nmake
nmake install

********************
** APR-Util Build **
********************
cd /D C:\httpd\srclib\apr-util\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DOPENSSL_ROOT_DIR=C:\Apache24 -DCMAKE_BUILD_TYPE=Release -DAPU_HAVE_CRYPTO=ON -DAPR_BUILD_TESTAPR=OFF -DINSTALL_PDB=OFF ..
nmake
nmake install

******************
** Apache Build **
******************
cd /D C:\httpd\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=Release -DENABLE_MODULES=i -DINSTALL_PDB=OFF ..
nmake
nmake install

Thank you very much!
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 346
Location: UK

PostPosted: Thu 20 Aug '20 22:08    Post subject: Reply with quote

I would suggest you build zlib (1.2.11) first, since it has no other dependencies.

Using the same layout structure as per the Apache guide (https://www.apachelounge.com/viewtopic.php?t=6462), these are suitable build commands.

Code:
cd /d C:\Development\Apache24\build\zlib
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ..\..\src\zlib-1.2.11
nmake
nmake install


This places zlib1.dll, zlib.lib, and zlib.h below C:\Apache24, so your OpenSSL build should find them.

You say you've built expat which is good.

For LUA you can use a similar approach, though release 5.3.5 doesn't come with a CMakeLists.txt file. However, there are plenty of CMake files for LUA out on the net; the CMakeLists.txt file I've been using can be found here https://apaste.info/yOSR

Code:
cd /d C:\Development\Apache24\build\lua
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=Release ..\..\src\lua-5.3.5
nmake
nmake install


Take it from there and progressively prepare the extra packages needed so that the Apache build creates the missing modules you want.
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 58
Location: Vietnam

PostPosted: Fri 21 Aug '20 7:48    Post subject: Reply with quote

So the compile order would be: expat, pcre, zlib, lua, OpenSSL (I can remove the no-zlib option at compile time), APR, APR-Util and finally Apache?
Then I don't change the command line when compiling Apache, I will get all the missing modules listed above. Right?
Are your OpenSSL compilation options the same as mine?
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 346
Location: UK

PostPosted: Fri 21 Aug '20 22:10    Post subject: Reply with quote

Based on the modules you list, the suggested build order would be zlib, pcre, expat, openssl, lua, apr, apr-util and httpd.

However, this still won't build all the modules you say are missing in your original post. As stated before, you'll need to build and install a number of additional packages first, before the missing modules will get built with httpd. You need to check the httpd build log details to find out what's needed.

If I run the httpd build with just the above packages, I get these warnings:

    -- mod_brotli was requested but couldn't be built due to a missing prerequisite (BROTLI_FOUND)
    -- mod_charset_lite was requested but couldn't be built due to a missing prerequisite (APR_HAS_XLATE)
    -- mod_proxy_html was requested but couldn't be built due to a missing prerequisite (LIBXML2_FOUND)
    -- mod_xml2enc was requested but couldn't be built due to a missing prerequisite (LIBXML2_FOUND)
    -- mod_http2 was requested but couldn't be built due to a missing prerequisite (NGHTTP2_FOUND)
    -- mod_md was requested but couldn't be built due to a missing prerequisite (CURL_FOUND)
    -- mod_md was requested but couldn't be built due to a missing prerequisite (JANSSON_FOUND)
    -- mod_proxy_http2 was requested but couldn't be built due to a missing prerequisite (NGHTTP2_FOUND)


So here you can see what packages are missing, e.g. brotli, libxml2, nghttp2, curl, jansson, and APR with XLATE which means you need apr-iconv.

If you look at the News and Hangout forum, you'll see the httpd 2.4.46 release page shows the dependencies used in that build, which basically matches all the packages you are missing.

So you can see, building a full Apache suite is not simple, nor for the feint hearted. Hence the need for gurus who run this site and build the packages for us!

Stick at it. Build the dependencies one by one, and iterate till you get there.
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 58
Location: Vietnam

PostPosted: Sat 22 Aug '20 17:45    Post subject: Reply with quote

How to compile apr-iconv using CMake? I don't see the cmake file in it's release source package.
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 346
Location: UK

PostPosted: Sat 22 Aug '20 23:26    Post subject: Reply with quote

Unfortunately, release 1.2.2 of apr-iconv doesn't support CMake. However, it does come with nmake files, apriconv.mak for static library build, and libapriconv.mak for dynamic library build.

Take a look at https://apr.apache.org and https://apr.apache.org/compiling_win32.html and read the documentation for details.

The build process is closely tied up with the APR build location, so you'll need to edit these make files to update the location of the various APR include files, depending on your chosen directory locations, e.g. using perl to edit the make files.

Code:
rem Edit APR-ICONV MAK files to suit build environment

set APR_VER=1.7.0
set APR-ICONV_VER=1.2.2

%PERL% -pi.orig -e ^" ^
    $apr_ver=$ENV{'APR_VER'}; ^
    s~\/apr\/~/apr-$apr_ver/~; ^
    ^" apriconv.mak

%PERL% -pi.orig -e ^" ^
    $apr_ver=$ENV{'APR_VER'}; ^
    $apr-iconv_ver=$ENV{'APR-ICONV_VER'}; ^
    s~\/apr\/~/apr-$apr_ver/~; ^
    s~\\apr\"~\\apr-$apr_ver\"~; ^
    s~\\apr\\~\\apr-$apr_ver\\~; ^
    s~\\apr-iconv\"~\\apr-iconv-$apr-iconv_ver\"~; ^
    ^" libapriconv.mak

rem Build static and then dynamic libraries

nmake -nologo -f apriconv.mak CFG="apriconv - x64 Release"
nmake -nologo -f libapriconv.mak CFG="libapriconv - x64 Release"


Note this isn't the whole solution; which will depend on your layout and configuration files. You'll need to keep working through your error logs till you can get the package to build cleanly. You'll then have to copy over the target libaries apriconv-1.lib and libapriconv-1.lib from x64\LibR, since there's no support for 'nmake install' in apr-iconv.

Yes, it's a pain, but this forum is meant to be an aid, rather than a guide verbatim. Am sorry tanquang, but I'm not sure I can help you much further.
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 58
Location: Vietnam

PostPosted: Sun 23 Aug '20 2:57    Post subject: Reply with quote

Thank you very much. I wonder if the home page version is Relase or Debug or Release with Debug because their modules file size is different from the modules file size after I compile?
Also, could you help me with this topic: https://www.apachelounge.com/viewtopic.php?t=8482 Crying or Very sad
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 346
Location: UK

PostPosted: Sun 23 Aug '20 13:10    Post subject: Reply with quote

I'm not sure if the Apache Lounge build is done with Release or RelWithDebInfo - you'd need to ask them.

Looking at your PHP topic, I believe James Blond has given you appropriate answers to your question. Building PHP versions from scratch, with a full set of matching extensions, is notoriously difficult, especially on Windows.

I'd download the pre-compiled binaries for the versions you want from https://windows.php.net/downloads/releases/archives, and then run PHP code through Apache using fcgid. Earlier in this topic I posted that you should build fcgid after httpd. It's quite straightforward and comes with support for CMake, e.g. for mod_fcgid-2.3.9

Code:
cd /d C:\Development\Apache24\build\mod_fcgid
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=Release -DINSTALL_PDB=OFF ..\..\src\mod_fcgid-2.3.9\modules\fcgid
nmake
nmake install


...
...
[100%] Built target mod_fcgid
Install the project...
-- Install configuration: "Release"
-- Installing: C:/Apache24/modules/mod_fcgid.so

Apart from this site, (e.g. https://www.apachelounge.com/viewtopic.php?t=2513), there a few articles out on the net about running PHP through fcgid. I found this old one for Windows - http://fuzzytolerance.info/blog/2009/11/09/2009-11-09-apache-mod_fcgid-and-php-on-windows. With the appropriate fcgid entries in httpd.conf, you should be good to go, mixing x64 and x86 binaries as you choose fit.

This site is run using PHP, and I'd wager they're using mod_fcgid!
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 58
Location: Vietnam

PostPosted: Sun 23 Aug '20 19:00    Post subject: Reply with quote

Sadly PHP 5.3 and 5.4 have no x64 release, only x86 version. X86 versions won't work on Apache x64, that's why I need to find their x64 version.
But also thank you very much. Neutral
Back to top
admin
Site Admin


Joined: 15 Oct 2005
Posts: 685

PostPosted: Tue 25 Aug '20 21:47    Post subject: Reply with quote

Indeed @tangent. Apachelounge runs mod_fcgid only.

Thanks for jumping in.
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 58
Location: Vietnam

PostPosted: Sat 12 Jun '21 19:47    Post subject: Reply with quote

The latest Apache version (2.4.4Cool has had many changes that can no longer be compiled the old way. I got a few errors here: https://stackoverflow.com/questions/67944929/error-lnk2019-unresolved-external-symbol-referenced-when-compile-httpd
Can you review it?
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 346
Location: UK

PostPosted: Sun 13 Jun '21 11:20    Post subject: Reply with quote

Can I suggest you look at the following two topics, which outline an alternative method for compiling Apache and related support packages with CMake:

https://www.apachelounge.com/viewtopic.php?t=8609
https://www.apachelounge.com/viewtopic.php?t=8627

I've yet to update these topics for Apache 2.4.48, and the latest Openssl, Curl, etc. (I've been busy elsewhere of late), but the method and details are sound. Notably, you can compare the CMake options I've chosen to use, with those in your build process.

Specifically, with Curl, I build it twice; once with BUILD_SHARED_LIBS=ON and again with BUILD_SHARED_LIBS=OFF, since we need both static and dynamic libraries.

Also take a look at the discussion over Curl support for OpenSSL as well as Schannel. This also has a direct bearing on Apache module mod_md, as much as libcurl.lib
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 58
Location: Vietnam

PostPosted: Mon 14 Jun '21 2:12    Post subject: Reply with quote

You say cURL you will compile 2 times, the order is -DBUILD_SHARED_LIBS=ON first and -DBUILD_SHARED_LIBS=OFF is it correct?
Is this command line I wrote correct?
Code:
==================== Compile Dynamic Libraries ====================
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
nmake
nmake install

==================== Compile Static Libraries ====================
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
nmake
nmake install

Or combine them into:
Code:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
nmake
nmake install
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 346
Location: UK

PostPosted: Mon 14 Jun '21 21:46    Post subject: Reply with quote

You need the first of these two options for CURL. Build, make, install; twice. If you look at the CMakeLists.txt file for CURL, it doesn't support building both static and dynamic in the one pass, viz:
Code:
if(BUILD_SHARED_LIBS)
  set(ENABLE_SHARED         "yes")
  set(ENABLE_STATIC         "no")
  set(LIBCURL_NO_SHARED     "")
else()
  set(ENABLE_SHARED         "no")
  set(ENABLE_STATIC         "yes")
  set(LIBCURL_NO_SHARED     "${LIBCURL_LIBS}")
endif()

I would, however, suggest you may need some additional CMake options, as per those detailed in the first of those above topics.
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 58
Location: Vietnam

PostPosted: Mon 14 Jun '21 23:27    Post subject: Reply with quote

I got it. The problem I had on HTTPD 2.4.48 was that I had to specify libcurl in the CMakeLists.txt file, or else the same error occurred to me.
Back to top


Reply to topic   Topic: How do I compile Apache with all modules? View previous topic :: View next topic
Post new topic   Forum Index -> Building & Member Downloads