php cannot load pecl http extension - php

I have installed pecl_http on a PLESK server (which seems to be successful) but for some reason, the http extension will not load into PHP.
var_dump(extension_loaded("http"));
gives me bool(false).
pecl info pecl_http gives me a lot of info and if I run php -me http is also listed.
php -i | grep "http_request" gives me:
http_request => N/A => 0 => 0
http_request_datashare => GLOBAL => 1 => 0
http_request_pool => N/A => 0 => 0
and if I run pecl run-tests -p pecl_http I get a lot of FAILs
and I am also getting
Fatal error: Call to undefined function http_get()
http.so is located inside /usr/lib/php/modules/ which is also defined as the extension dir in php.ini - all other extensions loads fine.
What have I missed?

What happens if change
enable_dl = Off
to
enable_dl = On
in php.ini and run
php -r "dl('http.so');"
?

Related

Installing a PHP extension on Windows 10

I've been away from PHP for a while. Right now, I have a working CakePHP 3.x site running on IIS. Now, I need to install and use an extension (specifically a Couchbase extension, but I don't think my problem is Couchbase specific).
I've downloaded the DLL from PECL (here, the 5.6 Thread Safe 32bit download, specifically)
I think that I have to put the files in that zip file somewhere, and then I have to make a change to php.ini under ExtensionList. But I'm not sure where to put the files specifically, or which DLLs to reference.
I tried putting them in C:\Program Files (x86)\PHP\v5.6\ext\couchbase and then I added extension=couchbase/php_couchbase.dll to php.ini, restarted IIS. Then, I wrote this simple CakePHP controller just to make sure that worked:
<?php
namespace App\Controller;
class ProfilesController extends AppController
{
public function index()
{
$cluster = new CouchbaseCluster("couchbase://127.0.0.1");
$bucket = $cluster->openBucket("sqltocb");
$query = CouchbaseN1qlQuery::fromString("SELECT b.* FROM `sqltocb` b LIMIT 10;");
$query->consistency(CouchbaseN1qlQuery::REQUEST_PLUS);
$result = $bucket->query($query);
echo json_encode($result->rows);
}
}
?>
But I get an error Error: Class 'App\Controller\CouchbaseCluster' not found, which I assume to mean that I didn't install the extension correctly. Any idea what I'm doing wrong?
My system version
PS> [Environment]::OSVersion
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 10.0.14393.0 Microsoft Windows NT 10.0.14393.0
Download and extract PHP interpreter and the Couchbase extension:
PS> Invoke-WebRequest -Uri "http://windows.php.net/downloads/releases/php-5.6.31-Win32-VC11-x86.zip" -OutFile "php-5.6.31-Win32-VC11-x86.zip"
PS> Expand-Archive "php-5.6.31-Win32-VC11-x86.zip" -DestinationPath "C:\php"
PS> Invoke-WebRequest -Uri "http://packages.couchbase.com/clients/php/php_couchbase-2.3.4-5.6-zts-vc11-x86.zip" -OutFile "php_couchbase-2.3.4-5.6-zts-vc11-x86.zip"
PS> Expand-Archive "php_couchbase-2.3.4-5.6-zts-vc11-x86.zip" -DestinationPath "C:\php\ext"
Copy libcouchbase.dll to the place where your SAPI lives (in our case SAPI is PHP CLI, so we copy it into the same directory, where php.exe located):
PS> copy "C:\php\ext\libcouchbase.dll" "C:\php\libcouchbase.dll"
Update configuration:
PS> copy "C:\php\php.ini-development" "C:\php\php.ini"
PS> "extension=php_couchbase.dll" | Add-Content "C:\php\php.ini"
Lets check setup:
PS> C:\php\php.exe -i 2>$null | findstr -i couchbase
couchbase
couchbase support => enabled
libcouchbase runtime version => 2.7.6 (git: e15b267765913f110fd1bbf65749c54b56875ebf)
libcouchbase headers version => 2.7.6 (git: e15b267765913f110fd1bbf65749c54b56875ebf)
igbinary transcoder => disabled (install pecl/igbinary and rebuild pecl/couchbase)
couchbase.decoder.json_arrays => 0 => 0
couchbase.encoder.compression => off => off
couchbase.encoder.compression_factor => 0.0 => 0.0
couchbase.encoder.compression_threshold => 0 => 0
couchbase.encoder.format => json => json
couchbase.log_level => WARN => WARN
If you are using something different instead of C:\php, then make sure your extension directory match to place where PHP is looking for extensions, because this is is what it outputs by default (and php.ini-development does not override it):
PS> C:\php\php.exe -i 2>$null | findstr -i extension_dir
extension_dir => C:\php\ext => C:\php\ext
All snippets executed in home directory using PowerShell, and PS> means its prompt.

Class 'SoapClient' not found on Google Cloud PHP App

I deployed my php app to Google Cloud and getting currently the following error when i call the line.
$url = "S5WS.wsdl";
$client = new \SoapClient(dirname(__FILE__) . DIRECTORY_SEPARATOR . $url, array('trace' => true, 'soap_version' => SOAP_1_1));
PHP message:
PHP Fatal error: Class 'SoapClient' not found in /app/controllers/TicketController.php on line 211
I opened the terminal in the Google Cloud and typed php -i | grep -i soapso to check the status of the soap and it seemds to be fine.
baltacii#s5-app-****:/$ php -i | grep -i soap
soap
Soap Client => enabled
Soap Server => enabled
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
baltacii#s5-app-167912:/$
If i call phpinfo(); in the app.It returns me in contrast to my localhost no Soap Section. There are only 2 lines related with the soap.
SOAP Brad Lafountain, Shane Caraveo, Dmitry Stogov
and in the configure command section
'--enable-soap=shared'
EDIT: App runs on PHP Version 5.6
So according to documentation some PHP extensions are compiled as shared, but disabled by default.Soap is one of these extensions.In order to activate it. We should create a php.ini in the base folder of the project.
php.ini
; Enable the Soap extension
extension=soap.so
After new deployment to server soap should be available.

No oci8 module in phpinfo()

I try to set up connection with oracle database, but I still can't even set up the module. I have rhel 7. 2 server, and I followed whole tutorial for setting up oracle instantclient and configured it with php. One thing I completely don't understand is that oci8 module displays after php -i execution:
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.3
Revision => $Id: 59f993160cf983dd24bb391b68a65a17303d2dba $
Oracle Run-time Client Library Version => 12.1.0.2.0
Oracle Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
But there is no such module in phpinfo() inside the script. How to fix it?
PHP Version 7.0.13
Server Apache (httpd)
LD library path:
[![enter image description here][2]][2]
The common problem would be that LD_LIBRARY_PATH isn't set for Apache.
Try adding it to /etc/sysconfig/httpd like:
LD_LIBRARY_PATH=/full/path/to/oracle-client
If I have my versions right, this version of Apache (i) doesn't like the export keyword for setting variables (ii) requires a full path since it won't expand environment variables. If I'm wrong, try either or both of those.
There is a lot of information about setting the environment in the free Underground Oracle & PHP Manual, see, for example 'Setting Oracle Environment Variables for Apache' on p 108
You say you followed 'whole tutorial'. There are many tutorials. I'd recommend Oracle's installation instructions.
The answer is:
setsebool -P allow_execstack 1
You also can enable executable stack for only oci8.so with:
execstack -c /usr/lib64/php/modules/oci8.so
https://serverfault.com/questions/314336/centos-6-php-can-not-load-gdchart-so-and-oci8-so-compiled-by-me
make sure that the oci8.so is in the php extension folder
in centos is /usr/lib64/php/modules
in ubuntu xammp is /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
cd <extension folder >
sudo chmod 755 oci8.so
It works for me after
ps ax | grep "fpm"
check the pid of "php-fpm: master process"
sudo kill -9 <pid>
start php-fpm again
sudo service php-fpm start
inspired by https://stackoverflow.com/a/21693610/2538630

Centos 6 PHP OCI8 extention is not working (Undefined function oci_connect())

I am using Centos 6 64 bit OS. Recently i have installed OCI8 extension with php. After making all configuration i tried to execute the function oci_connect to connect with a Oracle Database remotely.
Unfortunately i got this error:
Fatal error: Call to undefined function oci_connect() in /var/www/html/index.php on line 5
I have installed oci8 like this:
OCI8
Download the OCI8 source using pear
$ pear download pecl/oci8
$ tar -xvf oci8-1.4.9.tgz
$ cd oci8-1.4.9
Build and install the extension.
$ phpize
$ ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib
$ make
$ sudo make install
To enable the extension, add a file named oci8.ini in /etc/php.d with
this content:
extension=oci8.so
Validate that it was successfully installed.
$ php -i | grep oci8
You should see something like this:
/etc/php.d/oci8.ini,
oci8
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
Ref: http://shiki.me/blog/installing-pdo_oci-and-oci8-php-extensions-on-centos-6-4-64bit/
I would like to mention that when the installation started is message was display something like: instantclient, /../../ to PUT THE PATH. I didn't give anything, just pressed enter. Is it the issue that i can't connect to Oracle ?
Need your help badly.
Thanks
I have managed to solve problem. Actually the problem was the the environment library was not loaded. so i have loaded the environment of oracle manually via PHP .
Here is my code:
> if (!$conn):
> /// INCLUDING ORACLE_HOME MANUALLY
> putenv("ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1/");
> // INCLUDING LD_LIBRARY_PATH MANUALLY
> putenv("LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib:/lib:/usr/lib:/lib:/usr/lib:/usr/local/lib");
>
> $conn = "(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521)))
> (CONNECT_DATA = (SERVICE_NAME = data)))";
> $conn = oci_pconnect("username", "password", $conn);
> endif;
> if($conn):
> return $conn;
> endif;
> if(!$conn):
> redirect('login');
> endif;
> }
Hope that it will help everyone
Thanks,
step-01 For correct installation oci8 refer this link
http://www.techinfobest.com/install-oci8/
After successfully installation
step-02 Check php configuration where separate section for OCI8 listed are not
<?php echo phpinfo(); ?>
if not listed.
step-03 check your httpd error log by terminal
cat /var/log/httpd/error_log
find any php error occured while after httpd service starting like
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.12.1: cannot enable executable stack as shared object requires: Permission denied in Unknown on line 0
then it is the problem in your selinux permission. find below link to proper permission.
step-03 http://www.cdatazone.org/index.php?/archives/37-PHP,-Oracle-and-SELinux.html
I have followed these steps and got success to oracle installation
For Centos 7, I do not know if works in Centos 6.
$ sudo vim /etc/ld.so.conf.d/oracle-instantclient.conf
// Add path to oracle client lib, the XX is the version, ex: /usr/lib/oracle/XX/client64/lib
$ sudo ldconfig
$ sudo service php-fpm restart
Done!

php custom C++ module works from command line, not on webserver

I made a custom PHP module with C++ and Swig. It works from the command line, but not with my webserver:
php index.php
php-cgi index.php
Both of those work fine.
I'm using lighttpd and php. I didn't configure these in any special way. I just installed them using sudo apt-get install.
Unfortunately if I make a webpage I get this:
Fatal error: Call to undefined function minikey_to_wif() in /var/www/index.php on line 6
Calling function_exists("minikey_to_wif") returns False too.
The phpinfo() does not show my module called minikey, and shows the same configuration path as the file I edited (/etc/php5/cgi/php.ini):
extension=/path/to/php-ext/minikey/minikey.so
I also tried copying it to where the other PHP extensions seem to be installed (/usr/lib/php5/20090626+lfs/) but that didn't work either.
I've been stopping, and starting lighttpd countless times. Each time, when I run ps aux | grep php, there are no results. I've also rebooted a few times to no effect. I have no idea what's up.
OK found the answer.
The extension relied on a library which was installed in a non-standard location. Normally I set LD_LIBRARY_PATH in ~/.bashrc. But when the web server ran the extension, it didn't have that environment variable.
Fix was to create a file in /etc/ld.so.conf.d/genjix.conf with /home/genjix/usr/lib and run ldconfig as root.
Try running phpinfo() using lighty. Make sure that its pointing to the correct php.ini.
If you think this is the problem you can launch php using the -c switch from inside lighttpd.conf with "bin-path" => "/path/to/php-cgi -c /path/to/php.ini":
e.g.
fastcgi.server = (
".php" => (
(
"bin-path" => "/path/to/php-cgi -c /path/to/php.ini",
"socket" => "/tmp/php.socket",
"max-procs" => 4,
"idle-timeout" => 30,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "1000"
)
)
)
)

Categories