Linux

centos install memcached and memcache php module

Thursday, October 27th, 2011 | Linux | Comments Off

1. yum install memcached
2a. wget http://pecl.php.net/get/memcache-3.0.6.tgz
2b. tar -xvf memcache-3.0.6.tgz

here is a little storry, we need to use phpize to prepare the imagick php extension for compiling.
On my server I have multiple php installations and if I use phpize directly it will compile the extension for a wrong version of php. Even if I try using phpize with an absolute path the end result will still be wrong and I’ll get the following errors inside my apache error log:
“PHP Warning: PHP Startup: imagick: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20090626
These options need to match”

so keeping the story short I backup/rename (temporary) the default php include directory:
3. rename /usr/local/include/php to /usr/local/include/_php (in my case)
I create a symlink inside /usr/local/include/ called php that points to the php include version I whish to compile the imagemagick extension, in this case it will point to /usr/local/php-5.3.2-fcgi/include/php

4. now I continue with:
/usr/local/php-5.3.2-fcgi/bin/phpize

5. I configure with the right php-config file:
./configure –with-php-config=/usr/local/php-5.3.2-fcgi/bin/php-config

6. and the usual
make
make install

7. now check where the imagick.so file was copied to and include it in your php.ini:
extension=/usr/…/extensions/memcache.so

8. start memcache server
memcached -d -u nobody -m 1048 -p 11211 127.0.0.1

9. restart apache
/etc/init.d/httpd restart

php compile: undefined reference to `xmlXPathContextSetCache’

Monday, August 22nd, 2011 | Linux | Comments Off

I am doing some tests to prepare a new version of PHP on which I needed the xsl library. Everything was going ok after the ./configure command (I added -with-xsl=/usr/lib64 as one of the configure options).

I mention that I am using centos 5.3 as OS.

When I tried to execute the make command I got the following error:
“undefined reference to `xmlXPathContextSetCache’” and unfortunately didn’t found an answer on google that will solve my question.

After some trial & error I noticed that inside /usr/lib64 folder I had a symlink called libxml2.so that pointed to libxml2.so.2.6.23. I also had the file libxml2.so.2.6.26.

All I did is to change the symlink to point to the newer version of libxml2. In conclusion the problem seems to be in the libxml2 versions prior to 2.6.26 (2.6.25 and bellow)

Configure: error: Cannot find libmysqlclient under /usr/local

Wednesday, July 27th, 2011 | Linux | Comments Off

The fix is pretty simple, run the following commands and afterwards reenter your previous ./configure command
ln -s /usr/lib64/libmysqlclient.so /usr/lib/libmysqlclient.so
ln -s /usr/lib64/libmysqlclient.so /usr/local/libmysqlclient.so

install percona in a whm cpanel environment

Wednesday, June 22nd, 2011 | Linux | Comments Off

1. stop all services
/etc/init.d/httpd stop ; /etc/init.d/exim stop ; /etc/init.d/pure-ftpd stop ; /etc/init.d/dovecot stop ; /etc/init.d/cpanel stop ; /etc/init.d/lfd stop ; /etc/init.d/munin-node stop ; /etc/init.d/crond stop ; /etc/init.d/mysql stop ; /etc/init.d/exim stop ; /etc/init.d/portsentry stop

2. uninstall mysql, the database files are not removed, but feel free to backup them if you want
check the installed mysql packages
yum list installed | grep -i mysql
and now unsinstall them one by one, in my case:
yum remove MySQL-test.x86_64
yum remove MySQL-shared.x86_64
yum remove MySQL-server.x86_64
yum remove MySQL-devel.x86_64
yum remove MySQL-client.x86_64

3. install yum repository for percona
rpm -Uhv http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm

4. install percona yum install Percona-Server-client-51 Percona-Server-server-51
LATER UPDATE!!!!
please install the separate rpm from this because later you’ll run into all sort of dependency problems on centos5:

http://www.percona.com/downloads/Percona-Server-5.1/Percona-XtraDB-5.1.43-9.1/RPM/rhel5/x86_64/

you need to use rpm -ivh ~package_name.rpm~

5. now go to whm configuration section and set up mysql not to be updated automatically

6. you may need to recompile php, I needed to do it anyway so I am not sure if it wil work if you won’t compile it

7. start services again
/etc/init.d/httpd start ; /etc/init.d/exim start ; /etc/init.d/pure-ftpd start ; /etc/init.d/dovecot start ; /etc/init.d/cpanel start ; /etc/init.d/lfd start ; /etc/init.d/munin-node start ; /etc/init.d/crond start ; /etc/init.d/mysql start ; /etc/init.d/exim start ; /etc/init.d/portsentry start

8. optionally install percona xbackup
yum install xtrabackup

install imagick for php

Wednesday, June 8th, 2011 | Linux | Comments Off

I’ll describe the installation process for Centos as this is my server’s operating system, the installation is very similar for any linux flavour.

In order to have imagick class available inside php firstly we need to install ImageMagick-devel:
1. yum install ImageMagick-devel

then, download & extract the imagick pecl package:
2.a. cd ~
2.b. wget http://pecl.php.net/get/imagick-3.0.1.tgz
2.c. tar -xvf imagick-3.0.1.tgz
2.d cd imagick-3.0.1.tgz

here is a little storry, we need to use phpize to prepare the imagick php extension for compiling.
On my server I have multiple php installations and if I use phpize directly it will compile the extension for a wrong version of php. Even if I try using phpize with an absolute path the end result will still be wrong and I’ll get the following errors inside my apache error log:
“PHP Warning: PHP Startup: imagick: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20090626
These options need to match”

so keeping the story short I backup/rename (temporary) the default php include directory:
3. rename /usr/local/include/php to /usr/local/include/_php (in my case)
I create a symlink inside /usr/local/include/ called php that points to the php include version I whish to compile the imagemagick extension, in this case it will point to /usr/local/php-5.3.2-fcgi/include/php

4. now I continue with:
/usr/local/php-5.3.2-fcgi/bin/phpize

5. I configure with the right php-config file:
./configure –with-php-config=/usr/local/php-5.3.2-fcgi/bin/php-config

6. and the usual
make
make install

7. now check where the imagick.so file was copied to and include it in your php.ini:
extension=/usr/…/extensions/no-debug-non-zts-20090626/imagick.so

install apc for php

Wednesday, May 4th, 2011 | Linux | Comments Off

cd to where you dearchived the sourcecode files for apc
export PHP_PREFIX=”/opt/php”, where /opt/php is where you have php installed
$PHP_PREFIX/bin/phpize
./configure –with-php-config=$PHP_PREFIX/bin/php-config
make
make install

add in php.ini the reference to the new extension that was copied inside extension folder
restart apacje

Linux track cpu usage per user

Saturday, March 26th, 2011 | Linux | Comments Off

Quick info how to setup everything so you’ll be able to check the cpu user per each user.
As a note I have the PHP set up in fcgid mode and also suexec so each php process is running under the proper username.

The solution I found is to install munin – this can be installed from 1. shell 2. whm

1. from shell it’s as simple as:
1.a. sudo yum -y install munin
1.b. sudo yum -y install munin-node

if you run into dependencies problem make sure to check what you have in the global exclude list (I had ruby and perl packages excluded). Also set up the proper repositories:

sudo vi /etc/yum.repos.d/dag.repo

and inside the file place:

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1
sudo  vi /etc/yum.repos.d/rubyworks.repo

and inside the file place:

# Link file for RubyWorks yum repository
# Place this file in /etc/yum.repos.d
 
[rubyworks]
name=RubyWorks
baseurl=http://rubyworks.rubyforge.org/redhat/$releasever/RPMS/$basearch
enabled=1
gpgcheck=1
gpgkey=http://rubyworks.rubyforge.org/RubyWorks.GPG.key
priority=1

2. if you have cpanel installed, from whm is a lot simpler:
2.a go to plugins and install munin from there
2.b go to whm home->plugins->Munin Service Monitor and there you have all the graphs

Latest steps is to install this plugin: http://exchange.munin-monitoring.org/plugins/cpubyuser/details
and restart the munin-node:

sudo /etc/init.d/munin-node restart

Solving: mod_fcgid: read data timeout

Saturday, October 23rd, 2010 | Linux | Comments Off

This is starting to be a more and more common problem because the hosting companies are using fcgid more often (which is a great thing as fcgid and suexec combination has a lot of advantages).

solving the read data timeout for mod fcgid is not as hard as it seems it just required some testing: in http.conf – the configuration file for apache or in a file that’s included in http.conf place the following line:

IPCCommTimeout 120 or any number of seconds you find suitable for your server.

error removing addon domain from cpanel

Friday, October 22nd, 2010 | Linux | Comments Off

Recently I was unable to remove a domain from cpanel after firstly I deleted the dns zone for that domain (using whm)

The error was: “There was a problem removing the Addon Domain” and details of the error explained: “Error from park wrapper: Sorry, you do not control the domain exampledomain.com”

I used the following steps to remove the domain:

1. Remove domain.com from /var/cpanel/users/username
2. Run /scripts/updateuserdomains as root user on the server.
3. Remove /var/named/exampledomain.com.db
4. Remove the virtualhost for domain.com on /usr/local/apache/conf/httpd.conf
5. Remove exampledomain.com from /etc/named.conf

Simple as that!

Centos add additional repositories

Tuesday, October 12th, 2010 | Linux | Comments Off

yum install yum-priorities
edit all .repo files from /etc/yum.repos.d/ and add bellow:
[base], [addons], [updates], [extras], [centosplus]
priority=1

bellow [contrib]
priority=2

download RPMforge and check the file
rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.1-1.el5.rf.*.rpm

install and check the installation
rpm -i rpmforge-release-0.5.1-1.el5.rf.*.rpm
yum check-update

done