Tag: php

Memcached Installation

Memcached is a general-purpose distributed memory caching system. It can be used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times database must be read.

Please make sure that Memcached port is opened and access is allowed only to desired servers. If the memcached port is left open to all any one can connect to it and access the data objects.

1) Install libevent

libevent is required to install memcached

# yum install libevent-devel libevent

2) Install memcached

# cd /usr/local/src
# wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
# tar -zxvf memcached*
# cd memcached*
# ./configure
# make
# make install

3) Run memcached as a daemon and make it listen on default port

Create a user,
# useradd memcache

Use the below command to run memcached
# memcached -u memcache -p 11211 &

To use memcahe with PHP on the same server , you can install it with

# pecl install memcache

Make sure that below line is added to main php.ini
extension=memcache.so
To load the module and reflect the changes restart  apache

# /usr/local/apache/bin/apachectl restart

LAMP installation from source

Overview

Installing Apache ( 2.2.17 ) , Mysql ( 5.1.54 ) and php ( 5.3.4 ) on a Centos server.

Requirements

Centos Server

Objective

Building from source an optimised/light Apache-Mysql-PHP on top of Centos server

Configuration

Step 1

Install Mysql

root@serv:~# groupadd mysql

root@serv:~# useradd -r -g mysql mysql

root@serv:~# cd /usr/local

root@serv:~# wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.54-linux-i686-glibc23.tar.gz/from/http://mysql.easynet.be/

root@serv:~# gunzip < /usr/local/mysql-5.1.54-linux-i686-glibc23.tar.gz | tar xvf –

root@serv:~# ln -s /usr/local/mysql-5.1.54-linux-i686-glibc23 mysql

root@serv:~# cd mysql

root@serv:~# chown -R mysql .

root@serv:~# chgrp -R mysql .

root@serv:~# scripts/mysql_install_db –user=mysql

root@serv:~# chown -R root .

root@serv:~# chown -R mysql data

root@serv:~# cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf

root@serv:~# bin/mysqld_safe –user=mysql &

root@serv:~# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

root@serv:~# ln -s /usr/local/mysql/bin/* /usr/bin/

Step 2

Install Apache , also install the dependent packages and compilers. You have to install the below packages for the most needed compile options that I have used.

root@serv:~# yum install gcc zlib-devel openssl-devel make

root@serv:~# cd /usr/local/src/

root@serv:~# wget http://www.alliedquotes.com/mirrors/apache//httpd/httpd-2.2.17.tar.bz2

root@serv:~# tar -jxvf httpd-2.2.17.tar.bz2

root@serv:~# cd /usr/local/src/httpd-2.2.17

root@serv:~# ./configure –prefix=/usr/local/apache –host=i686-redhat-linux-gnu –build=i686-redhat-linux-gnu –target=i386-redhat-linux  –enable-deflate –enable-proxy –enable-proxy-http—enable-proxy-connect –enable-so –enable-cgi –enable-info –enable-rewrite –enable-speling –enable-usertrack –enable-deflate –enable-mime-magic –enable-ssl

root@serv:~# make

root@serv:~# make install

Step 3

Install php, as we did before you need to install the dependencies before the php installation

root@serv:~# cd /usr/local/src/

root@serv:~# wget http://in2.php.net/get/php-5.3.4.tar.bz2/from/us.php.net/mirror

root@serv:~# tar -jxvf php-5.3.4.tar.bz2

root@serv:~# cd /usr/local/src/php-5.3.4/

root@serv:~# yum install libxml2-devel pcre-devel bzip2-devel curl-devel libjpeg-devel libpng-devel libXpm-devel libc-client-devel libmcrypt-devel libmcrypt-devel expat-devel

root@serv:~# ./configure –with-apxs2=/usr/local/apache/bin/apxs –enable-bcmath –enable-calendar –enable-ftp –enable-libxml –enable-magic-quotes –enable-pdo=shared –enable-soap –enable-sockets –enable-zip –prefix=/usr –with-bz2 –with-curl=/opt/curlssl/ –with-gd –with-imap=/opt/php_with_imap_client/ –with-imap-ssl=/usr –with-jpeg-dir=/usr –with-kerberos –with-libexpat-dir=/usr –with-libxml-dir –with-libxml-dir –with-mcrypt=/opt/libmcrypt/ –with-mhash=/opt/mhash/ –with-mysql=/usr/local/mysql/ –with-mysql-sock –with-openssl=/usr –with-openssl-dir=/usr –with-pcre-regex –with-pdo-mysql=shared –with-pdo-sqlite=shared –with-png-dir=/usr –with-sqlite=shared –with-xmlrpc –with-xpm-dir=/usr –with-zlib –with-zlib-dir=/usr

root@serv:~# make

root@serv:~# make install
Step 4

Configure php to phrase .php extension as php

root@serv:~# vi /usr/local/apache/conf/httpd.conf

find the line “LoadModule php5_module modules/libphp5.so” add the below line after it.
AddType application/x-httpd-php .php

root@serv:~# /usr/local/apache/bin/apachectl restart

Step 5

That is it, you can now test your installation

echo “<?php phpinfo(); ?> ” > /usr/local/apache/htdocs/phpinfo.php

Access and check your phpinfo page with,
http://your_server_ip/phpinfo.php