Posts Tagged ‘Apache’

How to install Memcache in cPanel?

Tuesday, September 28th, 2010

Take a coffee, this is going to be a long process.

Step 1: Configure Apache
Login to cPanel and start EasyApache. At the Exhaustive Option List choose Memcache. Compile Apache & Restart it.

Step 2: Memcache requires LibEvent
LibEvent can be downloaded from Monkey.org. Download the last 1.4.x available version.

wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
tar xvfz libevent-1.4.14b-stable.tar.gz
cd libevent-1.4.14b-stable
./configure; make; make install

Step 3: Register LibEvent

nano /etc/ld.so.conf.d/libevent-i386.conf

Add the following text inside:

/usr/local/lib/

and at last, run:

ldconfig

Step 4: Compile and install Memcache (deamon)
Now you can install Memcache with the last version from their site.

wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
tar xvfz memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure; make; make install

Step 5: Install PHP extension for Memcache
Normall, you should be able to do this from cPanel but i get a compiling error. So here is an alternative:

wget http://pecl.php.net/get/memcache-3.0.3.tgz
tar xvfz memcache-3.0.3.tgz
cd memcache-3.0.3
phpize
./configure
make
make install

Edit /usr/local/lib/php.ini

nano /usr/local/lib/php.ini

and copy paste at the end of the file:

extension=memcache.so

and at last, restart Apache:

service httpd restart

Step 6: Run Memcache as a deamon on the startup files

nano /etc/memcached.conf

and add inside:

#Memory a usar
-m 16
# default port
-p 11211
# user to run daemon nobody/apache/www-data
-u nobody
# only listen locally
-l 127.0.0.1

create the startup files

touch /etc/init.d/memcached
chmod +x /etc/init.d/memcached

and add inside it

nano /etc/init.d/memcached

the following text

then run:

touch /usr/local/bin/start-memcached
chmod +x /usr/local/bin/start-memcached

and add inside the following text

Now, let’s test the scripts:

/etc/init.d/memcached restart

and review if the conf file is parsed ok:

ps aux | grep memcached

and last, add memcached as autostart deamon

/sbin/chkconfig memcached on
/sbin/chkconfig --list | grep memcached

it should output:

memcached 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Step 7: Test Memcache in PHP
Create the memcache.php file and add this text
You should have in the browser:

String to store in memcached.

Apache Error “Permission denied: make_sock: could not bind to address”

Friday, June 19th, 2009

If you run Centos and you want to create a new vhost but you get the following error:

Error "Permission denied: make_sock: could not bind to address"

Then you need to issue:

# semanage port -a -t http_port_t -p tcp 6077

where 6077 is the port you want to have it opened for your vhost.