Skip to content
Snippets Groups Projects
Commit ae42790c authored by Adam Malone's avatar Adam Malone
Browse files

Adds further support for php-memcached.

parent 5880a72f
No related branches found
No related tags found
No related merge requests found
......@@ -3,18 +3,19 @@
// Check that the memcache library is enabled
if (!class_exists('Memcache')) {
echo("Error: the memcache library appears to be unavailable.\n");
echo("\n");
echo("This is most likely because PHP doesn't load it for the command line\n");
echo("version. You probably need to enable it somehow.\n");
echo("\n");
if(is_executable('/usr/sbin/phpenmod')) {
echo("It is possible that running the following command as root will fix it:\n");
echo(" phpenmod -s cli memcache\n");
}
exit(1);
if(!class_exists('Memcache') && !class_exists('Memcached')) {
echo("Error: the memcache and memcached libraries appear to be unavailable.\n");
echo("\n");
echo("This is most likely because PHP doesn't load it for the command line\n");
echo("version. You probably need to enable one of them somehow.\n");
echo("\n");
if(is_dir('/etc/php5/cli/conf.d')) {
echo("It is possible that running one of the following commands as root will fix it:\n");
echo(" echo 'extension=memcache.so' >/etc/php5/cli/conf.d/memcache.ini\n");
echo(" echo 'extension=memcached.so' >/etc/php5/cli/conf.d/memcached.ini\n");
}
exit(1);
}
// This is the base directory of the SimpleSAMLphp installation
......
......@@ -14,9 +14,12 @@ Memcache
To enable memcache, you must first install and configure memcache on the server hosting your IdP.
You need both a memcache server and a the PHP memcache client.
How this is done depends on the distribution.
If you are running Debian Lenny, you can install both by running:
If you are running Debian Lenny, you can install both by running one of the following:
aptitude install memcached php5-memcache
aptitude install memcached php5-memcached
The memcached extension should be used for PHP 7.
*Note*: For security, you must make sure that the memcache server is inaccessible to other hosts.
The default configuration on Debian Lenny is for the memcache server to be accessible to only the local host.
......
......@@ -110,13 +110,20 @@ class SimpleSAML_AuthMemCookie
* This function creates and initializes a Memcache object from our configuration.
*
* @return Memcache A Memcache object initialized from our configuration.
* @throws Exception If the servers configuration is invalid.
*/
public function getMemcache()
{
$memcacheHost = $this->amcConfig->getString('memcache.host', '127.0.0.1');
$memcachePort = $this->amcConfig->getInteger('memcache.port', 11211);
$memcache = new Memcache;
$class = class_exists('Memcache') ? 'Memcache' : (class_exists('Memcached') ? 'Memcached' : FALSE);
if (!$class) {
throw new Exception('Missing Memcached implementation. You must install either the Memcache or Memcached extension.');
}
// Create the Memcache(d) object.
$memcache = new $class();
foreach (explode(',', $memcacheHost) as $memcacheHost) {
$memcache->addServer($memcacheHost, $memcachePort);
......
......@@ -111,7 +111,6 @@ $functionchecks = array(
'mcrypt_module_open'=> array('optional', 'MCrypt (required if digital signatures or encryption are used)'),
'session_start' => array('optional', 'Session Extension (required if PHP sessions are used)'),
'pdo_drivers' => array('optional', 'PDO Extension (required if a database backend is used)'),
'memcache_debug' => array('optional', 'Memcache Extension (required if a Memcached backend is used)'),
);
if (SimpleSAML\Module::isModuleEnabled('ldap')) {
$functionchecks['ldap_bind'] = array('optional', 'LDAP Extension (required if an LDAP backend is used)');
......@@ -129,6 +128,11 @@ foreach ($functionchecks AS $func => $descr) {
$funcmatrix[] = array('descr' => $descr[1], 'required' => $descr[0], 'enabled' => function_exists($func));
}
$funcmatrix[] = array(
'required' => 'optional',
'descr' => 'Memcache or Memcached Extension (required if a Memcached backend is used)',
'enabled' => class_exists('Memcache') || class_exists('Memcached'),
);
/* Some basic configuration checks */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment