thehenrys.net

May 19, 2008

PHP, OpenSSL and ftp_ssl_connect() on Win32, my journey…

Filed under: Programming,Server Admin — dh @ 1:46 pm

I need to compile php for Windows so that the ftp_ssl_connect function would be available. This is how I did it. All of this is as of today, May 19, 2008. Windows XP Pro SP2.

  • Download & Install (this is a large install > 1GB):
    » Microsoft Visual C++ 2008 Express Edition
    » Windows SDK for Windows Server 2008 and .NET Framework 3.5
  • Copy C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\WinResrc.h to C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\winres.h
  • Create the directory C:\work
  • Download:
    » php 5.2.6 Source Code and extract it to the C:\work\ folder.
  • Download:
    » Needed Libraries (zip.zip). Edin Kadribašic has a nice zip file with everything in it. You need to go into subfolder /php/win32 and click on zip.zip. (If this link is down try this one: http://perisama.net/ ). Create folder C:\work\php_build\ and extract the zip file into it.
  • Download:
    » Newer libxml2. The libxml package that is included in the zip file was a little out of date. Download this one and extract the contents of the zip file on top of C:\work\php_build\ . Overwrite files as needed.
  • Download & Install:
    » Win32 OpenSSL (Win32 OpenSSL v0.9.8g)
  • Patch php source:
    As of php 5.2.6, you will need to patch C:\work\php-5.2.6\ext\ftp\ftp.c in your php source directory. deciacco did some awesome work in producing a working patch. You can see his site here. You can download my patched version for php 5.2.6 here. Just replace the copy of ftp.c in your C:\work\php-5.2.6\ext\ftp\ folder.
  • Open:
    Start > Program Files > Visual C++ 9.0 Express Edition > Visual Studio Tools > Visual Studio 2008 Command Prompt
  • Type these commands into the Visual Studio 2008 Command Prompt:
    Link To Commands
    You will see many, many compile warnings. This is quite normal. 🙂
  • If everything went well, you should now have php.exe in the folder C:\work\Release_TS\ which has ftp_ssl_connect functionality.

    6 Responses to “PHP, OpenSSL and ftp_ssl_connect() on Win32, my journey…”

    1. deciacco Says:

      I’m so glad to see more of these tutorials out on the web. I think PHP is awesome and I’m glad that more people are using it on Windows.

    2. dh Says:

      🙂

      Thank you for that patch! Hopefully they can get your work into the main php code. It would certainly cause problems for anyone trying to get ftp_ssl_connect working on Windows. Thanks for the reply!

      -dan

    3. sgguo Says:

      I have been trying to find an easy-to-follow instruction on compiling the ftp_ssl_connect() function into the Win32 build. Your step-by-step procedure did the heavy lifting for us, and make our life easier. Thank you a million!!! I would also recommend investigate the environmental variables using the dos “set” command very clearly and make corrections if necessary to avoid the compiler using the wrong directories.

    4. Andrew Smith Says:

      Any chance someone can just make a binary available for everyone else to download? It seems crazy that everyone has to jump through hoops to compile their own PHP with openssl.
      Any kind soul out there?

    5. keysheads Says:

      I spent hours trying to get this working only to find out that what I needed wasn’t FTPS support but rather SFTP support. I didn’t even know that there was a difference!

      Anyway, here’s what I used for SFTP:

      http://phpseclib.sourceforge.net/

    6. zorrax Says:

      Thank for this tuto
      but using php 5.2.7 source it doesnt work
      many error during nmake

    Leave a Reply