33
44Configure the `apache2handler` PHP SAPI.
55
6- ## PHP_SAPI_APACHE2HANDLER
6+ ## Configuration options
7+
8+ ### PHP_SAPI_APACHE2HANDLER
79
810* Default: `OFF`
911* Values: `ON|OFF`
1012
1113Enable the shared Apache 2 handler SAPI module.
1214
15+ ## PHP_SAPI_APACHE2HANDLER_INSTALL_DIR
16+
17+ * Default: The path to the Apache modules directory of the host system
18+ (`Apache_LIBEXEC`).
19+
20+ The path where to install the PHP Apache module (`mod_php.so`). Relative path is
21+ interpreted as being relative to the installation prefix `CMAKE_INSTALL_PREFIX`.
22+
23+ ## About
24+
1325Loadable via Apache's Dynamic Shared Object (DSO) support. If Apache will use
1426PHP together with one of the threaded Multi-Processing Modules (MPMs), PHP must
1527be configured and built with `PHP_THREAD_SAFETY` set to `ON`. Thread safety will
@@ -21,11 +33,24 @@ with the `APACHE_ROOT` and `Apache_APXS_EXECUTABLE` variables.
2133
2234For example:
2335
24- ```cmake
36+ ```sh
2537cmake -B php-build -DPHP_SAPI_APACHE2HANDLER=ON -DAPACHE_ROOT=/opt/apache2
2638# or
2739cmake -B php-build -DPHP_SAPI_APACHE2HANDLER=ON -DApache_EXECUTABLE=/opt/apache2/bin/apxs
2840```
41+
42+ The path, where to install the PHP Apache module, can be overridden with the
43+ `PHP_SAPI_APACHE2HANDLER_INSTALL_DIR` variable. This might be used in edge cases
44+ where some specific custom installation prefix is used to avoid insuficcient
45+ permissions of the default location on the host, or when developing the PHP
46+ build system.
47+
48+ ```sh
49+ cmake \
50+ -B <build-dir> \
51+ -DPHP_SAPI_APACHE2HANDLER=ON \
52+ -DPHP_SAPI_APACHE2HANDLER_INSTALL_DIR=/custom/path/to/lib/apache2/modules
53+ ```
2954#]=============================================================================]
3055
3156include (FeatureSummary)
@@ -38,6 +63,15 @@ add_feature_info(
3863 "Apache HTTP server module"
3964)
4065
66+ set (
67+ CACHE {PHP_SAPI_APACHE2HANDLER_INSTALL_DIR}
68+ TYPE STRING
69+ HELP "The path to the Apache modules directory to install PHP Apache module"
70+ VALUE ""
71+ )
72+ set_property (CACHE PHP_SAPI_APACHE2HANDLER_INSTALL_DIR PROPERTY TYPE PATH )
73+ mark_as_advanced (PHP_SAPI_APACHE2HANDLER_INSTALL_DIR)
74+
4175if (NOT PHP_SAPI_APACHE2HANDLER)
4276 return ()
4377endif ()
@@ -75,6 +109,13 @@ set_package_properties(
75109 PURPOSE "Necessary to enable the Apache PHP SAPI."
76110)
77111
112+ if (Apache_FOUND AND NOT PHP_SAPI_APACHE2HANDLER_INSTALL_DIR)
113+ set_property (
114+ CACHE PHP_SAPI_APACHE2HANDLER_INSTALL_DIR
115+ PROPERTY VALUE "${Apache_LIBEXECDIR} "
116+ )
117+ endif ()
118+
78119target_link_libraries (
79120 php_sapi_apache2handler
80121 PRIVATE
@@ -146,9 +187,9 @@ endif()
146187install (
147188 TARGETS php_sapi_apache2handler
148189 LIBRARY
149- DESTINATION ${Apache_LIBEXECDIR }
190+ DESTINATION ${PHP_SAPI_APACHE2HANDLER_INSTALL_DIR }
150191 COMPONENT php-sapi-apache2handler
151192 RUNTIME
152- DESTINATION ${Apache_LIBEXECDIR }
193+ DESTINATION ${PHP_SAPI_APACHE2HANDLER_INSTALL_DIR }
153194 COMPONENT php-sapi-apache2handler
154195)
0 commit comments