Memcached installation, memcached.so missing

postcd

Well-Known Member
Oct 22, 2010
721
21
68
Im lost in Memcached installation on my cpanel centos server.

I have Memcached ticked in EasyApache, also its amongs the extensions in php config:
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"
zend_extension = "/usr/local/IonCube/ioncube_loader_lin_5.2.so"
zend_extension = "/usr/local/Zend/lib/Optimizer-3.3.9/php-5.2.x/ZendOptimizer.so"
extension = "xcache.so"
extension = "memcached.so"

When i do /usr/local/apache/bin/httpd -l

i see its included: mod_mem_cache.c (or isnt it memcached?)

In directory /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ there is memcached.so missing

My website error log shows:
[11-Feb-2012 18:17:42] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcached.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcached.so: cannot open shared object file: No such file or directory in Unknown on line 0
[11-Feb-2012 18:17:42] PHP Fatal error: Cannot open or create file set by xcache.mmap_path, check the path permission or check xcache.size/var_size against system limitation in Unknown on line 0
[11-Feb-2012 18:17:42] PHP Fatal error: XCache: Cannot create shm in Unknown on line 0

Please how can i install memcached now?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello :)

Check to see if the "memcached.so" file exists at the referenced location:

Code:
/usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcached.so
If it does not exist at that location, check to see if it exists within the following directory:

Code:
/usr/lib/php/extensions/no-debug-non-zts-20060613
If it does, try moving the file to the "/usr/local/lib/php/extensions/no-debug-non-zts-20060613" location and restarting Apache.

Thank you.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
EasyApache MemCache is the Apache module rather than the PHP module as we do not list or provide the PHP module there. When you compile EasyApache with the MemCache Apache module, you end up with it available via Apache only not via PHP.

For the PHP module, what steps were taken to install it manually, since that would be the only way to install it? Please try the following steps if you hadn't already (and if you had, you likely lost memcached.so when recompiling PHP via EasyApache since it was a custom installed module):

Code:
wget https://github.com/downloads/libevent/libevent/libevent-2.0.17-stable.tar.gz --no-check-certificate
tar -xvf libevent-2.0.17-stable.tar.gz 
cd libevent-2.0.17-stable
./configure
make && make install
cd ~
wget http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz
tar -xzf memcached-1.4.13.tar.gz 
cd memcached-1.4.13
./configure
make && make install
After installing these components, then create the following file:
(if using 32-bit machine)
Code:
echo "/usr/local/lib/" > /etc/ld.so.conf.d/libevent-i386.conf
(if using 64-bit machine)
Code:
echo "/usr/local/lib/" > /etc/ld.so.conf.d/libevent-x86_64.conf
Run the following:

Code:
ldconfig
memcached -d -u nobody -m 1024 127.0.0.1 -p 11211
Now, install libmemcached:

Code:
cd ~
wget http://launchpad.net/libmemcached/1.0/1.0.4/+download/libmemcached-1.0.4.tar.gz
tar -zxvf libmemcached-1.0.4.tar.gz 
cd libmemcached-1.0.4
./configure
make && make install
pecl install memcached
Then run the following to check if memcached.so is installed into /usr/local/lib/php.ini file and add it if is it not:

Code:
grep -q "memcached.so" /usr/local/lib/php.ini || echo 'extension=memcached.so' >> /usr/local/lib/php.ini
You can check the extension directory you are using and whether it is in it using this line:

Code:
for i in `grep ^extension_dir /usr/local/lib/php.ini | awk {'print $3'} | cut -d\" -f2` ;do ls -lah $i/memcache* ;done
Also, to preserve the memcached.so module on EasyApache recompiles, this needs to be done as well:

Code:
for i in `grep ^extension_dir /usr/local/lib/php.ini | awk {'print $3'} | cut -d\" -f2` ;do cp $i/memcached.so /root ;done
for i in `grep ^extension_dir /usr/local/lib/php.ini | awk {'print $3'} | cut -d\" -f2` ;do echo -e '#!/bin/bash\ncp /root/memcached.so' "$i\ngrep -q 'memcached.so' /usr/local/lib/php.ini || echo 'extension=memcached.so' >> /usr/local/lib/php.ini\n/etc/init.d/httpd restart" > /usr/local/cpanel/scripts/posteasyapache ;done
chmod +x /usr/local/cpanel/scripts/posteasyapache
This will create a posteasyapache script that will ensure memcached.so is copied from /root/memcached.so back into the php extension directory.

I followed the above details, and it shows up installed onto my machine:

Code:
root@host [~]# php -i | grep -i memcached
memcached
memcached support => enabled
libmemcached version => 1.0.4
Registered save handlers => files user sqlite memcached
Thanks!
 
Last edited:

santrix

Well-Known Member
Nov 30, 2008
230
4
68
I've read this thread with interest. However, I'm unsure from what I have read if the solution posted by cPanelTristan for installing the PHP extension/so is necessary if installing MemCache using easyapache. cPanelTristan seems to indicate that the EA installation of Memcache (being referenced only in the apache section) does not install the PHP extension, and installs an apache module only.

I'm confused because at the start of the thread after postcd stated he was lost in EasyApache, cPanelMichael asked if the PHP extensions had, in fact, been installed...

I suspect this is simply an oversight, but before I go installing memcached PHP extensions on our servers, I would like to know if this should be done manually as detailed by cPanelTristan, or if they should in fact get installed, allbeit atypically, via the apache module memcache installer (as a bonus!)

Cheers
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
We do not provide MemCache as a PHP module via EasyApache. However, it's possible to install it as a custom PHP module using the method that Tristan provided.

Thank you.
 

grava69

Member
May 8, 2012
12
0
51
cPanel Access Level
Website Owner
I have followed your instructions to install memcahe in PHP but when I reached the point where you say:
"You shoudl also find the file in /usr/local/lib/php/extensions/no-debug-non-zts-20090626
Code:
ls -lah /usr/local/lib/php/extensions/no-debug-non-zts-20090626/memcached.so "
the file doesn't exist

I have attached a screenshot of where I was stuck.

Also in your instructions you say:
"After installing these components, then create the following file:
(if using 32-bit machine)
Code:
vi /etc/ld.so.conf.d/libevent-i386.conf
(if using 64-bit machine)
Code:
/etc/ld.so.conf.d/libevent-x86_64.conf "

In my 64-bit machine should I just create an empty file like that?
pico /etc/ld.so.conf.d/libevent-x86_64.conf

Please let me know where I might be wrong. Thanks
 

Attachments

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Are you using PHP 5.2? If you are, then the directory for /usr/local/lib/php/extensions will have 2006 rather than 2009 in it. You can find the extension directory being used in your global php.ini file:

Code:
grep ^extension_dir /usr/local/lib/php.ini
Check that directory for the file.

If you are on a 64-bit machine, you'd create the file as the instructions indicate you would, yes.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Not if all the instructions were followed in the order noted. Since the file noted that needed to be created was before the installation, did you create the file (your response indicates that /etc/ld.so.conf.d/libevent-x86_64.conf was possibly not created during the instructions). If it was not created, then the components won't properly install.
 

grava69

Member
May 8, 2012
12
0
51
cPanel Access Level
Website Owner
I did created /etc/ld.so.conf.d/libevent-x86_64.conf
I opened it and it was empty.
I just went through the steps again
When I reached : memcached -d -u nobody -m 1024 127.0.0.1 -p 11211
I got the error you see in the screenshot
 

Attachments

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
That error indicates libevent isn't being found. Did you receive an error when installing it? It was the very first steps of all of those noted.

Did this error not happen previously? I don't see how re-running the steps in the correct order would cause that command to suddenly fail when it worked before.
 

grava69

Member
May 8, 2012
12
0
51
cPanel Access Level
Website Owner
I see nowhere giving me an error when I went through the first steps:
Code:
wget github.com/downloads/libevent/libevent/libevent-2.0.17-stable.tar.gz --no-check-certificate
tar -xvf libevent-2.0.17-stable.tar.gz
cd libevent-2.0.17-stable
./configure
make && make install
The file libevent-2.0.so.5 does exist in the .libs folder within libevent-2.0.17-stable, but why it cannot be found?

I have attached part of the ls in the .libs folder where you can see the file.
 

Attachments

Last edited by a moderator:

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
That is not the folder after it is configured. The folder after it is configured with the ./configure command and make && make install would be /usr/local/lib one:

Code:
root@host [/usr/local/lib]# ls -lah libevent-2*
lrwxrwxrwx 1 root root   21 May  9 08:04 libevent-2.0.so.5 -> libevent-2.0.so.5.1.5*
-rwxr-xr-x 1 root root 946K May  9 08:04 libevent-2.0.so.5.1.5*
You can even run whereis libevent to see this listing:

Code:
root@host [/usr/local/lib]# whereis libevent
libevent: /usr/local/lib/libevent.la /usr/local/lib/libevent.so /usr/local/lib/libevent.a
 

grava69

Member
May 8, 2012
12
0
51
cPanel Access Level
Website Owner
Yes, the file exists:

root@64-150-181-16 [/libevent-2.0.17-stable/.libs]# cd /usr/local/lib
root@64-150-181-16 [/usr/local/lib]# whereis libevent
libevent: /usr/local/lib/libevent.la /usr/local/lib/libevent.so /usr/local/lib/libevent.a
root@64-150-181-16 [/usr/local/lib]# ls -lah libevent-2*
lrwxrwxrwx 1 root root 21 May 8 17:54 libevent-2.0.so.5 -> libevent-2.0.so.5.1.5*
-rwxr-xr-x 1 root root 940K May 8 15:21 libevent-2.0.so.5.1.4*
-rwxr-xr-x 1 root root 947K May 8 17:54 libevent-2.0.so.5.1.5*

but I still get this error after ldconfig:
root@64-150-181-16 [~/memcached-1.4.13]# ldconfig
root@64-150-181-16 [~/memcached-1.4.13]# memcached -d -u nobody -m 1024 127.0.0.1 -p 11211
memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

actually this error was there from the first time I went through the steps but I ignored it
and went through the following steps. I have no idea what to do now.
 
Last edited by a moderator:

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
All right, try the following and I'm revising the guide for this portion:

Code:
echo "/usr/local/lib/" > /etc/ld.so.conf.d/libevent-x86_64.conf
ldconfig
memcached -d -u nobody -m 1024 127.0.0.1 -p 11211
Then follow the rest of the guide and let us know of any further errors. Please do not ignore errors.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Of note, it appears the newer PHP is not adding memcached.so to /usr/local/lib/php.ini (I had no trouble of it adding the memcached.so to /usr/local/lib/php/extensions/no-debug-non-zts-20090626 though). Here are revisions on those prior steps:

Code:
grep -q "memcached.so" /usr/local/lib/php.ini || echo 'extension=memcached.so' >> /usr/local/lib/php.ini
You can check the extension directory you are using and whether it is in it using this line:

Code:
for i in `grep ^extension_dir /usr/local/lib/php.ini | awk {'print $3'} | cut -d\" -f2` ;do ls -lah $i/memcache* ;done
This takes out the ability for the user to not know which they are using as it pulls it from the php.ini file.

Also, to preserve the memcached.so module on EasyApache recompiles, this needs to be done as well:

Code:
for i in `grep ^extension_dir /usr/local/lib/php.ini | awk {'print $3'} | cut -d\" -f2` ;do cp $i/memcached.so /root ;done
for i in `grep ^extension_dir /usr/local/lib/php.ini | awk {'print $3'} | cut -d\" -f2` ;do echo -e '#!/bin/bash\ncp /root/memcached.so' "$i\ngrep -q 'memcached.so' /usr/local/lib/php.ini || echo 'extension=memcached.so' >> /usr/local/lib/php.ini\n/etc/init.d/httpd restart" > /usr/local/cpanel/scripts/posteasyapache ;done
chmod +x /usr/local/cpanel/scripts/posteasyapache
This will create a posteasyapache script that will ensure memcached.so is copied from /root/memcached.so back into the php extension directory.

I didn't do the above type of commands when I originally created the steps as I didn't know how to do these things back then. I know a lot more now.
 

grava69

Member
May 8, 2012
12
0
51
cPanel Access Level
Website Owner
Everything fine up to this point where i get this error:

root@64-150-181-16 [~/libmemcached-1.0.4]# for i in `grep ^extension_dir /usr/local/lib/php.ini | awk {'print $3'} | cut -d\" -f2` ;do ls -lah $i/memcache* ;done
/bin/ls: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/memcache*: No such file or directory
 
Last edited by a moderator:

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
The component still didn't install while it did on my system. You received no errors when running "pecl install memcached"?

Please re-run the pecl installation command for memcached and provide the last 10 or so lines.
 

grava69

Member
May 8, 2012
12
0
51
cPanel Access Level
Website Owner
It says is already installed:

root@64-150-181-16 [~/libmemcached-1.0.4]# pecl install memcached
pecl/memcached is already installed and is the same as the released version 2.0.1
install failed
 
Last edited by a moderator: