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.
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.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