I'm busting my brains over this issue (it should be straightforward), but can't seem to find a solution so hopefully one of you can help me. I'm trying to store sessions using php's memcache extension.
I'm running MAMP and have installed the extension correctly (I think...it shows up when I do phpinfo), am running the daemon and can connect to it through php, using something like this:
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
So I KNOW that php can communicate with the daemon. The problem is when I enable memcache session storage in php.ini and try to do a session_start() it gives me an error that it "Cannot find save handler memcache". This is what is in my php.ini:
session.save_handler = memcache
session.save_path = "tcp://127.0.0.1:11211"
Any help would be much appreciated =(
Some additional info:
Installed using the directions here:
http://lullabot.com/articles/setup-memcached-mamp-sandbox-environment
on OSX 1.6.4 and i put the .so file in the proper directory
Memcached, not Memcache. Same as the name of the class.
session.save_handler = memcached
EDIT since the OP indicated that it was just a typo.
There are some similar stories here:
http://www.dotdeb.org/2008/08/25/storing-your-php-sessions-using-memcached/
http://phpslacker.com/2009/03/02/php-session-clustering-with-memcache/
Did you say "yes" when the installer asked you "Enable memcache session handler support?"
If it doesn't work, try the new Memcached extension (with the D). It's supposed to be better somehow.
If you want to use memcached instead of memcache, make sure you don't have tcp:// in your session.save_path. So you should fix your session.save_path from
session.save_path = "tcp://127.0.0.1:11211"
to
session.save_path = "127.0.0.1:11211"
You might just still need to install the PHP memcached extension, for example yum install php55-pecl-memcached
You will need to enable the memcache session handler support then installing php5-memcache. Which OS are you using and how have you installed it?
Related
I have an issue with PHP when I use session with save_handler redis or memcached.
I use the ProcessWire CMS and both session handler method working generally fine but I found one strange behaviour: I can't upload multiple images in parallel. The image which finishes at least are overriding all other uploaded images in the database.
Since yet, nobody used really ProcessWire with this session handlers and I guess it isn't a bug in ProcessWire itself. Maybe it is a bug in phpredis, memcached extension or PHP itself or I have some wrong configuration.
I used following in php.ini:
For Redis:
session.save_handler = redis
session.save_path = "tcp://127.0.0.1:6379"
For memcached:
session.save_handler = memcached
session.save_path = "127.0.0.1:11211"
Could it depend on something like session locking?
Deactivating/activating it doesn't help me.
The issue in the processwire github repo:
https://github.com/processwire/processwire-issues/issues/798
I found a solution. I added following to my php.ini
redis.session.locking_enabled = 1
redis.session.lock_expire = 60
redis.session.lock_retries = -1
I have Trying to use MemCached but its showing "class not Found error"
$Memcached = new Memcached();
$Memcached->addServer('127.0.0.1', 11211);
But when i Use Memcache everything works Fine :-
$memcache = new Memcache;
$memcache->connect("127.0.0.1",11211);
I have placed memcache.dll file in php ext directory and enable it in php.ini and i have also installed memcache.exe in windows as a service.
Just want to know what i am missing or what i need to do differently as memcache works like a charm while Memcached is showing error.
EDIT:-
Memcache is installed and visible in the phpinfo file, thats why memcache is working but memcached is not working.I guess memcached is not feasible with windows.
I started to use memcached for storing session files, but Session doesn't work and apache sends response too slow. How can I solve the problem?
Modifications in php.in are:
;session.save_handler = files
session.save_handler = memcached
session.save_path = "tcp://127.0.0.1:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
I solved the problem, Solution is connection url without tcp://
,so session.save_path should be
session.save_path = "127.0.0.1:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
read this page:
http://www.php.net/manual/en/memcached.sessions.php
you should modify php.ini like that
session.save_handler = memcached
Change memcached to memcache
Maybe Helpful for you
Else
That Check For Server Permissions And Check For Charset of Your PHP script And
Put this code:
in being:
<?php
ob_start ();
?>
at the end:
<?php
ob_flush ();
?>
I have a simple setup of IIS 7 with PHP 5.4. Everything has been working fine until I needed to add MS SQL Server support. I downloaded the SQLSRV package provided through this link, extracted the appropriate DLLs to my PHP ext directory and added the extension entry/configuration in php.ini like so:
; MS SQL Server
extension=php_sqlsrv.dll
;extension=php_pdo_sqlsrv.dll
[sqlsrv]
sqlsrv.LogSubsystems=-1
sqlsrv.LogSeverity=-1
sqlsrv.WarningsReturnAsErrors=0
... with an additional change to the extension_dir setting:
extension_dir = "ext"
..., and restarted my server. Now, when I run any request, I get:
PHP_RINIT for php_sqlsrv: entering
sqlsrv.WarningsReturnAsErrors = Off
sqlsrv.LogSeverity = -1
sqlsrv.LogSubsystems = -1
sqlsrv.ClientBufferMaxKBSize = 10240
PHP_RSHUTDOWN for php_sqlsrv: entering
Sometimes, the first line is missing, but it's generally the same problem. No page is generating proper text/HTML anymore! What has happened? Thanks.
On the balance of probability, I imagine you're using the wrong sqlsrv dll. First things first: did you download SQLSRV from here?
I'll assume you want the PDO version (I use it; it works very well!). From the file name, I can't tell what you have, but for your circumstances you should should be using php_pdo_sqlsrv_54_nts.dll. As you're using IIS, you'll have an NTS version of PHP, which should be used with non thread safe extensions.
Try replacing the dll you're using with that one, and reload the application pool in IIS. phpinfo() should show sqlsrv as an available PDO driver. Let me know how you get on... :)
How can I use memcache in Joomla? I'm a newbie in this field so please be descriptive with your answer.
You will need to install memcached on your server and will probably need root access to do so. You can get memcached from http://www.danga.com/memcached/. It requires libevent, which can be downloaded here: http://www.monkey.org/~provos/libevent/
Finally, you'll need to get the PHP PECL extension for memcache. To install this, you need to go to the server where PHP is installed and run this command:
pecl install memcache
Again, you will most likely need root access to your server to do this. After you have libevent, memcached, and the PECL extensions installed, go to the Global Configuration in Joomla and choose Memory Cache as the Cache Handler under Cache Settings. After you save the Global Configuration, open it again and more inputs should appear underneath the Cache Handler input. Set Memory Chache Server to localhost and the port to 11211. This should match the parameters you use to run memcached from the command line.
EDIT: You can also use XCache not only to store data in a way similar to Memcache, but it will also cache the opcode generated by PHP. This way, instead of reading the PHP code from disk and parsing it each time, it will hold the code in memory for the next request.
Be sure to select XCache as the Cache Handler in Global Configuration. Read this for information on installing XCache: http://xcache.lighttpd.net/wiki/InstallFromSource
In order to make Joomla to use memcache for session caching you need to manually edit the configuration.php and change this line:
public $session_handler = 'database';
to this one:
public $session_handler = 'memcache';
And this is what is missing everywhere, you need to add a new option memcache_settings:
public $memcache_settings = 'a:3:{s:10:"persistent";s:1:"0";s:11:"compression";s:1:"0";s:7:"servers";a:1:{i:0;a:2:{s:4:"host";s:9:"127.0.0.1";s:4:"port";s:5:"11211";}}}';
This is a serialized multy-dimentianal array. I use this code to generate the above string:
$a = array(
"persistent" => "0",
"compression" => "0",
"servers" => array(
"0" => array(
"host" => "127.0.0.1", "port" => "11211")
)
);
echo(serialize($a));
If you don't add the memcache_settings option your sessions will never work with memcache.
These settings in configuration.php work for memcached in Joomla 3.3+
public $cache_handler = 'memcached';
public $memcached_server_host = '127.0.0.1';
public $memcached_server_port = '11211';
public $memcached_persist = '1';
public $memcached_compress = '1';
public $cachetime = '15';
public $session_handler = 'memcached';
public $session_memcached_server_host = '127.0.0.1';
public $session_memcached_server_port = '11211';
To install memcached on a Debian system:
apt-get install memcached php5-memcached
(you can also use memcache in place of each occurence of memcached in the above public variables & install the older php5-memcache extension)
Upgrading to php5.5 will give you a builtin Zend Opcode Cache - this could be used with APCu (APCu is the Alternative PHP Cache with the Opcode Cache removed) - to cache userland locally if you do not need a distributed memory cache (memcached)
For a single VPS APCu has a lower memory footprint & is a more suitable cache (especially with php5.5) & can be set in configuration.php with:
public $cache_handler = 'apc';
public $session_handler = 'apc';
This how to might also offer some help for Joomla 2.5 as it points to the Joomla Admin Screen to use memcache http://www.siteground.com/tutorials/supercacher/joomla_memcached.htm
It's better to not use APC for backend cache. This can cause a lot of fragmentation. I have only seen it degrade performance of Joomla.