I have a fully working Joomla 2.5.6 install driven by a local MySQL server, but I'd like to test nginx to see if it's a faster web serving experience than Apache.

  • PHP 5.4.6 (PHP54w)
  • CentOS 6.2
  • Joomla 2.5.6
  • PHP54w-fpm.i386 (FastCGI process manager)
  • php -m shows: mysql & mysqli modules loaded

Nginx seems to have installed fine via yum, it can process a PHP-info file via FastCGI perfectly OK ( but when I stop Apache, start nginx instead and visit my site I get: "Database connection error (1): The MySQL adapter 'mysqli' is not available."

I've tried adjusting my Joomla configuration.php to use mysql instead of mysqli but I get the same basic error, only this time "Database connection error (1): The MySQL adapter 'mysql' is not available" of course!

Can anyone think what the problem might be please? I did try explicitly setting extension = mysqli.so and extension = mysql.so in my php.ini to try and force the issue (despite php -m showing they were both successfully loaded anyway) - no difference.

I have a pretty standard nginx default.conf:

server {
    listen 80;
    server_name www.MYDOMAIN.com;
    server_name_in_redirect off;
    access_log /var/log/nginx/localhost.access_log main;
    error_log /var/log/nginx/localhost.error_log info;

    root /var/www/html/MYROOT_DIR;
    index index.php index.html index.htm default.html default.htm;
    # Support Clean (aka Search Engine Friendly) URLs
    location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;
    # deny running scripts inside writable directories
    location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
            return 403;
            error_page 403 /403_error.html;
    location ~ \.php$ {
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi.conf;
    # caching of files 
    location ~* \.(ico|pdf|flv)$ {
            expires 1y;
    location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
            expires 14d;


Snip of output from phpinfo under nginx:

Server API    FPM/FastCGI
Virtual Directory Support    disabled
Configuration File (php.ini) Path    /etc
Loaded Configuration File    /etc/php.ini
Scan this dir for additional .ini files    /etc/php.d
Additional .ini files parsed    /etc/php.d/curl.ini, /etc/php.d/fileinfo.ini, /etc/php.d/json.ini, /etc/php.d/phar.ini, /etc/php.d/zip.ini

Snip of output from phpinfo under Apache:

Server API    Apache 2.0 Handler
Virtual Directory Support    disabled
Configuration File (php.ini) Path    /etc
Loaded Configuration File    /etc/php.ini
Scan this dir for additional .ini files    /etc/php.d
Additional .ini files parsed    /etc/php.d/curl.ini, /etc/php.d/fileinfo.ini, /etc/php.d/json.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_sqlite.ini, /etc/php.d/phar.ini, /etc/php.d/sqlite3.ini, /etc/php.d/zip.ini

Seems that with Apache, PHP is loading substantially more additional .ini files, including ones relating to mysql (mysql.ini, mysqli.ini, pdo_mysql.ini) than nginx.

Any ideas how I get nginix to also call these additional .ini's ?

Thanks in advance,



There is a different php.ini file for apache and for fcgi. check your php configuration folder (/etc/php5 in ubuntu) and you will see at least two folders apache2 and cli. Make sure that in both files the mysql driver is enabled. Also check that you have the ini files in conf.d for both locations.


You need to check the installation of your php-fpm/FastCGI version for nginx, from what it seems you don't have mysql and mysqli enabled for this particular installation.
In case you have the same version of php installed both for Apache and nginx with the same threaded setup(either ZTS is enabled for both or disabled for both), you just need to copy the mysql.so and mysqli.so from the extension_dir of the Apache installation to the extension_dir of the nginx php-fpm/FastCGI installation which you can easily get by opening a phpinfo() php script first in Apache then in nginx.
After this you need to enable these modules in php-fpm/FastCGI, if they are not included from the /etc/php.d/ directory just specify this directly in /etc/php.ini by adding the next lines:


And restart php-fpm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.