Basically run the next PHP code around the command line I recieve the expected result:

php -r 'var_dump(ldap_connect("ldaps://ldaps.example.com", 636));'
resource(4) of type (ldap link)

If however I put this inside a PHP script

<?php ldap_connect("ldaps://ldaps.example.com", 636); ?>

Apache drops the bond, for instance this is exactly what cURL returns basically hit the script in the command line:

curl http://example.com/ldap_test.php
curl: (52) Empty reply from server

The Apache access_log never shows the hit for this page, and also the error_log is empty.

I understand the LDAP server is being employed as I've examined this on two other servers. I'm focusing on an Joyent accelerator running PHP 5.2.9 and Apache. Anybody know why Apache is choking about this?

Update:

Today I debugged Apache using GDB while running the issue script. Once the script hits the ldap_connect() line I recieve the next in GDB:

Program received signal SIGSEGV, Segmentation fault.
0xfe94b8bb in _free_unlocked () from /lib/libc.so.1

I am unsure what's leading to the segfault yet, but a minimum of I understand that Apache is really crashes.

This is actually the full backtrace:

Breakpoint 1, 0x08094417 in ap_process_request ()
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0xfe94b8bb in _free_unlocked () from /lib/libc.so.1
(gdb) where
#0  0xfe94b8bb in _free_unlocked () from /lib/libc.so.1
#1  0xfe94b86f in free () from /lib/libc.so.1
#2  0xfde2d7e8 in ldap_x_free () from /usr/lib/libldap.so.5
#3  0xfde3f78b in ldap_free_urldesc () from /usr/lib/libldap.so.5
#4  0xfd0943d9 in ldap_free_urllist () from /opt/local/lib/libldap-2.4.so.2
#5  0xfd087191 in ldap_ld_free () from /opt/local/lib/libldap-2.4.so.2
#6  0xfd07ce8f in ldap_initialize () from /opt/local/lib/libldap-2.4.so.2
#7  0xfd3831a1 in zif_ldap_connect () from /opt/local/lib/php/20040412/ldap.so
#8  0xfcbda874 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#9  0xfcbe1a23 in ZEND_DO_FCALL_SPEC_CONST_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#10 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#11 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#12 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#13 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#14 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#15 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#16 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
---Type <return> to continue, or q <return> to quit---
#17 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#18 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#19 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#20 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#21 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#22 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#23 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#24 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#25 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#26 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#27 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#28 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#29 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#30 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
---Type <return> to continue, or q <return> to quit---
   from /opt/local/lib/httpd/mod_php5.so
#31 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#32 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#33 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#34 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#35 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#36 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#37 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#38 0xfcbbebaa in zend_execute_scripts () from /opt/local/lib/httpd/mod_php5.so
#39 0xfcb7f40e in php_execute_script () from /opt/local/lib/httpd/mod_php5.so
#40 0xfcc509ca in php_handler () from /opt/local/lib/httpd/mod_php5.so
#41 0x08085c2a in ap_run_handler ()
#42 0x0808638e in ap_invoke_handler ()
#43 0x08094ca7 in ap_internal_redirect ()
#44 0xfe48c232 in handler_redirect () from /opt/local/lib/httpd/mod_rewrite.so
#45 0x08085c2a in ap_run_handler ()
#46 0x0808638e in ap_invoke_handler ()
#47 0x08094471 in ap_process_request ()
#48 0x0809177c in ap_process_http_connection ()
---Type <return> to continue, or q <return> to quit---
#49 0x0808d426 in ap_run_process_connection ()
#50 0x0808d858 in ap_process_connection ()
#51 0x08099e89 in child_main ()
#52 0x08099f65 in make_child ()
#53 0x0809a472 in ap_mpm_run ()
#54 0x080709ab in main ()
(gdb) 

Update 2:

From what I will tell the issue starts during these two function calls:

#3  0xfde3f78b in ldap_free_urldesc () from /usr/lib/libldap.so.5
#4  0xfd0943d9 in ldap_free_urllist () from /opt/local/lib/libldap-2.4.so.2

The function in #4 (ldap_free_urllist) is known as from the library in /opt/local/lib/libldap-2.4.so.2 and #3 is known as from the library in /usr/lib/libldap.so.5. I'm not sure enough to inform whether it is perfectly normal, however i would assume it's not. So in some way these two LDAP libraries are becoming loaded.