Nginx – Enabling PHP’s SSH2 extension with nginx

centosnginxPHP

Okay, so normally my sysadmin takes care of this, but he's been rather slack lately and I cannot wait any longer.

I've used PECL to install PHP's ssh2 extension. I've put the extension=ssh2.so in the php.ini and checked the ssh2.so is in the extension_dir. When I php -m | grep ssh2, it displays ssh2. When I run this script:

<?php

if (function_exists('ssh2_connect'))
{
    echo "true";
}

?>

and run it from the command line, it echos true.

When I run phpinfo() through the webserver, I can't find ssh2 anywhere. When I run ssh2_connect() through the webserver, it tells me that the function is undefined.

My OS is CentOS 5.7
PHP Version 5.2.14
nginx/0.7.67

I've been looking all over Google and tried everything I could find, but I can't figure it out. Can anyone help?

EDIT:

Just to keep you guys updated, Shish was right. I found a program php-fpm, that when called, seems to be what I'm looking for. However, it's failing to load the ssh2 extension due to mismatched API numbers

Starting php_fpm PHP Warning:  PHP Startup: ssh2: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP    compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
 in Unknown on line 0
 done

After some short research, it seems it might be an issue of me installing the ssh2 module via PECL, and I believe my sysadmin compiled PHP from source.

Looking into it now.

EDIT:

After additional research, it appears two versions of PHP are installed on my system. One that I probably installed via yum, and one that my sysadmin probably installed. It appears php-fpm is loading the one he installed, and naturally my updates aren't affecting it. Perhaps I'll wait for him in case I screw something up.

EDIT:

On second thought, I'm just going to remove everything and try it myself. At worst I'll just need to get him to reinstall everything, and at best it'll work and I won't have to wait for him any longer. Wish me luck.

EDIT:

Nope. Scratch that. No idea what I'm doing. I think I hate my life. I have about 30 tabs open in Chrome now. I'm going to bed. Hopefully someone can provide further insight while I sleep.

EDIT:

Yup, probably destroyed everything. Gonna try to repair my damage and then let my sysadmin handle it again. Going to accept the current answer because, well, it was right. Past that was just problems with the module API mismatch.

Best Answer

You'll need to restart the PHP daemon - if the web server is nginx, then PHP is probably running as fastcgi or under PHP-FPM. Unfortunately I don't know CentOS to know the exact command to use to restart that daemon...