Page tree
Skip to end of metadata
Go to start of metadata

Profiling FreePBX is the process of finding where slowdowns in the code are. This walkthrough will guide you into installing a profiler for PHP locally on your system

CentOS 7.x

Install and setup PHP components

yum install -y php56w-pear php56w-devel php56w-mcrypt
pecl install xhprof-beta
echo "extension=xhprof.so" > /etc/php.d/xhprof.ini
pecl uninstall mongodb
pecl install mongodb-1.4.4
echo "extension=mongodb.so" > /etc/php.d/mongodb.ini
service httpd restart

Now Install the GUI into a web directory

cd /var/www/html/
wget https://github.com/perftools/xhgui/archive/0.9.0.tar.gz
tar vxzf 0.9.0.tar.gz
cd xhgui-0.9.0
php install.php
cp config/config.default.php config/config.php

Edit /var/www/html/xhgui-0.9.0/config/config.php, make sure this function returns true

return array(
    'profiler.enable' => function() {
        return true;
    }
);

Adding the following snippet of code to xhgui/external/header.php right before ignore_user_abort(true); call

if(!empty($data['profile'])) {
  foreach($data['profile'] as $key => $value) {
      $profile[strtr($key, ['.' => '_'])] = $value;
  }
  $data['profile'] = $profile;
} else {
  return;
}

Add line to top of /etc/freepbx.conf

require '/var/www/html/xhgui-0.9.0/external/header.php';

Browse to <webhost>/xhgui-0.9.0/webroot

CentOS 6.x

Install and setup PHP components

yum install -y php-pear php-devel php-mcrypt
yum groupinstall "Development Tools"
pecl install xhprof-beta
echo "extension=xhprof.so" > /etc/php.d/xhprof.ini
pecl install mongo-1.4.4
echo "extension=mongo.so" > /etc/php.d/mongo.ini
service httpd restart

Now Install the GUI into a web directory

cd /var/www/html/
wget https://github.com/perftools/xhgui/archive/v0.5.2.tar.gz
tar vxzf v0.5.2.tar.gz
cd xhgui-0.5.2
php install.php

Edit /var/www/html/xhgui-0.5.2/config/config.php, make sure this function returns true

return array(
    'profiler.enable' => function() {
        return true;
    }
);

To use in CLI commands simply do this:

php -dauto_prepend_file=/var/www/html/xhgui-0.9.0/external/header.php <script>

At this point you will be able to view the profiling stats in the gui. Note: this address structure is VERY INSECURE. 

http://<web>/xhgui/xhgui-0.5.2/webroot

For web commands applications you need include:

/var/www/html/xhgui/xhgui-0.5.2/external/header.php

For help setting up mongodb 2.6 on CentOS 6 see the following:

https://www.programering.com/a/MjNxYjMwATU.html

  • No labels