Installing The PHP-MemCache Module On CentOS

Centos, PHP No Comments »

“MemCached” is a
high-performance, distributed memory object caching system, generic in nature,
but intended for use in speeding up dynamic web applications by alleviating
database load.

In this howto I explain how you can very simply install it and make it aviable in PHP.�

You need to activate the RPMForge custom
repository (formely known as Dag Wieers): http://dag.wieers.com/rpm/packages/rpmforge-release/

Grab your specific RPM and install it:

wgethttp://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-*.rpm

rpm –install rpmforge-release-*.rpm

yum install –enablerepo=rpmforge memcached

Now memcached is installed.

You can test it

memcached -m 512 -u nobody -vv

First, you start up the memcached daemon on
as many spare machines as you have. The daemon has no configuration file, just
a few command line options, only 3 or 4 of which you’ll likely use:

./memcached -d -m 2048 -l 10.0.0.40 -p 11211 -u nobody

This starts memcached up as a daemon, using 2GB of memory, and listening
on IP 10.0.0.40, port 11211. The -m switch specifies the amount of memory in megabytes. The -l switch specifies the IP to listen on and finally the -p switch specifies the port to listen on. The default port is 11211 and if your machine has just 1 IP you can omit the -l parameter. In the above example I set the amount of memory to 2GB. Of course you should use a sensible amount of memory. Making your machine swap to disk sort of defeats the purpose of a memory cache daemon. Note that it’s perfectly fine to run the memcached daemon on another machine than the one you’re running your actual PHP project on. You could even set up a machine totally dedicated to being a memory cache server. And if that’s not even enough you can set up muliple servers as well. The sky is the limit. Note: if you try to start the memcached as root it will require you to specify a user under which it should run with an additional -u nobody

Installation of the PHP MemCache extension�

cd /files/download/

wget http://pecl.php.net/get/memcache-2.1.2.tgz

tar -xvf memcache-2.1.2.tgz

cd memcache-2.1.2

phpize
&& ./configure –enable-memcache && make

Copy the memcache.so to the default module
directory.

vi /etc/php.ini

add

extension=memcache.so

/etc/init.d/httpd restart

If you check you phpinfo() you should a memcache section appear.

You can now fully use the Memcache functionality in your PHP.

References

http://www.danga.com/memcached/

http://dk.php.net/manual/en/ref.memcache.php

Change system time

Centos, Linux 1 Comment »

I found out that a large part of centos servers were out of sync with the current time.

So I fixed them.

First get the current date and time from a time server:
rdate -s tick.uh.edu

Then type
/sbin/hwclock –systohc

This sets the system time as a ‘permanent’ clock so that the time will be correct next time you reboot.

You can also use NTP (Network Time protocol) but I haven’t looked into (yet).
The NTP uses a network of time server to automatically sync your system time with the time server on a regular base.

Centos 5 : Install PHP-MSSQL Module / Extension

Centos, Linux, PHP 24 Comments »

As you might have noticed since Centos 5.0, the PHP-MSSQL module / extension isn’t default available in the yum repository. So if you want to use it you can alter the PHP binairy or you can compile an mssql module / extension. In this howto I will explain how to compile the mssql module / extension.You need to activate the RPMForge custom repository (formely known as Dag Wieers)http://dag.wieers.com/rpm/packages/rpmforge-release/Grab your specific RPM and install it.

wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-*.rpmrpm –install rpmforge-release-*.rpm

Next step is to install freetds,freetds-devel, php-devel and the Development tools.

yum groupinstall ‘Development Tools’

yum install freetds freetds-devel –enablerepo=rpmforge
yum install php-devel

next we alter the php.spec file, containing the php configuration for compiling.

vi /usr/src/redhat/SPECS/php.spec

if you can’t find the php.spec file.

You can download the php src rpm.

wget centos.mirrors.skynet.be/pub/centos/5/os/SRPMS/php-5.1.6-5.el5.src.rpmand next

rpm –install php-5.1.6-5.el5.src.rpm

And then do an updatedb and locate php.spec.

edit the CFLAGS= line (~line 310) of the php.spec file – remove ” -Wno-pointer-sign”

add the following piece of code to it.

Group: Development/Languages
Requires: php = %{version}-%{release}, php-pdo
Summary: A module for PHP applications that use the MSSQL database.
provides: php_database
BuildRequires: freetds-devel

%description mssql
The MSSQL package contains a dynamic shared object that will add
support for accessing MSSQL databases to php

Start building your php rpm.

rpmbuild -bb ./php.spec

If has is asking for some dependancies just yum install them

cd /usr/src/redhat/BUILD/php-5.1.6/ext/mssql/

Now we are going to make the mssql module without having to rewrite the php binairy.

phpize
./configure –with-mssql
make
make install

Next look for the mssql.so and make sure it is in the module directory specified in your php.ini.
and copy it to the specified location if needed.

final step

vi /etc/php.ini

add this line to php.ini

extension=mssql.so

save php.ini and restart apache

/etc/init.d/httpd restart

éh voila you have just made your mssql module / extension without having to change anything to the base Centos 5 HTTPD / PHP setup.

PS: I have also posted this howto on http://www.howtoforge.com

Centos 5 : Local yum repository

Centos, Linux 10 Comments »

Sometimes it can be handy to setup your own repository to prevent from downloading the remote repository over and over again.

Create the Directories:

mkdir -pv /var/www/html/centos/{base,updates}

Copy the RPMs from the CDs/DVD to /var/www/html/centos/base

Create the base repository headers:

createrepo /var/www/html/centos/base

Select a rsync mirror for updates:
check out this list of aviable mirrors: Centos OS Mirror list and these are identified with “rsync.” For example: “rsync://ftp.belnet.be/packages/centos/”. The mirrors share a common structure for updates. Simply append /updates/<d version>/<base arch>.

Rsync to create the updates-released repository:

rsync -avrt rsync://ftp.belnet.be/packages/centos/5.0/updates/i386 \ –exclude=debug/ /var/www/html/centos/updates

This will create a complete update repository at /var/www/html/centos/updates/i386. The repodata directory will be created with all of the headers. Next I would advise to setup a cron job to run the rsync (above). In this manner your repository keep updated and only new updates and headers will be downloaded to your repository.

Edit yum.conf:

vi /etc/yum.repos.d/CentOS-Base.repo

[base] name=CentOS-$releasever – Base baseurl=http://192.168.*.*/centos/$releasever/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever – Updates baseurl=http://192.168.*.*/centos/$releasever/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

That’s it. Special thanks to http://www.tqmcube.com for the info

Virtual Users With Postfix, PostfixAdmin, Courier, Mailscanner, ClamAV On CentOS

Centos, Linux 5 Comments »

A while ago I wrote an extensive ‘how to’ on installing Postfix, PostfixAmdin, Courier, Mailscanner, ClamAv on a Centos (redhat like) Linux OS. I tried to make the howto as complete as possible. I noticed how hard it was to find a good howto on setting up a mail server with a nice web interface, on a Centos OS. So after some testing and experimenting I decided to write my own howto.

I posted the whole howto on howtoforge.com.
http://www.howtoforge.com/virtual_users_postfix_courier_mailscanner_clamav_centos

PDF format: Virtual Users With Postfix, PostfixAdmin, Courier, Mailscanner, ClamAV On CentOS

Howtoforge.com is a website with the best howto’s on the internet,I find it an honor to finally contribute my little piece back to this large community.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in