0

I'm trying to setup up a web application environment on Windows 11, using Apache Lounge, PHP and PostgreSQL. I am an absolute beginner. I've worked through older posts of the same issue and have had no luck fixing the problem.

  1. I installed Apache Lounge:
    a) I extracted Apache 2.4.63-250207 Win64 to my C drive.
    b) Starting up the server and going to localhost I get the "It Works!" site, so I know it is running.

  2. I installed PHP:
    a) I extracted VS17 x64 Thread Safe to C:/_WORK/PHP
    b) I added C:/_WORK/PHP to the system path.
    c) I copied the php.ini-development file, creating php.ini
    d) And enabled extension_dir = "ext" in the php.ini
    e) I copied to httpd.conf:

             # before PHP 8.0.0 the name of the module was php7_module
             LoadModule php_module "C:/_WORK/PHP/php8apache2_4.dll"
             <FilesMatch \.php$>
                 SetHandler application/x-httpd-php
             </FilesMatch>
             # configure the path to php.ini
             PHPIniDir "C:/_WORK/PHP"
    

f) I changed the index.html to index.php and added an echo - it works and returns as expected:

        <html>
            <body>
                <h1>It works!</h1>
                <?php
                echo phpinfo();
                ?>
            </body>
        </html>

3. I installed PostgreSQL:
a) I installed postgresql-17.5-2-windows-x64 to C:/_WORK/PostGreSQL
b) In the php.ini I enabled extension=pdo_pgsql and extension=pgsql
c) I added C:/_WORK/PostGreSQL to the system path.
d) I edited index.php:
         <html>
            <body>
                <h1>It works!</h1>
                <?php
                $db_handle = pg_connect("host=localhost dbname=testdb user=prostgres password=myPSSW");
                if ($db_handle)
                {
                    echo "DB connection succeeded.";
                }
                else
                {
                    echo "DB connection failed!";
                }
                ?>
            </body>
        </html>

This is where I get the error:
Fatal error: Uncaught Error: Call to undefined function pg_connect() in C:\Apache24\htdocs\index.php:7 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\index.php on line 7

+ I copied php_pgsql.dll to the Apache\bin directory. It did nothing.

My PHPInfo outputs:
Configuration File (php.ini) Path no value
Loaded Configuration File C:\_WORK\PHP\php.ini
3
  • 1
    Try setting full path for extension_dir Commented Jun 25 at 13:54
  • 3
    You can get a dump of all the extensions etc and how they are setup with the "phpinfo" statement. php.net/manual/en/function.phpinfo.php Commented Jun 25 at 14:08
  • In the end it just started working, but I can't figure out why. I did end up setting the full path for extension_dir, but setting it back to "ext" doesn't re-create the problem so I'm not sure if that is what solved it. Commented Jun 25 at 18:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.