John Davidson

postgresql - PHP postgres enable ssl support

0 comments
Message:


Sorry to get back to you for a question that has been asked many years ago. But I am really stuck with this.
I have a legacy application which is very old, running PHP 5.2.17.
I followed this guide to setup my docker container
https://andrewscaya.net/blog/bringing-php-52-back-life


I have everything setup correctly. I made a downloaded and compiled a PHP installation and configured this with Apache. And its working fine with php.


However, it is essential that I have SSL support (in PHP) for the POSTGRES connection.
Which is now default not enabled according to PHPINFO


I have basically the very same problem somebody else had many years ago. SSL support of Pgsql

See:
Enable SSL support for pgsql


So from what I am understanding is that I need to recompile PHP again, but with a package called libpg ?
Where do I get this package and how can I compile this with the PHP source code?



My Answer:
To enable SSL support for PostgreSQL in PHP, you will need to recompile PHP with the `--with-pgsql` flag and specify the path to the `libpq` library. Here are the steps to do this:

1. Download the PostgreSQL source code from the official website (https://www.postgresql.org/download/).
2. Compile and install the `libpq` library by following the instructions in the PostgreSQL documentation.
3. Download the PHP source code from the official website (https://www.php.net/downloads.php).
4. Extract the PHP source code and navigate to the directory where it is located.
5. Run the following command to configure PHP with PostgreSQL support:


./configure --with-pgsql=/path/to/libpq


Replace `/path/to/libpq` with the actual path where the `libpq` library is installed.

6. Compile PHP by running `make` and then install it by running `make install`.
7. Restart Apache to apply the changes.

After following these steps, PHP should now have SSL support for PostgreSQL connections. You can verify this by checking the `phpinfo()` output or by testing a PostgreSQL connection with SSL enabled in your legacy application.

Rate this post

3 of 5 based on 3553 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us