PostgreSQL avec Xampp
Commment intégrer une serveur de base de données postgreSQL à Xampp dans Windows
Je voulais intégrer un serveur postgreSQL à Xampp sur clé USB exécuté sur une machine Windows
Je me suis reféré à un article en ajoutant les modifications nécessaire et j’ai réalisé avec succés l’installation du serveur PostgreSQL. Voici les étapes:
Installer postgreSQL
1. Download the postgreSQL installer from EnterpriseDB.
2. Run the installer and follow the on-screen instruction.
Note: pgAdmin also get installed alongside.
3. Assuming XAMPP is located in C:\xampp; using the pgSQL installer, install postgreSQL in say C:\xampp\pgsql\9.1 folder.
In my case, I installed it on my usb drive. So the link:
F:\softs\xampp\PostgreSQL\9.5 folder
4. You will be prompted to set a password for postgresroot user. Keep it you’ll need later
5. By now, pgSQL has been installed.
Getting postgreSQL to talk with PHP
We need to perform the following rituals to get PHP talking / communicating with pgSQL.
1. Open php.ini file located in C:\xampp\php.
2. Uncomment the following lines in php.ini
extension=php_pdo_pgsql.dll (line 1014, remove “;” in front)
extension=php_pgsql.dll (line 1017, remove “;” in front)
3. Add the below code snippet to httpd.conf
LoadFile “C:\xampp\php\libpq.dll”
In my case, the httpd.conf file is at: F:\softs\xampp\apache\conf
I pasted the following at the ligne 178:
LoadFile » \softs\xampp\php\libpq.dll »
I noticed that this link is already in the xampp-http.conf file, located at : F:\softs\xampp\apache\conf\extra
(was it really necessary to paste the LoadFile line?)
4. Done.
PostgreSQL Database Administration tool
When we were installing postgreSQL, pgAdmin – a graphical pgSQL database administration tool was installed alongside. (see: pgAdmin III folder)
There is also phpPgAdmin (web base Postgres database management tool) which is to postgreSQL what phpMyAdmin is to MySQL / MariaDB.
I downloaded phpPgAdmin from the link provided. See configuration later below.
If you are like me that is intimidated by the command line, you will find these tools useful.
pgAdmin Quick-start
To get started with pgAdmin in creating and managing postgres database; firstly create a server, connect to it and create the database for that project of yours.
Let’s start with creating the server.
(Note that shortcuts of installed files are in windows start menu)
It can also be executed here: F:\softs\xampp\PostgreSQL\9.5\bin\pgAdmin3.exe
1. Click on File > Add Server…
2. Fill the form as shown in the image below.
Take note: in the username and password field, insert postgres as the username and in the password field, the password you entered while installing postgreSQL.
In my case, I really got problems to create a server.
“could not connect to Server: Connection refused”, so I tried many things that didn’t succeed. What I did that succeded (I think): I stoped Appache and mySQL and closed Xampp. I restarted Xampp and connected Appache and MySQL.
I right clicked on the PostgresSQL 9.5 server that was already created and clicked start server, and everything started.
You can now go ahead to create a Database.
Creating database
To create the database, under the server we created, right-click on the Database menu and click the New Database… link.
phpPgAdmin installation
I will be integrating phpPgAdmin to XAMPP to just have a MySQL-like XAMPP experience.
1. Head over to the Github repository and clone the repo to C:\xampp\phppgadmin.
Alternatively, download the repo. as a Zip, and extract the content to C:\xampp\phppgadmin.
In my case: F:\softs\xampp\phppgadmin
2. In C:\xampp\phppgadmin\conf, rename the config.inc.php-dist file to config.inc.php
In my case: F:\softs\xampp\phppgadmin\conf
I made a copy of config.inc.php-dist and named it: config.inc.php
3. Edit the config.inc.php and replace all instances of the following with the values below.
$conf[‘servers’][0][‘host’] = ‘localhost’;
$conf[‘servers’][0][‘pg_dump_path’] = ‘C:\\xampp\\pgsql\\9.1\\pg_dump.exe’;
In my case: ‘\\soft\\xampp\\PostgreSQL\\9.5\\pg_dump.exe’;
$conf[‘servers’][0][‘pg_dumpall_path’] = ‘C:\\xampp\\pgsql\\9.1\\pg_dumpall.exe’;
In my case: ‘\\soft\\xampp\\PostgreSQL\\9.5\\pg_dumpall.exe’
$conf[‘extra_login_security’] = false;
4. Edit XAMPP’s httpd-xampp.conf and add the below code.
Alias /phppgadmin “C:/xampp/phppgadmin/”
AllowOverride AuthConfig
Require all granted
The file is located at: F:\softs\xampp\apache\conf\extra
I made a space and pasted the following command after the line 115:
Alias /phppgadmin « /softs/xampp/phppgadmin/ »
<Directory « /softs/xampp/phppgadmin »>
AllowOverride AuthConfig
Require all granted
5. Restart Apache
6. You should now be able to use phpPgAdmin when you visit http://localhost/phppgadmin.
FINE! It worked
I got some problems starting.
To start service, you need to have your Appache server started.
Execute the pgAdmin3.exe located here in my case: F:\softs\xampp\PostgreSQL\9.5\bin\pgAdmin3.exe
Click on the server and click on right mouse button.
Choose “Start server”
The server will refresh.
Click again on server, click right mouse button, choose “connect”
The server will connect.
To create a database, as phppgadmin is installed,
Open your browser
Goto localhost/phppgadmin
Click on the server.
It will ask for username and password
Username: postgres
Password : xampxxxxXX
When logged in, click on the server. you’ll see the databases.
Under databases, you’ll see “create database”. Click on it and you’ll se the windows for database creation
Name: Enter the name of the database
Template: choose template 1 (that is the default if there is no precision)
You can leave the other things as they are (empty) if no special requirement precised
Hit create. The database will be created.