centos install memcached and memcache php module
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’
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)
debug which wordpress plugin is slower
Once I had a performance problem with wordpress website even if it run on a dedicated server.
I suspected that the problem is one of the plugins but I had at least 50 installed
.
In order to see who’s the slowest I opened wp-includes/plugin.php and temprary changed the do_action function to something like this:
function do_action($tag, $arg = '') { global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; if ( ! isset($wp_actions) ) $wp_actions = array(); if ( ! isset($wp_actions[$tag]) ) $wp_actions[$tag] = 1; else ++$wp_actions[$tag]; $wp_current_filter[] = $tag; // Do 'all' actions first if ( isset($wp_filter['all']) ) { $all_args = func_get_args(); _wp_call_all_hook($all_args); } if ( !isset($wp_filter[$tag]) ) { array_pop($wp_current_filter); return; } $args = array(); if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this) $args[] =& $arg[0]; else $args[] = $arg; for ( $a = 2; $a < func_num_args(); $a++ ) $args[] = func_get_arg($a); // Sort if ( !isset( $merged_filters[ $tag ] ) ) { ksort($wp_filter[$tag]); $merged_filters[ $tag ] = true; } reset( $wp_filter[ $tag ] ); do { foreach ( (array) current($wp_filter[$tag]) as $the_ ) { if ( !is_null($the_['function']) ) { if($tag=='init') $time_start = microtime(true); call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); if($tag=='init') { $time_end = microtime(true);$time = $time_end - $time_start; echo print_r($the_['function']).' ----- <b>'.$time."</b><br>\n"; } } } } while ( next($wp_filter[$tag]) !== false ); array_pop($wp_current_filter); }
after this you’ll be able to see what plugin is eating the most of your time (after each function call you’ll see execution time in bold)
It’s not a mature script just a quick snippet to have a starting point for someone who runs into the same problem.
debug sql inside cakephp model
$dbo = $this->getDatasource();
$dbo->fullDebug = true;
$this->find(‘all’, …
$logs = $dbo->_queriesLog;
$log = end($logs);
print_r($logs);exit;
Configure: error: Cannot find libmysqlclient under /usr/local
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
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
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
CSS transparent border hack, easy
Recently I wanted to have different elements surrounded by transparent borders.
For instance an ajax popup, similar with what facebook has, or a design element to look nicer.
The solution is having another div that is inside the one you already have with an opacity applyed to it.
The HTML:
<div class="normalDiv"> <div class="transparentBorder"> </div> our content here, </div>
The CSS:
.transparentBorder{border: 10px solid #363636; position: absolute; top: -10px; left: -10px; height: 100%; width: 100%; opacity: 0.34;filter:alpha(opacity=34); z-index: -10; } .normalDiv {position: relative; width: 500px; height: 300px; text-align: center; font-size: 13px; color; #363636;}
See the DEMO for transparent borders
install apc for php
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
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