digininja Posted February 28, 2018 Posted February 28, 2018 I'm trying to help someone debug why they they can't get DVWA working on a Fedora 27 box so I built my own to test it out. I've installed MySQL from the official MySQL repo (i.e. no using the default MariaDB) and got standard Apache and PHP installed. PHP is running as php-fpm. [root@localhost php-fpm.d]# php-fpm -m |grep mysql mysqli mysqlnd pdo_mysql [root@localhost php-fpm.d]# php -m |grep mysql mysqli mysqlnd pdo_mysql The mysqli modules are installed but when I try to use mysqli_connect I get an error saying the function doesn't exist. Checking phpinfo() and that agrees, there is no mention of the mysql extensions. [root@localhost php-fpm.d]# cat /etc/php.d/30-mysqli.ini ; Enable mysqli extension module extension=mysqli.so [root@localhost php-fpm.d]# locate mysqli.so /usr/lib64/php/modules/mysqli.so /usr/lib64/php-zts/modules/mysqli.so The mysql extension files are on the box and are referenced in the php config so I'm assuming that should enable them, I've not used fpm before. The php-fpm ini file test says it is OK [root@localhost php-fpm.d]# php-fpm -t [28-Feb-2018 14:29:21.074218] NOTICE: pid 30341, fpm_conf_init_main(), line 1717: configuration file /etc/php-fpm.conf test is successful But I still get this error in the log file: [28-Feb-2018 14:30:42 UTC] PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/dvwa/includes/dvwaPage.inc.php:467 Can any Fedora experts out there help? I'm assuming that I've not enabled the module correctly but not sure what I need to do to enable it. And to preempt certain answers, this is a very specific config that I'm trying to debug, I don't need advice on getting this working using different distros or application stacks. Quote
digininja Posted March 1, 2018 Author Posted March 1, 2018 Something I've just noticed, in the phpinfo() I have these entries: Loaded Configuration File /etc/php.ini Scan this dir for additional .ini files /etc/php.d Additional .ini files parsed /etc/php.d/20-bz2.ini, /etc/php.d/20-calendar.ini, /etc/php.d/20-ctype.ini, /etc/php.d/20-curl.ini, /etc/php.d/20-exif.ini, /etc/php.d/20-fileinfo.ini, /etc/php.d/20-ftp.ini, /etc/php.d/20-gettext.ini, /etc/php.d/20-iconv.ini, /etc/php.d/20-json.ini, /etc/php.d/20-phar.ini, /etc/php.d/20-sockets.ini, /etc/php.d/20-tokenizer.ini Yet my /etc/php.d directory has more files than that in it, including 30-mysqli.ini. I've tried copying that to 1-mysqli.ini just in case it was having problems with one of the 20's and so stopping loading the later ones but that hasn't helped. Quote
digininja Posted March 1, 2018 Author Posted March 1, 2018 More curious, I've just removed everything from that directory and then restarted apache but the phpinfo() still shows the same list of additional files. Quote
digininja Posted March 1, 2018 Author Posted March 1, 2018 Turns out php runs as a service on Fedora so you have to restart it after making changes. After that I check the status of the service and get this error: Feb 28 23:14:15 localhost.localdomain php-fpm[893]: [28-Feb-2018 23:14:15] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mysqli.so' - /usr/lib64/php/modules/mysqli.so: undefined symbol: mysqlnd_global_stats which I think is caused because of a mix between the official MySQL release and the built in stuff that is expecting MariaDB. The solution I've seen suggested for this is to use the Remi repo rather than the official Fedora one but that hasn't helped. Quote
digininja Posted March 1, 2018 Author Posted March 1, 2018 Got it all working, I've documented it in the original Github ticket but the short answer was that you need to rename a file so the mysqli extension gets started later in the init process. https://github.com/ethicalhack3r/DVWA/issues/222#issuecomment-369179468 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.