OpenSSL is on but not working

I am running Apache 2.2.13 and PHP 5.2.12. Just installed PHP 5.2.12 manually (to access all the extensions) and enabled OpenSSL. phpinfo () indicates that OpenSSL is enabled and running OpenSSL 0.9.8k on March 25, 2009.

I get this error: PHP Fatal error: function call undefined ftp_ssl_connect ().

I saw where in the PHP manual it says "ftp_ssl_connect () is only available if both the ftp module and OpenSSL support are built in statically in php" and further states that "you must compile your own PHP binaries "to make it work with Windows.

I have a suspicion that phpinfo () only indicates OpenSSL as "enabled" because I uncommented the line "extension = php_openssl.dll" and have the correct DLLs in the right folders and the right path in the environment variables. And perhaps static build in PHP should be done regardless of what phpinfo () points to.

I believe that the purpose of distribution (as described above) is for dynamic extensions, but recompilation (for OpenSSL) is encoding a static extension.

The ftp extension works fine (built-in to PHP 5.2). I am testing this with the following code:

$ conn_id = ftp_connect ($ url); $ login_result = ftp_login ($ conn_id, $ username, $ password); ftp_close ($ conn_id);

Please note that to check ssl I change ftp_connect to ftp_ssl_connect. On reaching this line, I get the PHP error above in my Apache error log file.

+4
source share
1 answer

As stated (quoting what you have already quoted):

Note. Why this feature may not exist
ftp_ssl_connect() only available if both the ftp module is supported and support for OpenSSL is statically in php, which means that on Windows this function will be undefined in official PHP builds.
To make this feature available on Windows, you must compile your own PHP files.

You say that you installed PHP "manually"; but that probably still means that you used the "official" build with php.net - that means you did not compile your own PHP binaries ... So this function is not available.


There is no magic: it seems you will have to recompile PHP using the correct configuration parameters at compile time if you want to use this function ...

Here is some documentation about this: Build your own PHP on Windows - but ... good luck ... I never heard that it’s β€œeasy” to compile PHP on windows, actually (it's not that difficult on Linux, but Linux is maybe a little better compiled)


A few other solutions:

  • switching to Linux for your development (even if it is used only with a virtual machine) - but you still have to recompile PHP to get it (it may not be enabled by default)
  • just not using this function; after all, do you know if your hosting will provide this to you? (If you cannot use it on your production server, you do not need to use it on your development / testing machine).
+4
source

All Articles