skip to Main Content

Problem description

I use Windows 10 OS. I have installed Apache 2.4 in C:/Apache24 and PHP7.4.1 in C:/php7. In the configuration file of Apache, httpd.conf, I appended the following

    LoadModule php7_module "c:/php7/php7apache2_4.dll"
    #<FilesMatch .php$>
    #   SetHandler application/x-httpd-php
    #</FilesMatch>
    AddType application/x-httpd-php .php
    PHPIniDir "C:/php7" 

I also have modified the php.ini file of php in the following way:

     extension_dir = C:php7ext
     extension=bz2
     extension=curl
     ;extension=ffi
     extension=fileinfo
     extension=gd2
     extension=gettext
     extension=gmp
     extension=intl
     extension=imap
     ;extension=ldap
     extension=mbstring
     extension=exif      ; Must be after mbstring as it depends on it
     extension=mysqli
     ;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
     ;extension=odbc
     extension=openssl
     ;extension=pdo_firebird
     extension=pdo_mysql
     ;extension=pdo_oci
     extension=pdo_odbc
     extension=pdo_pgsql
     extension=pdo_sqlite
     extension=pgsql
     extension=shmop
     ; The MIBS data available in the PHP distribution must be installed.
     ; See http://www.php.net/manual/en/snmp.installation.php
     ;extension=snmp
     extension=soap
     extension=sockets
     ;extension=sodium
     extension=sqlite3
     extension=tidy
     extension=xmlrpc
     extension=xsl

and still in php.ini I have also modified

     [sqlite3]
     ; Directory pointing to SQLite3 extensions
     ; http://php.net/sqlite3.extension-dir
     sqlite3.extension_dir = C:Apache24htdocs

Then I have restarted apache several tens of times and the PC once.

Problem:

I have made a ‘index.php’ file and placed it in ‘c:/apache24/htdocs’ which has the following text in it:

    <?php phpinfo(); ?>

Going to ‘localhost’ in Chrome Web browser I see the PHP info file. However, —> it does not have sqlite3 nor pdo_sqlite enabled <—. However, running ‘php -m’ in comand window, it shows that sqlite3 and pdo_sqlite are loaded. Furthermore, in localhost PHP info says that it uses the loaded configuration file found here ‘C:php7php.ini’ hich is indeed the right one.

I have no other idees, why sqlite3 or pdo_sqlite is not visible in apache2 but visible in com window, especially bue to the fact that it uses the same php.ini file.

Update

Checking the ‘error.log’ file from Apache24logs I can see that the following warning:

PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: C:\php7\ext\pdo_sqlite (The specified module could not be found.), C:\php7\ext\php_pdo_sqlite.dll (The specified module could not be found.)) in Unknown on line 0
However, php_pdo_sqlite.dll can be seen in c:php7ext using the Windows 10 explorer, but on the other hand C:\php7\ext is not a valid path for the windows explorer. I do not know if double backslashes are used just for printing or indeed it searches at that path. However cmd is not bothered by double backslashes. I really do not know what to think!

2

Answers


  1. When apache runs php (because you fetch a URL which is served by the web server and it redirects the *.php URLs to the php) then php loads a php.ini file from one particular directory. You can see the path of the loaded php.ini (and potentially other configuration files) in the output of phpinfo() within your web browser.

    By contrast, if you run php from command line then php uses a different php.ini, more precisely, a php.ini from a different directory. You can see the path of this php.ini also in the output of phpinfo() but it will be shown in your terminal, not in your browser. You can get this output via a command similar to this one:

    php c:Apache24htdocsindex.php
    

    The point is that you need to adjust both of the php.ini files if you want to use your sqlite or other extensions both from command line and web server.

    Instead of double backslashes, maybe you should use single froward slashes, like extension_dir = "C:/php7/ext" but, disclaimer, I have no installed apache and php on my windows computer so I cannot confirm if I say it correctly.

    I still hope I was able to help. 🙂

    I wish you a happy new year. 🙂

    Login or Signup to reply.
  2. Upgrading Apache to 2.4.41 + adding the following to my httpd.conf fixed the problem for me.

    # PHP7
    
    LoadModule php7_module "C:/Php/php7apache2_4.dll"
    AddHandler application/x-httpd-php .php
    AddHandler application/x-httpd-php .phtml
    PHPIniDir C:/Php
    
    # FIX CURL REQUIRES LIBSSH2
    LoadFile "C:/Php/libssh2.dll"
    LoadFile "C:/Php/libsqlite3.dll"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search