Table of Contents
Memcache Linux installation process:
This post is more like a note to me, so that in future I can look up for steps involved in installing memcache on Linux servers like Centos or RHEL.
If you have tried YUM and APT-GET and still could not install the memcache then read on, to find the alternate( read manual, without magic ) way of doing it.
When we talk about Memcache their two things that needs to be installed
- Memcache Daemon know as memcached, and
- Memcache client for your programing language, in this case PHP.
Installing Memcache Daemon
Note these steps has been taken from https://in2.php.net/manual/
Steps to install Libevent(memcached dependency)
- First we need to check if libevent is installed or not?
- type whereis libevent on shell.
- If you don’t find it, then we need to download and install it. Type following sequence of commands on your shell
- wget https://www.monkey.org/~
provos/libevent-1.4.8-stable. tar.gz - tar xfz libevent-1.4.8-stable.tar.gz
- cd libevent-1.4.8-stable
- ./configure
- make
- sudo make install
- wget https://www.monkey.org/~
- Finally we need to create a symlink to libevent
- type sudo ln -s /usr/local/lib/libevent-1.4.
so.2 /usr/lib on shell.
- type sudo ln -s /usr/local/lib/libevent-1.4.
Now that we have installed the dependencies, we will install the memcahced.
Installation steps:
- Download and install, for that type following sequence of commands on your shell
- wget https://danga.com/
memcached/dist/memcached-1.2. 6.tar.gz - tar xfz memcached-1.2.6.tar.gz
- cd memcached-1.2.6
- ./configure
- make
- sudo make install
- wget https://danga.com/
- Run Memcached as a daemon (d = daemon, m = memory, u = user, l = IP to listen to, p = port)
- type memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 on shell
Note: versions numbers mentioned here might be outdated, so do check for updated package to download.
Now we have installed and started the Memcache daemon, it’s time to install PHP client.
Installing Memcache Extension for PHP
Some of the steps mentioned below are taken fromhttps://www.sitepoint.com/
- Let’s determine the PHP version installed and also make sure it is in system path.
- type php -v on you shell, it should show something like PHP 5.2.6 (cli) (built: Nov 4 2008 09:25:57)
- type whereis php to get the path where PHP is installed in your system.
- In your accounts home directory create/edit ‘.profile’ file and add ‘
export PATH=$PATH:/usr/local/bin
‘ where ‘/usr/local/bin‘ is the folder where php executable is installed.
- Install PEAR, type following sequence of commands on your shell
- wget https://pear.php.net/go-
pear -O go-pear.php - php go-pear.php and follow the installation instructions
- ls -l ~/.pearrc
- edit the ‘.profile‘ (again) and add exportPATH=/home/yourname/
pear/bin:$PATH
- wget https://pear.php.net/go-
- Finally Install Memcache
- type pecl install memcache on your shell, it will install memcahce extension for PHP.
- Edit php.ini to add ‘extension=memcache.so‘, to find the exact php.ini file used by your system
- php -i | grep ‘php.ini’
- Restart apache, and you are done type one of the commands below to do that
- /etc/init.d/apache restart , or
- service httpd restart
I hope this helps and save some time for you.
No Comments Yet