Cannot run Apache 2.4 with libapache2-mod-php5

apache-2.4php-fpmphp5

I have a Vagrant Debian Wheezy running Apache 2.4.10 and Php 5.6.26
I need to install and run libapache2-mod-php5 to make Apache able to read php_value inside an .htaccess file. TL;DR the error is fired as soon as Apache restarts:

$ apachectl -M
apache2: Syntax error on line 37 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: undefined symbol: unixd_config
Action '-M' failed.
The Apache error log may have more information.

That's the PHP version:

$ php -v
PHP 5.6.26-1~dotdeb+7.1 (cli) (built: Sep 18 2016 19:52:57) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.0-dev, Copyright (c) 2002-2016, by Derick Rethans

And that's the Apache configuration:

$ apache2 -V
[Mon Sep 26 23:27:20.618601 2016] [core:warn] [pid 25105] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Mon Sep 26 23:27:20.623081 2016] [core:warn] [pid 25105:tid 139878783203136] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
[Mon Sep 26 23:27:20.623438 2016] [core:warn] [pid 25105:tid 139878783203136] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
Server version: Apache/2.4.10 (Debian)
Server built:   Nov  7 2014 12:05:20
Server's Module Magic Number: 20120211:37
Server loaded:  APR 1.5.1-dev, APR-UTIL 1.5.3
Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3
Architecture:   64-bit
Server MPM:     worker
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/apache2"
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="mime.types"
 -D SERVER_CONFIG_FILE="apache2.conf"

Later I read that libapache2-mod-php5 needs to be compiled with prefork MPM, so recompiled again with mpm-prefork enabled:

$ sudo a2dismod worker                 
Module worker disabled.
To activate the new configuration, you need to run:
  service apache2 restart

$ sudo a2enmod mpm_prefork
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled

$ sudo service apache2 start  
[ ok ] Starting web server: apache2.

$ apache2 -V
[Mon Sep 26 23:05:35.463940 2016] [core:warn] [pid 22298] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Mon Sep 26 23:05:35.466868 2016] [core:warn] [pid 22298] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
[Mon Sep 26 23:05:35.467139 2016] [core:warn] [pid 22298] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
Server version: Apache/2.4.10 (Debian)
Server built:   Nov  7 2014 12:05:20
Server's Module Magic Number: 20120211:37
Server loaded:  APR 1.5.1-dev, APR-UTIL 1.5.3
Compiled using: APR 1.5.1-dev, APR-UTIL 1.5.3
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/apache2"
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="mime.types"
 -D SERVER_CONFIG_FILE="apache2.conf"

$ sudo apt-get remove libapache2-mod-php5
...
$ sudo apt-get autoclean
...
$ sudo apt-get install libapache2-mod-php5
...
$ sudo a2enmod php5
Enabling module php5.
To activate the new configuration, you need to run:
  service apache2 restart
$ sudo service apache2 restart
[FAIL] Restarting web server: apache2 failed!
[warn] The apache2 configtest failed. ... (warning).
Output of config test was:
apache2: Syntax error on line 37 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: undefined symbol: unixd_config
Action 'configtest' failed.
The Apache error log may have more information.

But still gives the same error. I have no clue what I'm missing here. I really need to get rid of those errors while reading php_value inside .htaccess files.

EDIT – found the solution

Thanks to @Unbeliever's answer I discovered that puPHPet Vagrant machine I'm using provision php-FPM instead the old mod_php (this happens since March 2015).
Later I discovered that php-FPM (as other CGI/FCGI versions of php) can read php_value in a user.ini file, as written on https://secure.php.net/manual/en/configuration.file.per-user.php .
So it would be good to put a php.ini file along an .htaccess, to give full support.

Best Answer

The undefined symbol means you have a mod_php package installed that was compiled against an earlier version of Apache.

You should be able to correct this by updating libapache2-mod-php5 to one compiled against Apache v2.4.

Apologies, I am not a Linux repo expert, but you probably need to get the libapache2-mod-php5 from the same repository that you got Apache httpd.