XF 2.0 Clean installation -> Error mysqli_init() not defined


Hi guys, I might need your help on this.

I am trying to setup a demo installation with XenForo 2.0 with nginx and php7.0-fpm.
Server is working fine, I have another site hosted in parallel and phpinfo() is finde too.

But when I try to call the address of the untouched installation, I get HTTP 500 response.
Logs say the following.

PHP Fatal error:  Uncaught Error: Call to undefined function mysqli_init() in /var/xenforo/www/src/XF/Db/Mysqli/Adapter.php:152
Stack trace:
#0 /var/xenforo/www/src/XF/Db/Mysqli/Adapter.php(28): XF\Db\Mysqli\Adapter->makeConnection(Array)
#1 /var/xenforo/www/src/XF/Error.php(46): XF\Db\Mysqli\Adapter->getConnection()
#2 /var/xenforo/www/src/XF/Install/App.php(48): XF\Error->hasPendingUpgrade()
#3 /var/xenforo/www/src/XF/Container.php(159): XF\Install\App->XF\Install\{closure}(Object(XF\Error), Object(XF\Container))
#4 /var/xenforo/www/src/XF/Container.php(28): XF\Container->XF\{closure}(Object(XF\Container))
#5 /var/xenforo/www/src/XF/App.php(2258): XF\Container->offsetGet('error')
#6 /var/xenforo/www/src/XF/App.php(1942): XF\App->error()
#7 /var/xenforo/www/src/XF.php(184): XF\App->logException(Object(ErrorException))
#8 [internal function]: XF::handleFatalError()
#9 {main}
  thrown in /var/xenforo/www/src/XF/Db/Mysqli/Adapter.php on line 152

What is the issue? Do I have to install some php plugin for mysql? Or what is it about the non existing mysql_init() function.

Funny thing is, when I tested it local inside docker everything worked fine. But native on Ubuntu 16.04 it does not.
Just in case, I copy paste my nginx config too.

server {
        listen 80;
        listen [::]:80;

        server_name demo.xenforo.xxxxx.de
        auth_basic "Private demo area";
        auth_basic_user_file ./htpasswd/cofo_private;

        root /var/xenforo/www;
        index index.html index.htm index.php;

        location / {
                try_files $uri $uri/ /index.php?$uri&$args;

        location ~ /(internal_data|library|src) {

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;

                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

         # deny access to .htaccess files, if Apache's document root
         # concurs with nginx's one

        location ~ /\.ht {
                deny all;

What do you think?
seems like it wasn't installed. I installed the package and now it manages at least to output the full exception as response.
But still, something mysql related.

An exception occurred: [XF\Db\Exception] No such file or directory in src/XF/Db/Mysqli/Adapter.php on line 160

XF\Db\Mysqli\Adapter->makeConnection() in src/XF/Db/Mysqli/Adapter.php at line 28
XF\Db\Mysqli\Adapter->getConnection() in src/XF/Db/AbstractAdapter.php at line 51
XF\Db\AbstractAdapter->connect() in src/XF/Db/Mysqli/Adapter.php at line 113
XF\Db\Mysqli\Adapter->escapeString() in src/XF/Db/AbstractAdapter.php at line 410
XF\Db\AbstractAdapter->quote() in src/XF/Db/AbstractAdapter.php at line 388
XF\Db\AbstractAdapter->quote() in src/XF/DataRegistry.php at line 137
XF\DataRegistry->readFromDb() in src/XF/DataRegistry.php at line 82
XF\DataRegistry->get() in src/XF/DataRegistry.php at line 225
XF\DataRegistry->offsetGet() in src/XF/App.php at line 1439
XF\App->XF\{closure}() in src/XF/Container.php at line 28
XF\Container->offsetGet() in src/XF/App.php at line 2130
XF\App->options() in src/XF.php at line 463
XF::options() in src/XF/Entity/User.php at line 1510
XF\Entity\User::getStructure() in src/XF/Mvc/Entity/Manager.php at line 70
XF\Mvc\Entity\Manager->getEntityStructure() in src/XF/Repository/User.php at line 57
XF\Repository\User->getGuestUser() in src/XF/Repository/User.php at line 31
XF\Repository\User->getVisitor() in src/XF/App.php at line 1560
XF\App->getVisitorFromSession() in src/XF/Pub/App.php at line 97
XF\Pub\App->start() in src/XF/App.php at line 1927
XF\App->run() in src/XF.php at line 328
XF::runApp() in index.php at line 13

Unfortunately didn't help at all. But I got it working anyways :)
I used a manually written config.php, which probably had some problem. I deleted it and stared the normal setup process again. After that everything went to the point where xenforo tells you which php libs you need to have installed. Did that too and was able complete the process.

In previous installations I did, I always got a screen where it reads the config.php and asks if I want to keep those settings. It never tried to connect to the database without this question wether I like to use the settings or not.
This time it skipped this Step somehow.

For future googlers, try to delete your config.php if you added it beforehand.
But many thanks anyways :)
The solution (I ran phpinfo so I saw mysqli was installed so I was perplexed but figured it out):

In order to get "php cmd.exe" to work on MAMP (In this case I'm using MAMP MAMP PRO v4.1 released 121818 https://downloads.mamp.info/MAMP-PRO-WINDOWS/releases/4.1/MAMP_MAMP_PRO_4.1.exe)

(1) copy php.ini-development or php.ini-production from C:\MAMP\bin\php\php7.1.7 to same folder and rename to php.ini (assuming you don't already have a local php.ini file, in which case just open it up).

(2) open php.ini and uncomment line that says ;extension=php_mysqli.dll

(3) change line to: extension=C:\MAMP\bin\php\php7.1.7\ext\php_mysqli.dll

then run cmd in shell: C:\MAMP\bin\php\php7.1.7\php.exe -c "C:\MAMP\bin\php\php7.1.7\php.ini" C:\MAMP\htdocs\NAME-OF-YOUR-FOLDER-WHERE-XENFORO-IS-INSTALLED\cmd.php xf-addon:create

or whatever command you're trying to run.

You're welcome.
Last edited:
Top Bottom