@@ -1,6 +1,7 @@
config BR2_PACKAGE_PHP
bool "php"
select BR2_PACKAGE_PHP_SAPI_CGI if \
+ !BR2_PACKAGE_PHP_SAPI_APACHE && \
!BR2_PACKAGE_PHP_SAPI_CLI && \
!BR2_PACKAGE_PHP_SAPI_FPM && \
BR2_USE_MMU
@@ -14,6 +15,12 @@ config BR2_PACKAGE_PHP
if BR2_PACKAGE_PHP
+config BR2_PACKAGE_PHP_SAPI_APACHE
+ bool "Apache interface"
+ depends on BR2_PACKAGE_APACHE
+ help
+ Apache module
+
config BR2_PACKAGE_PHP_SAPI_CGI
bool "CGI interface"
# CGI uses fork()
@@ -81,6 +81,34 @@ PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_SAPI_CLI),--enable-cli,--disable-cli)
PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_SAPI_CGI),--enable-cgi,--disable-cgi)
PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_SAPI_FPM),--enable-fpm,--disable-fpm)
+ifeq ($(BR2_PACKAGE_PHP_SAPI_APACHE),y)
+PHP_DEPENDENCIES += apache
+PHP_CONF_OPTS += --with-apxs2=$(STAGING_DIR)/usr/bin/apxs
+
+# Enable thread safety option if Apache MPM is event or worker
+ifeq ($(BR2_PACKAGE_APACHE_MPM_EVENT)$(BR2_PACKAGE_APACHE_MPM_WORKER),y)
+PHP_CONF_OPTS += --enable-maintainer-zts
+endif
+
+# php uses apache's apxs script from staging directory to install libphp
+# dynamic library and update /etc/apache2/httpd.conf in the staging and target
+# directories. Here is the full command line:
+# "apxs -S LIBEXECDIR='$(INSTALL_ROOT)/usr/modules'
+# -S SYSCONFDIR='$(INSTALL_ROOT)/etc/apache2' -i -a -n php7"
+# This does not work for target directory as apxs sets the full path of the
+# library and not the relative one. Indeed, apxs is smart enough to substitute
+# away the prefix specified in $(STAGING_DIR)/usr/build/config_vars.mk so
+# httpd.conf will only be correct in the staging directory.
+# To fix this, add -S PREFIX='$(INSTALL_ROOT)/usr' to apxs call in configure
+define PHP_FIX_APXS_CALL
+ $(SED) "s, APXS_LIBEXECDIR=, APXS_PREFIX='\$$(INSTALL_ROOT)/usr' APXS_LIBEXECDIR=, \
+ ;s,-i -a -n php,-i -a -S PREFIX='\$$APXS_PREFIX' -n php," \
+ $(@D)/configure
+endef
+
+PHP_PRE_CONFIGURE_HOOKS += PHP_FIX_APXS_CALL
+endif
+
### Extensions
PHP_CONF_OPTS += \
$(if $(BR2_PACKAGE_PHP_EXT_SOCKETS),--enable-sockets) \