Cannot find save handler 'redis' - php

I am running a PHP 5.4 hosted Web App on Azure. To manage session handling I have configured a Redis cache instance on Azure.
I have set the session save path & handler:
session.save_handler = redis
session.save_path = "tcp://kbcache.redis.cache.windows.net:6379?auth=***"
I have also configured the Redis extensions:
PHP_EXTENSIONS bin\php_igbinary.dll
APPSETTING_PHP_EXTENSIONS bin\php_igbinary.dll
PHP_EXTENSIONS02 bin\php_redis.dll
APPSETTING_PHP_EXTENSIONS02 bin\php_redis.dll
However when I browse to my website I receive the message:
Warning: session_start(): Cannot find save handler 'redis' - session
startup failed in D:\home\site\wwwroot\index.php(22) : eval()'d code
on line 2
What am I missing?

[Update Pre post]
When deployed PHP project, we need enable extensions on Azure.
Please see my website folder structure:
I copied the DLL files into folder named ext. And those dlls' version should be VC9 and non-thread-safe (nts) compatible.
And I created a extension.ini into folder name ini. The content as following :
extension=d:\home\site\ext\php_igbinary.dll
extension=d:\home\site\ext\php_redis.dll
zend_extension=d:\home\site\ext\php_xdebug-2.3.3-5.4-vc9-x86_64.dll
session.save_handler = redis
session.save_path = "tcp://**.redis.cache.windows.net:6379?auth=**
At last, I add the "PHP_INI_SCAN_DIR" Configurtation Panel on Azure portal:
It works for me.

Actually, I tried PHPRedis extension on my environment, it works fine.
Form your description, I think you made configuration of Redis extensions complicated.
I followed those steps:
1.Switch to PHP version 5.4
2.Download PHPRedis extension form this page.
Since I used PHP which version is version 5.4 TS, I downloaded phpredis_5.4_vc9_ts
3.After unzipped the download file, Please copy those DLL file into your PHP ext folder. It seems that you need pay attention to this point.
Add this code into your PHP.ini file
extension=php_igbinary.dll
extension=php_redis.dll
session.save_handler = redis
session.save_path = "tcp://**.redis.cache.windows.net:6379?auth=**
4.Create a Page and test Redis Code:
$redis=new Redis();
$redis->pconnect('tcp://**.redis.cache.windows.net', 6379);
$redis->auth('**+**=');
$redis->set('key', 'hello ');
$redis->append('key', 'world ');
echo $redis->get('key');

had similar issues. make sure redis dll file is there and enabled in php.ini also make sure that redis folder has full write permissions.

Related

My computer has two php folders so I either can't connect to SQL Server or install Laravel

I spent two days setting up my PHP connection to SQL Server.
I downloaded the drivers, added them to the C:\Program Files\php\ext folder (as indicated by phpinfo()). Then I modified the php.ini file to add those extensions. Then I went to services and restarted "SQL Server EXPRESS". Nothing worked until I found that PHP is also installed in another folder on my PC: C:\Program Files\iis express\PHP\v8.0. So I added the drivers there too and changed the php.ini file and restarted the SQL Server EXPRESS service (is that what they mean with restarting your web server?). The phpinfo() page said:
Configuration File (php.ini) Path: no value
Loaded Configuration File: C:\Program Files\iis express\PHP\v8.0\php.ini
and there was no section "sqlsserver". I gave up and the next day it magically worked. The phpinfo had a "sqlserver" section and the connection to my database no longer said "Call to undefined function sqlsrv_connect()".
Now, I had to download Laravel for my course, and install Composer. When doing so, it was unable to install when I had C:\Program Files\iis express\PHP\ as my PATH and it asked me if I wanted to make C:\Program Files\php\ my PATH instead. So I clicked yes, and the installation was successful.
Laravel works, however now my database connections with SQL Server don't work anymore! I get the same old "Call to undefined function sqlsrv_connect()" error, and my phpinfo() now says
Configuration File (php.ini) Path:
Loaded Configuration File: C:\Program Files\php\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
and there is no longer a "sqlsserver" section on the page.
I have tried everything in StackOverflow articles, such as removing the semicolon in the php.ini extension, including the full address in the extensions in the php.ini file, including the extensions of the other php folder into this php.ini file, restarting SQL Server service, etc. But nothing works. I also don't know how to reset the old PHP folder back into the PATH variable.
My connection code is:
$con = sqlsrv_connect( 'localhost' ,
[ 'Database' => 'sample_db' ,
'UID' => 'sample_user' ,
'PWD' => 'sample_password' ]
);
//Print error message if the database doesn't connect
if ($con === false ){
echo 'Failed to connect to db: ' . sqlsrv_errors()[ 0 ][ 'message' ];
exit ();
}
How can I have these two php folder on my computer both work, the one for my PHP SQL Server database connection, and the other for my Laravel programme to run? Has anyone else had this issue and I so, what worked for you?
I managed to resolve this by changing the PATH back to the php folder instead of the iis/php folder. I was worried that would break my Laravel now, but it didn't.

Unable to load Environment Variable Path with Jboss and PHP

I am trying to use the Oracle connectivity by oci_connect function with JBoss (where Server API is CGI/FastCGI), I am unable to show environment variable over phpinfo() function with JBoss(where Server API is CGI/FastCGI), which is already working fine with PHP and Apache.
Below are the parameters which are showing by jboss/(CGI/FastCGI), system environment variable PATH(which is needed to enable the oci8 module of php) and some other parameters are missing with JBoss.
CGI/FastCGI Environment
Variable Value
PHP_FCGI_CHILDREN 5
PHP_FCGI_MAX_REQUESTS 10000
REDIRECT_STATUS 200
SystemRoot C:\WINDOWS
__COMPAT_LAYER ElevateCreateProcess
Apache Environment
HTTP_COOKIE csrftoken=5LL6M3KDqW6zbW947SUd5qKiDNYvkDiKtNTKO8kbAhiECWitdjdncL2ZRnQQyYVl; PHPSESSID=s2fcp7cbjijjc77i5g195koiil
PATH C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\RSA SecurID Token Common........;
Can anyone provide the help/steps to display the environment variable with JBoss and CGI/FastCGI?
FYI: I am using the window 10 environment.
As I verified the my Project.war file, which has been bundled the php-cgi.exe with php 5.6, here we had the wrong version of java.inc file which Compile The PHP/Java Bridge for PHP library.
I changed my java.inc file then the issue have resolved, and now I can see the oci_connect module inside the phpinfo()
So I realized that, I would have need to use correct java bridge file.
OCI8 Module

PHP SNMP Warning: SNMP::get(): No response from 127.0.0.1

I'm trying to get PHP SNMP to work on XAMPP PHP 7.1.9
I'm always getting this result: Warning: SNMP::get(): No response from 127.0.0.1
Here's what I did:
Enabled php_snmp.dll on php.ini
Installed net-snmp-5.5.0-2.x64
Added windows environment variable MIBDIRS with value C:\usr\share\snmp\mibs
Code I'm running to test:
<?php
$session = new SNMP(SNMP::VERSION_1, "127.0.0.1", "public");
$sysdescr = $session->get("sysDescr.0");
echo "$sysdescr\n";
$session->close();
I'm new to this so I'm not sure what I'm missing.
The problem was with the MIBDIRS path.
I followed php docs and it says:
The Windows distribution of Net-SNMP contains support files for SNMP in the mibs directory. This directory should added to Windows' environment variables, as MIBDIRS, with the value being the full path to the mibs directory: e.g. c:\usr\mibs.
Problem was I couldn't find c:\usr\mibs on my net-snmp installation so I used C:\usr\share\snmp\mibs instead.
Solution:
I tried using a device with snmp support instead of 127.0.0.1 and ran snmpget on cli and confirmed net-snmp installation actually works. I figured the problem must be with the path php is using to run snmp.
So I used where snmpget to check the command path then changed MIBDIRS environment value with the result which is C:\usr\bin\snmpget.exe

Install ingres extension for php on my WAMP server

I've a development computer, which runs under windows.
For a project, I've to make a php website which has to connect to an Ingres database server.
So I installed wamp, I installed ingres(server and client, on my local machine).
I added the library that I found on their site(php_ingres.dll) in the C:\wamp\bin\php\php5.3.5\ext folder, and I added a line "extension=php_ingres.dll" in the configuration file.
I shutdown wamp and restarted it, and I restarted the server, I see now a check mark in the wamp menu, indicating that php_ingres is now activated. But when I go to the welcome page of the server, I don't see this extension as loaded. If I go on the php info page, I don't see any Ingres entry in the Configure Command.
I just can't found any post/tutorial/... which indicating how to do this operation, so any help would be appreciated!
Thank you!
Edit: I made a small test to see if I can connect to an Ingres database:
<?php
$link = ingres_connect("localhost", "demodbtest", "demodbtest") or die("Connexion impossible");
echo "Connexion réussie";
$result = ingres_query($link,"select * from airline");
while ($row = ingres_fetch_array($result)) {
echo $row["al_iatacode"]; // utilisation du tableau associatif
echo $row["al_name"];
echo $row["al_ccode"]; // utilisation du tableau à indices numériques
echo "</br>";
}
ingres_close($link);
?>
And I get this error:
( ! ) Fatal error: Call to undefined function ingres_connect() in
C:\wamp\www\tests\index.php on line 2
Some information on my installation:
I've a windows 7 pro 32bits
Wampserver 2.1 ( http://sourceforge.net/projects/wampserver/files/WampServer%202/WampServer%202.1/WampServer2.1e-x32.exe/download )
Apache 2.2.17
PHP 5.3.5
Ingres 10.1.0 Community edition( downloaded here: http://esd.ingres.com/product/Community_Projects/Ingres_Database/Windows_32-Bit/Ingres_10.1_Build_121/ingres-10.1.0-121-gpl-win-x86-NoDoc.zip/http )
PHP drivers downloaded here: http://esd.ingres.com/product/drivers/PHP/Windows_32-Bit/PHP_Driver
To practically test if the extension was loaded you can as well call one of it's functions. If the extension was loaded, you should not get a fatal error for a missing function. That's perhaps one of the quickest checks.
Another check is to make use of extension_loaded *PHP Manual** which will give you a list of all loaded extensions. See the PHP Manual link above for more info.
The configure line
The configure line will not show the ingres extension because it has not been compiled in. That's perfectly alright because you load it as an extension (.dll) so it's not part of php.exe. This is why you don't see it in the configure line.
Locating ingres on the phpinfo() page.
On the phpinfo()-page use the search function inside your browser (often CTRL+F) and try to locate the word ingres. You should locate a section that displays the extensions default settings if it has been loaded.
The following is an example screenshot for the xdebug extension. This might look similar for ingres:
Image from: Launching xdebug in Eclipse stuck at 57% - How to trouble-shoot?
Double check your extension_dir setting as well as the actual php.ini file being used. Calling php.exe -i from the command line might not give the same output if executing phpinfo() in a script via Apache (or IIS). In fact http://www.wampserver.com/en/faq.php says there are 3 potential php.ini scripts.
The problem is that I wasn't having the ingres client installed locally, so it appears that this lib cannot works without it

PHP Extension (memcache|memcached) not showing in phpinfo() but showing in php -m and php -i?

I am getting both modules listed as installed / configured when I use:
php -m
or if I use:
php -i
but when I use:
$m = new Memcache;
// or
$m = new Memcache();
// or
$m = new Memcached();
//or
$m = new Memcached;
I get the following error:
Fatal error: Class 'Memcached' not found
I am running on a Mac - OS X (10.5.7) with default install of apache & php. Additionally, I have memcached running as a daemon on 127.0.0.1:11211 and libmemcache as required by the php-memcached library. I have restarted apache tons of times and even done a machine restart.
Does anyone know why the modules/extensions show up in the command line but not in my phpinfo()? I am literally stumped, after 3 hours of googling, I am just about ready to give up.
Also, please note, my phpinfo() outputs my ini files as follows AND they are both the exact same file:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /private/etc/php.ini
UPDATE:
Apache is failing to load the extension.
[Fri May 14 04:22:26 2010] [warn]
Init: Session Cache is not configured
[hint: SSLSessionCache] PHP Warning:
PHP Startup: Unable to load dynamic
library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcached.so'
- (null) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load
dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so'
- (null) in Unknown on line 0
Does anyone know why or how this would happen? Both of the files referenced above DEFINITELY ARE there. Should I move this question to server fault?
Your webserver is probably using mod_php, which is a seperate bit of code from the standalone (CLI) interpreter. If they are both using the same ini file, and the memcache extension is configured in the ini file, then it sounds like for some reason, the mod_php is failing to load the extension - check your webserver error_log for startup errors.
It may be that the mod_php was compiled without memcache support (most extensions need to have a stub file linked into the php code, even though the bulk of the code is not linked until run time). Or it may be a permissions problem on the shared object file. Or your webserver may be running chroot, and unable to find the extension (which would also mean that although the ini files appear to have the same path, this is relative to different roots).
HTH
C.
because both versions use different php.ini
place your php.ini into location noted in the phpinfo() outout
I would suspect that the issue revolves around permissions. When you run php from comand line, it runs as the user invoking it. When run as an apache module, it runs as "nobody".
I would assume that the memcached.so file, or the directory it's in does not have proper permissions.
I stumpled upon this post and was having the exact same problem with an extension in my php -i but not in phpinfo(). Mine was a permissions problem because of selinux on a CentOS machine. I had to change ownership and permissions and now it is working as expected.
Set php path in environment variables as given below.
Right-click on "My Computer"
Properties
Advanced Tab > Environment Variables
Under System variables, scroll down to find "Path", select and click on Edit.
Add path to your php install on the end (make sure to precede with semi-colon ";"). Example: ";C:\php7"
Click Ok.

Categories