### Installing Log and CGI-Bin Directories Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Ensures that the logs and cgi-bin directories are created at the installation root. ```cmake INSTALL(DIRECTORY DESTINATION logs) INSTALL(DIRECTORY DESTINATION cgi-bin) ``` -------------------------------- ### Installing Support Executable Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Installs the ctlogconfig support executable to the bin directory. ```cmake INSTALL(FILES support/ctlogconfig DESTINATION bin) ``` -------------------------------- ### Install Configuration Files on Windows Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Installs configuration files using xcopy command for Windows environments. ```cmake INSTALL(CODE "EXECUTE_PROCESS(COMMAND xcopy \"${native_src}\" \"${native_dest}\" /Q /S /Y)") ``` -------------------------------- ### Installing Header Files Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Installs header files (.h) from the include/ directory and any other specified header files to the include destination. ```cmake INSTALL(DIRECTORY include/ DESTINATION include FILES_MATCHING PATTERN "*.h" ) INSTALL(FILES ${other_installed_h} DESTINATION include) ``` -------------------------------- ### Initializing Installation and Module Lists Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Initializes variables for tracking installation targets, PDB files, and module lists. This sets up the framework for managing build outputs and static modules. ```cmake SET(install_targets) SET(install_bin_pdb) SET(install_modules) # special handling vs. other installed targets SET(install_modules_pdb) SET(builtin_module_shortnames) LIST(APPEND builtin_module_shortnames "win32" "mpm_winnt" "http" "so") # core added automatically SET(extra_builtin_modules) # the ones specified with -DWITH_MODULES= STRING(REPLACE "," ";" WITH_MODULE_LIST "${WITH_MODULES}") FOREACH(static_mod ${WITH_MODULE_LIST}) STRING(REGEX MATCH "[^/]+\\.c" mod_basename ${static_mod}) STRING(REGEX REPLACE "^mod_(.*)\\.c" "\1" mod_module_name ${mod_basename}) ``` -------------------------------- ### Installing Library Export Files Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Installs library export files, which are necessary for linking against the installed libraries, to the lib destination. ```cmake INSTALL(FILES ${installed_mod_libs_exps} DESTINATION lib) ``` -------------------------------- ### XML Code Example Structure Source: https://github.com/apache/httpd/blob/trunk/docs/manual/AGENTS.md Use the `` element with nested `` for code examples. Valid language values include `config`, `lua`, `c`, `perl`, `sh`, and `html`. Avoid legacy patterns with `
`. ```xml Listen 80 Listen 8000 ``` -------------------------------- ### Installing Executable Targets Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Installs the main executable targets and their associated runtime, library, and archive files to their respective destinations. ```cmake INSTALL(TARGETS ${install_targets} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) ``` -------------------------------- ### Install Dependencies with uv Source: https://github.com/apache/httpd/blob/trunk/test/pytest_suite/README.md Installs the necessary Python dependencies (pytest and httpx) using uv. This command should be run within the virtual environment. ```sh # 1. Create the virtualenv (pytest + httpx). Needs `uv` (https://docs.astral.sh/uv/), # or substitute a plain venv -- see "Environment" below. uv sync ``` -------------------------------- ### Installing Library Export File for libhttpd Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Installs the specific export file for the libhttpd library to the LIB destination. ```cmake INSTALL(FILES "$/libhttpd.exp" DESTINATION LIB) ``` -------------------------------- ### Installing Module Targets Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Installs the module targets, typically shared libraries, to the modules directory. ```cmake INSTALL(TARGETS ${install_modules} RUNTIME DESTINATION modules ) ``` -------------------------------- ### Build Support Executables Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Iterates through a list of standard support programs, defining each as an executable with its source files, resource file, and setting installation properties. ```cmake FOREACH(pgm ${standard_support}) SET(extra_sources ${pgm}_extra_sources) ADD_EXECUTABLE(${pgm} support/${pgm}.c build/win32/httpd.rc ${${extra_sources}}) SET(install_targets ${install_targets} ${pgm}) SET(install_bin_pdb ${install_bin_pdb} $) TARGET_COMPILE_DEFINITIONS(${pgm} PRIVATE "APP_FILE" "LONG_NAME=Apache HTTP Server ${pgm} program" "BIN_NAME=${pgm}.exe" ) TARGET_COMPILE_OPTIONS(${pgm} PRIVATE "${EXTRA_COMPILE_FLAGS}") TARGET_LINK_LIBRARIES(${pgm} ${EXTRA_LIBS} ${APR_LIBRARIES}) ENDFOREACH() ``` -------------------------------- ### Conditional Installation of Manual Directory Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Installs the documentation manual from docs/manual/ to the manual destination, but only if the INSTALL_MANUAL variable is set to true. This is often disabled for development builds. ```cmake IF(INSTALL_MANUAL) # Silly? This takes a while, and a dev doesn't need it. INSTALL(DIRECTORY docs/manual/ DESTINATION manual) ENDIF() ``` -------------------------------- ### Install mod_lua as a Web App Source: https://github.com/apache/httpd/blob/trunk/docs/server-status/README.md Enable .lua script handling in your VirtualHost configuration by adding the AddHandler directive. Place the .lua script in your document root. ```apache AddHandler lua-script .lua ``` -------------------------------- ### Display Apache httpd Configuration Summary Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Prints a detailed summary of the Apache httpd build configuration, including build type, installation paths, compiler, and library details. ```cmake STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype) MESSAGE(STATUS "") MESSAGE(STATUS "") MESSAGE(STATUS "Apache httpd configuration summary:") MESSAGE(STATUS "") MESSAGE(STATUS " Build type ...................... : ${CMAKE_BUILD_TYPE}") MESSAGE(STATUS " Install .pdb (if available)...... : ${INSTALL_PDB}") MESSAGE(STATUS " Install manual .................. : ${INSTALL_MANUAL}") MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}") MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}") MESSAGE(STATUS " APR include directory ........... : ${APR_INCLUDE_DIR}") MESSAGE(STATUS " APR libraries ................... : ${APR_LIBRARIES}") MESSAGE(STATUS " OpenSSL include directory ....... : ${OPENSSL_INCLUDE_DIR}") MESSAGE(STATUS " OpenSSL libraries ............... : ${OPENSSL_LIBRARIES}") MESSAGE(STATUS " PCRE include directory .......... : ${PCRE_INCLUDE_DIR}") MESSAGE(STATUS " PCRE libraries .................. : ${PCRE_LIBRARIES}") MESSAGE(STATUS " libxml2 iconv prereq include dir. : ${LIBXML2_ICONV_INCLUDE_DIR}") MESSAGE(STATUS " libxml2 iconv prereq libraries .. : ${LIBXML2_ICONV_LIBRARIES}") MESSAGE(STATUS " Brotli include directory......... : ${BROTLI_INCLUDE_DIR}") MESSAGE(STATUS " Brotli libraries ................ : ${BROTLI_LIBRARIES}") MESSAGE(STATUS " Check include directory.......... : ${CHECK_INCLUDE_DIR}") MESSAGE(STATUS " Check libraries ................. : ${CHECK_LIBRARIES}") MESSAGE(STATUS " Curl include directory........... : ${CURL_INCLUDE_DIR}") MESSAGE(STATUS " Curl libraries .................. : ${CURL_LIBRARIES}") MESSAGE(STATUS " Jansson include directory ....... : ${JANSSON_INCLUDE_DIR}") MESSAGE(STATUS " Jansson libraries ............... : ${JANSSON_LIBRARIES}") MESSAGE(STATUS " Extra include directories ....... : ${EXTRA_INCLUDES}") MESSAGE(STATUS " Extra compile flags ............. : ${EXTRA_COMPILE_FLAGS}") MESSAGE(STATUS " Extra libraries ................. : ${EXTRA_LIBS}") ``` -------------------------------- ### Install mod_lua as a Handler Source: https://github.com/apache/httpd/blob/trunk/docs/server-status/README.md Configure httpd.conf to map a URL to the mod_lua script using LuaMapHandler. Ensure the path to your script is correct. ```apache LuaMapHandler ^/server-status$ /path/to/server-status.lua ``` -------------------------------- ### Check mod_proxy_beacon presence (shared build) Source: https://github.com/apache/httpd/blob/trunk/modules/proxy/mod_proxy_beacon-guide.md Verify if mod_proxy_beacon is installed and loaded when using a shared build. ```sh httpd -M 2>&1 | grep proxy_beacon ``` -------------------------------- ### Setup Script for Motorz MPM Tests Source: https://github.com/apache/httpd/blob/trunk/server/mpm/motorz/test/README.md Use this script to configure, build, and verify modules for the Motorz MPM tests. It can also force a reconfigure or control make parallelism. ```sh server/mpm/motorz/test/setup.sh # configure (if needed) + build + verify server/mpm/motorz/test/setup.sh --reconfigure # force a fresh ./configure server/mpm/motorz/test/setup.sh --jobs 8 # control make parallelism ``` -------------------------------- ### Define a Lua Handler Function for Apache Source: https://github.com/apache/httpd/blob/trunk/modules/lua/docs/writing-handlers.txt This is an example of a basic handler function in Lua for mod_lua. It sets the content type, prints a greeting, and then processes GET or POST requests by printing arguments or form data. Ensure the 'string' module is required if string manipulation is needed. ```lua -- example.lua -- require "string" function handle_something(r) r.content_type = "text/plain" r:puts("Hello Lua World!\n") if r.method == 'GET' then for k, v in pairs( r:parseargs() ) do r:puts( string.format("%s: %s", k, v) ) end elseif r.method == 'POST' then for k, v in pairs( r:parsebody() ) do r:puts( string.format("%s: %s", k, v) ) end else r:puts("unknown HTTP method " .. r.method) end end ``` -------------------------------- ### Lua Hook Example Implementation Source: https://github.com/apache/httpd/blob/trunk/modules/lua/docs/basic-configuration.txt Example Lua code for a hook function that maps the root URI to a specific file and returns an appropriate status code. ```lua function silly_mapper(r) if r.uri == "/" then r.file = "/var/www/home.lua" return apache2.OK else return apache2.DECLINED end end ``` -------------------------------- ### Processing Configuration File Templates Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Finds all .conf.in files, reads their content, performs variable substitution using STRING(CONFIGURE), and writes the processed .conf files to both the build and install directories. This allows for dynamic configuration generation. ```cmake FILE(GLOB_RECURSE conffiles RELATIVE ${CMAKE_SOURCE_DIR}/docs/conf "docs/conf/*") FOREACH(template ${conffiles}) STRING(REPLACE ".conf.in" ".conf" conf "${template}") FILE(READ "docs/conf/${template}" template_text) IF(template MATCHES ".conf.in$") # substitute @var@/@@var@@ in .conf.in STRING(REPLACE "@@" "@" template_text "${template_text}") STRING(CONFIGURE "${template_text}" template_text @ONLY) ENDIF() FILE(WRITE ${CMAKE_BINARY_DIR}/conf/original/${conf} "${template_text}") FILE(WRITE ${CMAKE_BINARY_DIR}/conf/${conf} "${template_text}") ENDFOREACH() ``` -------------------------------- ### Define HTTPD Executable Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Creates the main httpd executable target from server/main.c and a Windows resource file. It's added to installation targets and PDB file tracking. ```cmake ADD_EXECUTABLE(httpd server/main.c build/win32/httpd.rc) SET(install_targets ${install_targets} httpd) SET(install_bin_pdb ${install_bin_pdb} $) ``` -------------------------------- ### Conditional Installation of PDB Files Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Installs Program Database (PDB) files for debugging symbols for both executable and module targets, but only if the INSTALL_PDB variable is set to true. This is typically done for Debug and RelWithDebInfo configurations. ```cmake IF(INSTALL_PDB) INSTALL(FILES ${install_bin_pdb} DESTINATION bin CONFIGURATIONS RelWithDebInfo Debug) INSTALL(FILES ${install_modules_pdb} DESTINATION modules CONFIGURATIONS RelWithDebInfo Debug) ENDIF() ``` -------------------------------- ### Manual Configuration for Motorz MPM Build Source: https://github.com/apache/httpd/blob/trunk/server/mpm/motorz/test/README.md Manually configure the httpd build with specific MPMs and modules. Ensure autoconf, libtool, and python3 are installed for fresh checkouts. ```sh # from the build top. (Run ./buildconf first only on a fresh git checkout that # has no ./configure; needs autoconf + libtool + python3.) ./configure --with-included-apr \ --enable-mpms-shared='event motorz' \ --enable-so --enable-unixd \ --enable-authz_core --enable-authz_host --enable-log_config \ --enable-mime --enable-dir \ --enable-socache_shmcb --enable-ssl --enable-http2 make ``` -------------------------------- ### Detecting Check Libraries Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt This snippet checks for check.lib and compat.lib in the installation prefix to set the default Check libraries. If not found, it defaults to an empty list. ```cmake IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/check.lib") SET(default_check_libraries "${CMAKE_INSTALL_PREFIX}/lib/check.lib" "${CMAKE_INSTALL_PREFIX}/lib/compat.lib") ELSE() SET(default_check_libraries) ENDIF() ``` -------------------------------- ### Copying Generated Configuration Files Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Copies the generated .conf files from the build directory to the installation's conf directory. The 'original' subdirectory is explicitly intended to be overwritten. ```cmake # Copy generated .conf files from the build directory to the install, # without overwriting stuff already there. INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl \"${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl\" \"${CMAKE_BINARY_DIR}/conf\" \"${CMAKE_INSTALL_PREFIX}/conf\")") # But conf/original is supposed to be overwritten. # Note: FILE(TO_NATIVE_PATH ...) leaves the backslashes unescaped, which # generates warnings. Just do it manually since this build only supports ``` -------------------------------- ### Initialize Module Library List Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Initializes a list to track installed module libraries that have linkable APIs. This variable is used later to collect information about built modules. ```cmake SET(installed_mod_libs_exps) ``` -------------------------------- ### Detecting cURL Libraries Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt This snippet checks for libcurl_imp.lib or libcurl.lib in the installation prefix to set the default cURL libraries. If neither is found, it defaults to an empty list. ```cmake IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/libcurl_imp.lib") SET(default_curl_libraries "${CMAKE_INSTALL_PREFIX}/lib/libcurl_imp.lib") ELSEIF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/libcurl.lib") SET(default_curl_libraries "${CMAKE_INSTALL_PREFIX}/lib/libcurl.lib") ELSE() SET(default_curl_libraries) ENDIF() ``` -------------------------------- ### Detecting Brotli Libraries Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt This snippet checks for brotlienc.lib and brotlicommon.lib in the installation prefix to set the default Brotli libraries. If not found, it defaults to an empty list. ```cmake IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/brotlienc.lib") SET(default_brotli_libraries "${CMAKE_INSTALL_PREFIX}/lib/brotlienc.lib" "${CMAKE_INSTALL_PREFIX}/lib/brotlicommon.lib") ELSE() SET(default_brotli_libraries) ENDIF() ``` -------------------------------- ### Detecting NGHTTP2 Libraries Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt This snippet checks for the presence of nghttp2d.lib or nghttp2.lib in the installation prefix and sets the default NGHTTP2 libraries accordingly. ```cmake IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/nghttp2d.lib") SET(default_nghttp2_libraries "${CMAKE_INSTALL_PREFIX}/lib/nghttp2d.lib") ELSE() SET(default_nghttp2_libraries "${CMAKE_INSTALL_PREFIX}/lib/nghttp2.lib") ENDIF() ``` -------------------------------- ### Using t_cmp for Assertions Source: https://github.com/apache/httpd/blob/trunk/test/pytest_suite/README.md This example shows how to use the `t_cmp` helper function for assertions, which supports both string equality and regular expression matching. It's useful for comparing received values against expected patterns or exact strings. ```python from apache_pytest import t_cmp assert t_cmp(r.status_code, 200), "status" assert t_cmp(r.headers.get("Allow", ""), re.compile("OPTIONS")), "Allow header" ``` -------------------------------- ### Configure libhttpd Target Properties Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Sets linker flags and adds the libhttpd target to installation lists. This is typically used for shared library builds. ```cmake SET_TARGET_PROPERTIES(libhttpd PROPERTIES LINK_FLAGS /base:@${PROJECT_BINARY_DIR}/BaseAddr.ref,libhttpd.dll ) SET(install_targets ${install_targets} libhttpd) SET(install_bin_pdb ${install_bin_pdb} $) ``` -------------------------------- ### Reverse Proxy Configuration Source: https://github.com/apache/httpd/blob/trunk/modules/proxy/mod_proxy_beacon-guide.md Configure the reverse proxy to listen for backend announcements, set a shared secret, and define the target balancer cluster. This setup allows the proxy to automatically manage backend members. ```apache ProxySet growth=16 ProxyPass "/" "balancer://cluster/" ProxyPassReverse "/" "balancer://cluster/" ``` -------------------------------- ### Configuring Session and SSL Modules Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Sets up configurations for session and SSL modules, including defines, requirements, and library paths. Conditional logic is used for SSL dependencies. ```cmake SET(mod_serf_requires AN_UNIMPLEMENTED_SUPPORT_LIBRARY_REQUIREMENT) ``` ```cmake SET(mod_session_extra_defines SESSION_DECLARE_EXPORT) SET(mod_session_install_lib 1) SET(mod_session_cookie_extra_libs mod_session) SET(mod_session_crypto_requires APU_HAVE_CRYPTO) SET(mod_session_crypto_extra_libs mod_session) SET(mod_session_dbd_extra_libs mod_session) ``` ```cmake SET(mod_socache_dc_requires AN_UNIMPLEMENTED_SUPPORT_LIBRARY_REQUIREMENT) ``` ```cmake SET(mod_ssl_extra_defines SSL_DECLARE_EXPORT) SET(mod_ssl_requires OPENSSL_FOUND) IF(OPENSSL_FOUND) SET(mod_ssl_extra_includes ${OPENSSL_INCLUDE_DIR}) SET(mod_ssl_extra_libs ${OPENSSL_LIBRARIES}) ENDIF() SET(mod_ssl_extra_sources modules/ssl/ssl_engine_config.c modules/ssl/ssl_engine_init.c modules/ssl/ssl_engine_io.c modules/ssl/ssl_engine_kernel.c modules/ssl/ssl_engine_log.c modules/ssl/ssl_engine_mutex.c modules/ssl/ssl_engine_ocsp.c modules/ssl/ssl_engine_pphrase.c modules/ssl/ssl_engine_rand.c modules/ssl/ssl_engine_vars.c modules/ssl/ssl_scache.c modules/ssl/ssl_util.c modules/ssl/ssl_util_ocsp.c modules/ssl/ssl_util_ssl.c modules/ssl/ssl_util_stapling.c ) ``` ```cmake IF(OPENSSL_FOUND) SET(mod_ssl_ct_extra_includes ${OPENSSL_INCLUDE_DIR}) SET(mod_ssl_ct_extra_libs ${OPENSSL_LIBRARIES}) ENDIF() SET(mod_ssl_ct_extra_sources modules/ssl/ssl_ct_log_config.c modules/ssl/ssl_ct_sct.c modules/ssl/ssl_ct_util.c ) ``` -------------------------------- ### Define 'ab' Benchmark Executable Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Creates the 'ab' (ApacheBench) executable target from support/ab.c and a Windows resource file. It includes specific include directories and compile definitions. ```cmake ADD_EXECUTABLE(ab support/ab.c build/win32/httpd.rc) SET(install_targets ${install_targets} ab) SET(install_bin_pdb ${install_bin_pdb} $) SET(tmp_includes ${HTTPD_INCLUDE_DIRECTORIES}) SET_TARGET_PROPERTIES(ab PROPERTIES INCLUDE_DIRECTORIES "${tmp_includes}") TARGET_COMPILE_DEFINITIONS(ab PRIVATE "APP_FILE" "LONG_NAME=Apache HTTP Server ab program" "BIN_NAME=ab.exe" ) TARGET_LINK_LIBRARIES(ab ${EXTRA_LIBS} ${APR_LIBRARIES} Ws2_32.lib) ``` -------------------------------- ### Run Specific Test Categories or Files Source: https://github.com/apache/httpd/blob/trunk/test/pytest_suite/README.md Demonstrates how to run specific parts of the test suite, such as a particular category of tests or a single test file. ```sh ./runtests.sh tests/t/modules # run one category ./runtests.sh tests/t/modules/test_alias.py # run one file ``` -------------------------------- ### Detecting Jansson Libraries Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt This snippet checks for jansson.lib in the installation prefix to set the default Jansson libraries. If not found, it defaults to an empty list. ```cmake IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/jansson.lib") SET(default_jansson_libraries "${CMAKE_INSTALL_PREFIX}/lib/jansson.lib") ELSE() SET(default_jansson_libraries) ENDIF() ``` -------------------------------- ### Configure and Build mod_lua Source: https://github.com/apache/httpd/blob/trunk/modules/lua/docs/building-from-subversion.txt Configure mod_lua with paths to Lua, Apache HTTPD's apxs, and libapreq2. Ensure libapreq2 headers are found during compilation. ```bash ./configure --with-lua=/Users/brianm/.opt/lua-5.1.2/ \ --with-apxs=/Users/brianm/.opt/httpd-2.2.4-worker-wombat/bin/apxs \ --with-apreq2=/Users/brianm/.opt/libapreq2-2.0.8/ ``` -------------------------------- ### Configure libapreq2 Source: https://github.com/apache/httpd/blob/trunk/modules/lua/docs/building-from-subversion.txt Configure libapreq2, ensuring it is built with a --prefix option for compatibility. This is required for parsing entity bodies with mod_lua. ```bash ./configure --prefix=/Users/brianm/.opt/libapreq2-2.0.8 \ --with-apache2-apxs=/Users/brianm/.opt/httpd-2.2.4-worker-wombat/bin/apxs ``` -------------------------------- ### Configure Apache HTTPD 2.2 Source: https://github.com/apache/httpd/blob/trunk/modules/lua/docs/building-from-subversion.txt Configure Apache HTTPD with dynamic module loading enabled. The --with-mpm=worker flag is recommended for mod_lua. ```bash ./configure --prefix=/Users/brianm/.opt/httpd-2.2.4-worker-wombat \ --with-mpm=worker \ --enable-so ``` -------------------------------- ### Backend Configuration Source: https://github.com/apache/httpd/blob/trunk/modules/proxy/mod_proxy_beacon-guide.md Configure each backend to announce its address and advertisement URL to the proxy at a specified interval using a shared secret. This enables dynamic membership in the load balancer. ```apache # Announce this backend's routable origin to the proxy every 10s (UDP). ProxyBeaconAddress proxy.example.com:5555 ProxyBeaconAdvertise http://10.0.0.5:8080 ProxyBeaconSecret "a-long-random-shared-cluster-secret" ProxyBeaconInterval 10 ``` -------------------------------- ### Run mod_lua Tests Source: https://github.com/apache/httpd/blob/trunk/modules/lua/docs/running-developer-tests.txt Navigate to the test directory and execute the test script using Lua. Ensure Apache is running and configured. ```bash cd test lua ./test.lua ``` ```bash lua-5.1 ./test.lua ``` -------------------------------- ### Run the Full Test Suite Source: https://github.com/apache/httpd/blob/trunk/test/pytest_suite/README.md Executes the entire test suite against a specified Apache httpd build. The --apxs option points to the Apache Portable Runtime Extension tool. ```sh # 2. Run the whole suite against your httpd build. ./runtests.sh --apxs /path/to/your/httpd/bin/apxs ``` -------------------------------- ### Define Standard Support Executables Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Sets a list of standard support executables to be built, including htcacheclean, htdbm, htdigest, htpasswd, httxt2dbm, logresolve, and rotatelogs. ```cmake SET(standard_support htcacheclean htdbm htdigest htpasswd httxt2dbm logresolve rotatelogs ) ``` -------------------------------- ### SSL and Client Certificate Testing Source: https://github.com/apache/httpd/blob/trunk/test/pytest_suite/README.md Configure the client to use HTTPS and optionally present test client certificates for authentication. The framework automatically generates necessary certificates and manages trust. ```python from apache_pytest import need_ssl @need_ssl() def test_client_cert(http): http.scheme("https") assert http.GET_RC("/require/asf/index.html", cert="client_ok") == 200 assert http.GET_RC("/require/asf/index.html", cert=None) != 200 ``` -------------------------------- ### JavaScript Multi-Substitution Regex Test Source: https://github.com/apache/httpd/blob/trunk/test/pytest_suite/t/htdocs/modules/proxy_html/multi_subst_rx.html Defines multiple URL variables and a sentinel value for a regex substitution test. This setup is used to verify the functionality of multi-substitution within a buffer. ```javascript var u01='http://rx/u01';var u02='http://rx/u02';var u03='http://rx/u03';var u04='http://rx/u04';var u05='http://rx/u05';var u06='http://rx/u06';var u07='http://rx/u07';var u08='http://rx/u08';var u09='http://rx/u09';var u10='http://rx/u10';var u11='http://rx/u11';var u12='http://rx/u12';var u13='http://rx/u13';var u14='http://rx/u14';var u15='http://rx/u15';var u16='http://rx/u16';var u17='http://rx/u17';var u18='http://rx/u18';var u19='http://rx/u19';var u20='http://rx/u20';var u21='http://rx/u21';var u22='http://rx/u22';var u23='http://rx/u23';var u24='http://rx/u24';var u25='http://rx/u25';var u26='http://rx/u26';var u27='http://rx/u27';var u28='http://rx/u28';var u29='http://rx/u29';var u30='http://rx/u30';var u31='http://rx/u31';var u32='http://rx/u32';var u33='http://rx/u33';var u34='http://rx/u34';var u35='http://rx/u35';var u36='http://rx/u36';var u37='http://rx/u37';var u38='http://rx/u38';var u39='http://rx/u39';var u40='http://rx/u40';var sentinel='RX_CDATA_END_OK'; ``` -------------------------------- ### Bootstrap mod_lua from Subversion Source: https://github.com/apache/httpd/blob/trunk/modules/lua/docs/building-from-subversion.txt Bootstrap the autoconf environment for mod_lua when building from subversion. This script sets up the autoconf magic. ```bash ./bootstrap ``` -------------------------------- ### List Apache httpd Modules Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Iterates through lists of modules and prints their status (built and loaded, built but not loaded, or not built). ```cmake MESSAGE(STATUS " Modules built and loaded:") FOREACH(mod ${mods_built_and_loaded}) MESSAGE(STATUS " ${mod}") ENDFOREACH() MESSAGE(STATUS " Modules built but not loaded:") FOREACH(mod ${mods_built_but_not_loaded}) MESSAGE(STATUS " ${mod}") ENDFOREACH() MESSAGE(STATUS " Modules not built:") FOREACH(mod ${mods_omitted}) MESSAGE(STATUS " ${mod}") ENDFOREACH() ``` -------------------------------- ### Setting CMake Variables Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Defines variables used for configuring the httpd server, such as ports, installation paths, and directories for logs and configuration files. These variables are often used in template files. ```cmake SET(LoadModule "${LoadModules}") SET(Port "80" CACHE STRING "http port to listen on") SET(SSLPort "443" CACHE STRING "https port to listen on") SET(ServerRoot "${CMAKE_INSTALL_PREFIX}") SET(exp_cgidir "${CMAKE_INSTALL_PREFIX}/cgi-bin") SET(exp_htdocsdir "${CMAKE_INSTALL_PREFIX}/htdocs") SET(exp_iconsdir "${CMAKE_INSTALL_PREFIX}/icons") SET(exp_errordir "${CMAKE_INSTALL_PREFIX}/error") SET(exp_manualdir "${CMAKE_INSTALL_PREFIX}/manual") SET(rel_logfiledir "logs") SET(rel_runtimedir "logs") SET(rel_sysconfdir "conf") ``` -------------------------------- ### Executing Perl Script to Copy Directories Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Uses a Perl script (cpR_noreplace.pl) to copy directories like error, htdocs, and icons to their respective installation destinations. The 'ifdestmissing' option prevents overwriting existing files. ```cmake INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl \"${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl\" \"${CMAKE_CURRENT_SOURCE_DIR}/docs/error\" \"${CMAKE_INSTALL_PREFIX}/error\" ifdestmissing)") ``` ```cmake INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl \"${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl\" \"${CMAKE_CURRENT_SOURCE_DIR}/docs/docroot\" \"${CMAKE_INSTALL_PREFIX}/htdocs\" ifdestmissing)") ``` ```cmake INSTALL(CODE "EXECUTE_PROCESS(COMMAND perl \"${CMAKE_CURRENT_SOURCE_DIR}/build/cpR_noreplace.pl\" \"${CMAKE_CURRENT_SOURCE_DIR}/docs/icons\" \"${CMAKE_INSTALL_PREFIX}/icons\" ifdestmissing)") ``` -------------------------------- ### Enable balancer-manager Interface Source: https://github.com/apache/httpd/blob/trunk/modules/proxy/mod_proxy_beacon-guide.md Enable the balancer-manager interface to view and manage proxy members. Requires Apache configuration. ```apache SetHandler balancer-manager Require host localhost ``` -------------------------------- ### JavaScript Variable Declarations for URL Substitution Source: https://github.com/apache/httpd/blob/trunk/test/pytest_suite/t/htdocs/modules/proxy_html/multi_subst.html This snippet demonstrates the setup for a multi-substitution test by declaring numerous JavaScript variables, each holding a URL. This is typically used to prepare for tests involving dynamic content replacement or proxying. ```javascript var u01='http://x/u01';var u02='http://x/u02';var u03='http://x/u03';var u04='http://x/u04';var u05='http://x/u05';var u06='http://x/u06';var u07='http://x/u07';var u08='http://x/u08';var u09='http://x/u09';var u10='http://x/u10';var u11='http://x/u11';var u12='http://x/u12';var u13='http://x/u13';var u14='http://x/u14';var u15='http://x/u15';var u16='http://x/u16';var u17='http://x/u17';var u18='http://x/u18';var u19='http://x/u19';var u20='http://x/u20';var u21='http://x/u21';var u22='http://x/u22';var u23='http://x/u23';var u24='http://x/u24';var u25='http://x/u25';var u26='http://x/u26';var u27='http://x/u27';var u28='http://x/u28';var u29='http://x/u29';var u30='http://x/u30';var u31='http://x/u31';var u32='http://x/u32';var u33='http://x/u33';var u34='http://x/u34';var u35='http://x/u35';var u36='http://x/u36';var u37='http://x/u37';var u38='http://x/u38';var u39='http://x/u39';var u40='http://x/u40';var sentinel='CDATA_END_OK'; ``` -------------------------------- ### Check mod_proxy_beacon presence (static build) Source: https://github.com/apache/httpd/blob/trunk/modules/proxy/mod_proxy_beacon-guide.md Verify if mod_proxy_beacon is compiled into httpd when using a static build. ```sh httpd -l | grep mod_proxy_beacon ``` -------------------------------- ### Defining System Libraries for Windows Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Lists essential system libraries required for building on Windows platforms. ```cmake SET(HTTPD_SYSTEM_LIBS ws2_32 mswsock ) ``` -------------------------------- ### Minimal Pytest Test Example Source: https://github.com/apache/httpd/blob/trunk/test/pytest_suite/README.md This snippet demonstrates the basic structure of a pytest test function within the Apache HTTPD test suite. It uses the `http` fixture to interact with the test server and the `@need_module` decorator to ensure the `status` module is loaded, otherwise skipping the test. ```python import re from apache_pytest import need_module @need_module("status") # skip unless mod_status is loaded def test_server_status(http): servername = http.vars("servername") body = http.GET_BODY("/server-status") assert re.search(f"Apache Server Status for {servername}", body, re.I) ``` -------------------------------- ### Compile Definitions for httpd Executable Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Sets preprocessor macros for the httpd executable, defining it as an application file with specific long and binary names, and an icon file. ```cmake TARGET_COMPILE_DEFINITIONS(httpd PRIVATE "APP_FILE" "LONG_NAME=Apache HTTP Server" "BIN_NAME=httpd.exe" "ICON_FILE=${CMAKE_SOURCE_DIR}/build/win32/apache.ico" ) ``` -------------------------------- ### Run Tests with Pytest Arguments Source: https://github.com/apache/httpd/blob/trunk/test/pytest_suite/README.md Shows how to pass standard pytest arguments, like -k for keyword selection and -v for verbose output, through the runtests.sh script. ```sh ./runtests.sh -k rewrite -v # any pytest args pass through ``` -------------------------------- ### Create Unit Test Directory Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Ensures that the build directory for unit tests exists. ```cmake FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/test/unit") ``` -------------------------------- ### XML Markup for Placeholders and Emphasis Source: https://github.com/apache/httpd/blob/trunk/docs/manual/AGENTS.md Use `` for user-supplied placeholder values and `` for rhetorical emphasis. Ensure correct usage to maintain documentation clarity. ```xml Listen port

Replace hostname with your server's FQDN.

``` -------------------------------- ### Setting Module-Specific Libraries and Includes Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Defines extra libraries and include directories for various proxy modules. These settings are crucial for linking against necessary dependencies. ```cmake SET(mod_proxy_express_extra_libs mod_proxy) SET(mod_proxy_fcgi_extra_libs mod_proxy) SET(mod_proxy_ftp_extra_libs mod_proxy) SET(mod_proxy_hcheck_extra_libs mod_proxy) SET(mod_proxy_http_extra_libs mod_proxy) ``` ```cmake SET(mod_proxy_html_requires LIBXML2_FOUND) IF(LIBXML2_FOUND) SET(mod_proxy_html_extra_includes "${LIBXML2_INCLUDE_DIR};${LIBXML2_ICONV_INCLUDE_DIR}") SET(mod_proxy_html_extra_libs "${LIBXML2_LIBRARIES};${LIBXML2_ICONV_LIBRARIES}") ENDIF() ``` ```cmake SET(mod_proxy_scgi_extra_libs mod_proxy) SET(mod_proxy_wstunnel_extra_libs mod_proxy) ``` ```cmake SET(mod_lbmethod_bybusyness_extra_libs mod_proxy) SET(mod_lbmethod_bytraffic_extra_libs mod_proxy) SET(mod_lbmethod_byrequests_extra_libs mod_proxy) SET(mod_lbmethod_heartbeat_extra_libs mod_proxy) ``` ```cmake SET(mod_proxy_http2_requires NGHTTP2_FOUND) SET(mod_proxy_http2_extra_defines ssize_t=long) SET(mod_proxy_http2_extra_includes ${NGHTTP2_INCLUDE_DIR}) SET(mod_proxy_http2_extra_libs ${NGHTTP2_LIBRARIES} mod_proxy) SET(mod_proxy_http2_extra_sources modules/http2/h2_proxy_session.c modules/http2/h2_proxy_util.c ) ``` -------------------------------- ### Configuration Quoting Rules Source: https://github.com/apache/httpd/blob/trunk/docs/manual/AGENTS.md Quote filesystem paths, URLs, AuthName values, and regex patterns within `` blocks. Do not quote bare keywords like `AllowOverride None`. ```config ServerRoot "/usr/local/apache2" Redirect "/" "https://example.com/" AuthName "Restricted Area" RewriteRule "^/old(.*)" "/new$1" ``` -------------------------------- ### XML Markup for Code Elements Source: https://github.com/apache/httpd/blob/trunk/docs/manual/AGENTS.md Use `` for literal strings like filenames and keywords, `` for executables with manual pages, `` for module names, and `` for directive names. Specify the module attribute for directives when referencing outside their own module documentation. ```xml ServerRoot VirtualHost ``` -------------------------------- ### Setting LIBXML2 Configuration Variables Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Sets the include directory and library variables for iconv, used by libxml2. ```cmake SET(LIBXML2_ICONV_INCLUDE_DIR "" CACHE STRING "Directory with iconv include files for libxml2") SET(LIBXML2_ICONV_LIBRARIES "" CACHE STRING "iconv libraries to link with for libxml2") ``` -------------------------------- ### Setting Include Directories Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Specifies the directories to be searched for include files during the build process. ```cmake INCLUDE_DIRECTORIES(${HTTPD_INCLUDE_DIRECTORIES}) ``` -------------------------------- ### Add Lua Package Path Source: https://github.com/apache/httpd/blob/trunk/modules/lua/docs/basic-configuration.txt Extends Lua's module search path. Follows standard Lua conventions for package paths. ```apache LuaPackagePath /scripts/lib/?.lua ``` ```apache LuaPackagePath /scripts/lib/?/init.lua ``` -------------------------------- ### Display Feature Detection Summary Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt This section prints a summary of all detected features and their availability status to the build log. It lists various libraries and modules, indicating whether they were found. ```cmake MESSAGE(STATUS "") MESSAGE(STATUS "Summary of feature detection:") MESSAGE(STATUS "") MESSAGE(STATUS "LIBXML2_FOUND ............ : ${LIBXML2_FOUND}") MESSAGE(STATUS "LUA51_FOUND .............. : ${LUA51_FOUND}") MESSAGE(STATUS "NGHTTP2_FOUND ............ : ${NGHTTP2_FOUND}") MESSAGE(STATUS "OPENSSL_FOUND ............ : ${OPENSSL_FOUND}") MESSAGE(STATUS "ZLIB_FOUND ............... : ${ZLIB_FOUND}") MESSAGE(STATUS "BROTLI_FOUND ............. : ${BROTLI_FOUND}") MESSAGE(STATUS "CURL_FOUND ............... : ${CURL_FOUND}") MESSAGE(STATUS "JANSSON_FOUND ............ : ${JANSSON_FOUND}") MESSAGE(STATUS "CHECK_FOUND .............. : ${CHECK_FOUND}") MESSAGE(STATUS "APR_HAS_LDAP ............. : ${APR_HAS_LDAP}") MESSAGE(STATUS "APR_HAS_XLATE ............ : ${APR_HAS_XLATE}") MESSAGE(STATUS "APU_HAVE_CRYPTO .......... : ${APU_HAVE_CRYPTO}") MESSAGE(STATUS "") ``` -------------------------------- ### Run PHP Tests with Specific PHP-FPM Source: https://github.com/apache/httpd/blob/trunk/test/pytest_suite/README.md Executes the PHP-specific tests, specifying the path to the php-fpm binary to be used. ```sh ./runtests.sh --php-fpm /opt/local/sbin/php-fpm83 tests/t/php # PHP tests ``` -------------------------------- ### Building the Main HTTPD Library Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Defines the shared library for the core HTTPD functionality, including sources and Windows resource files. ```cmake ADD_LIBRARY(libhttpd SHARED ${LIBHTTPD_SOURCES} build/win32/httpd.rc) ``` -------------------------------- ### XML Note and Warning Structure Source: https://github.com/apache/httpd/blob/trunk/docs/manual/AGENTS.md Use `` for informational callouts and `` for critical warnings. Enclose text within `

` tags. Avoid using `Note:` in prose. ```xml

Informational callout text.

Critical warning text.

``` -------------------------------- ### Setting APR Configuration Variables Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Sets the include directory and library variables for APR (Apache Portable Runtime). ```cmake SET(APR_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with APR[-Util] include files") SET(APR_LIBRARIES ${default_apr_libraries} CACHE STRING "APR libraries to link with") ``` -------------------------------- ### Setting Check Configuration Variables Source: https://github.com/apache/httpd/blob/trunk/CMakeLists.txt Sets the include directory and library variables for the Check testing framework. ```cmake SET(CHECK_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with include files for Check") SET(CHECK_LIBRARIES "${default_check_libraries}" CACHE STRING "Check libraries to link with") ```