Tag Archives: php

Installing the PHP HandlerSocket Client

18 Dec

Download and Extract HandlerSocket Source Code

  • NOTE: If you are in a development environment where the Server-Side MySQL HandlerSocket service and the Apache/PHP service are in the
    same box, then you can skip this step.

Compile and Build HandlerSocket Client Code

  • cd /opt/mysqlcluster/src/handler_src
  • ./autogen.sh
  • ./configure –disable-handlersocket-server
  • make && make install

Install/Setup PHP HandlerSocket Client

  1. mkdir -p /opt/php_hs
  2. cd /opt/php_hs
  3. wget http://php-handlersocket.googlecode.com/files/php-handlersocket-0.3.0.tar.gz
  4. tar xvf php-handlersocket-0.3.0.tar.gz
  5. cd cd php-handlersocket
  6. Ensure the phpize command from /usr/bin is executed.
    1. export PATH=/usr/bin:$PATH
  7. make clean (If this is your first time building PHP HandlerSocket, this command will fail and that is ok)
  8. phpize
  9. ./configure
  10. make
  11. make install
    • This will copy handlersocket.so to /usr/lib64/php/modules on 64 bit OS (production systems)
    • Will copy handlersocket.so /usr/lib/php/modules on 32 bit OS (Dev systems)
  12. Specify handlersocket.so as a PHP extension
    1. echo “extension=handlersocket.so” > /etc/php.d/handlersocket.ini
  13. Restart Apache
    1. service httpd restart

Setup Sample Database

  • Setup a test database and innodb table:
    • mysql -h 127.0.0.1 -u myuser -p OR mysql -h 127.0.0.1 -u root depending on your environment.
    • mysql> create database hstestdb;
    • mysql> CREATE TABLE user (user_id INT UNSIGNED PRIMARY KEY,user_name VARCHAR(50),user_email VARCHAR(255),created Timestamp DEFAULT CURRENT_TIMESTAMP) ENGINE=InnoDB;
    • mysql> insert into user values (101, “Hulk Hogan”, “hulk@hogan.com”, current_timestamp());
    • mysql> insert into user values (102, “The Rock”, “the@rock.com”, current_timestamp());
    • mysql> SELECT user_name, user_email, created FROM user WHERE user_id=101;

Sample PHP Code to access the above Database/Table using HandlerSocket API:

Client API

SELECT example

$host = 'ec2-50-17-110-253.compute-1.amazonaws.com';
$port = 9998;
$port_wr = 9999;
$dbname = 'hstestdb';
$table = 'user';

// SELECT SINGLE AND SELECT MULTI $hs = new \HandlerSocket($host, $port);
if (!($hs->openIndex(1, $dbname, $table, \HandlerSocket::PRIMARY, 'user_name,user_email,created')))
{

    echo $hs->getError(), PHP_EOL; die();
}

$retval = $hs->executeSingle(1, '=', array('101'), 1, 0);

var_dump($retval);

$retval = $hs->executeMulti(
    array(array(1, '=', array('101'), 1, 0),
          array(1, '=', array('102'), 1, 0)));

var_dump($retval);

unset($hs);

UPDATE Example

$host = 'ec2-50-17-110-253.compute-1.amazonaws.com';
$port = 9998;
$port_wr = 9999;
$dbname = 'hstestdb';
$table = 'user';
// UPDATE $hs = new \HandlerSocket($host, $port_wr);
if (!($hs->openIndex(2, $dbname, $table, '', 'user_name')))
{
    echo $hs->getError(), PHP_EOL;
    die();
}

if ($hs->executeUpdate(2, '=', array('101'), array('Hulkier Hogan'), 1, 0) === false)
{
    echo $hs->getError(), PHP_EOL;
    die();
}

unset($hs);

INSERT EXAMPLE

$host = 'ec2-50-17-110-253.compute-1.amazonaws.com';
$port = 9998;
$port_wr = 9999;
$dbname = 'hstestdb';
$table = 'user';
// INSERT $hs = new \HandlerSocket($host, $port_wr);
if (!($hs->openIndex(3, $dbname, $table, '', 'user_id,user_name,user_email')))
{
    echo $hs->getError(), PHP_EOL;
    die();
}

if ($hs->executeInsert(3, array(103,'Mr. Perfect', 'mr@perfect.com')) === false)
{
    echo $hs->getError(), PHP_EOL;
}

unset($hs);

exit;

DELETE EXAMPLE

$host = 'ec2-50-17-110-253.compute-1.amazonaws.com';
$port = 9998;
$port_wr = 9999;
$dbname = 'hstestdb';
$table = 'user';
//DELETE $hs = new \HandlerSocket($host, $port_wr);
if (!($hs->openIndex(4, $dbname, $table, '', '')))
{
    echo $hs->getError(), PHP_EOL;
    die();
}

if ($hs->executeDelete(4, '=', array(103)) === false)
{
    echo $hs->getError(), PHP_EOL;
    die();
}

References

Advertisements

Installing PHPRedis

6 Aug

Compile and Build PHPRedis

  1. mkdir -p /opt/redis/php
  2. cd /opt/redis/php
  3. wget –no-check-certificate https://github.com/nicolasff/phpredis/zipball/master
  4. unzip nicolasff-phpredis-2.1.2-4-g765b9a7.zip
  5. cd nicolasff*/
  6. Ensure the phpize command from /usr/bin is executed.
    1. PATH=/usr/bin:$PATH; export PATH
  7. make clean (If this is your first time building PHPRedis, this command will fail and that is ok)
  8. phpize
  9. ./configure
  10. make
  11. make install
    • This Will copy redis.so to /usr/lib64/php/modules on 64 bit OS (production systems)
    • Will copy redis.so /usr/lib/php/modules on 32 bit OS (Dev systems)
  12. Specify redis.so as a PHP extension
    1. echo “extension=redis.so” > /etc/php.d/phpredis.ini
  13. Restart Apache
    1. service httpd restart

Reference

  1. The API is available here https://github.com/nicolasff/phpredis#readme.

Xhprof for profiling PHP applications

1 Mar

We wrote extensions to Xhprof so we could do aggregate/production grade profiling. To enable this capability we use Redis as the data store for profiling data.

Installing Xhprof for profiling PHP applications

This step is optional and only required if you are planning on doing PHP profiling using Xhprof.

Xhprof is a lightweight profiling library developed at Facebook. It can be used to profile applications in production as well.

  1. Prereq
    1. Requires php-devel package
  2. To install Xhprof
    1. mkdir -p /opt/xhprof
    2. cd /opt/xhprof
    3. pecl d xhprof-0.9.2
    4. tar xzf xhprof-0.9.2.tgz
    5. cd xhprof-0.9.2/extension/
    6. phpize
    7. ./configure –with-php-config=/usr/bin/php-config
    8. make
    9. make test
    10. make install
  3. Add xhprof as extension to /etc/php.d/xhprof.ini

    /etc/php.d/xhprof.ini

    extension=xhprof.so
    ;
    ; directory used by default implementation of the iXHProfRuns
    ; interface (namely, the XHProfRuns_Default class) for storing
    ; XHProf runs.
    ;
    xhprof.output_dir=/tmp
  4. Xhprof has a dependency on Graphviz to generate the call graphs
    1. cd /etc/yum.repos.d/
    2. wget http://www.graphviz.org/graphviz-rhel.repo
    3. yum install graphviz.x86_64
  5. To install the Xhprof UI
    1. cd /var/www/html
    2. ln -s /opt/xhprof/xhprof-0.9.2/xhprof_html .
  6. Install a Redis Server
    1. If you don’t already have a Redis Server setup follow instructions at http://stansantiago.blogspot.com/search/label/redis to create a Redis Server and PHP Redis Client.

Redis Based Xhprof Extension

  1. The files referred to in this section are available as attachments to this wiki page. Please download
    and install at the specified locations.
  2. To support production grade profiling the following wrapper scripts have been written:
    1. XhprofWrapper.php: specified before and after the part of the code to be profiled
    2. XhprofAgg.php: This is a standalone PHP script that aggregates the profiling of a multi-user test
    3. XhprofTest.php: A standalone PHP script that can be used to test connectivity to Redis
    4. xhprof_runs.php: I’ve created a new class that has logic to read/save profiling data to a Redis instance.

Installing the Custom Extension

  1. Copy XhprofTest.php and XhprofAgg.php to /opt/xhprof
  2. Copy XhprofWrapper.php to a directory accessible by your PHP codebase.
  3. Backup the existing xhprof_runs.php
    1. cd /opt/xhprof/xhprof-0.9.2/xhprof_lib/utils
    2. cp xhprof_runs.php xhprof_runs.php.orig
    3. Append the contents of the attached xhprof_runs.php to the /opt/xhprof/xhprof-0.9.2/xhprof_lib/utils/xhprof_runs.php file.

Enabling Profiling

  1. To enable profiling we will add the XhprofWrapper code so it executes before the location you want to start profiling.
  2. Insert the XhprofWrapper preRequest() and postRequest() methods around the code that needs to be profiled:require_once ‘XhprofWrapper.php’;
    \XhprofWrapper::preRequest();
    <CODE TO BE PROFILED>
    \XhprofWrapper::postRequest();
    return; 

    …* Modify the 3 main PHP entry pages (index.php, callgraph.php, typeahead.php) in the ” /opt/xhprof/xhprof-0.9.2/xhprof_html/” directory to use the new class instead of the default class XHProfRuns_Default. Change this line in the 3 files:
    $xhprof_runs_impl = new XHProfRuns_Default();* Ensure xhprof_html is accessible via Rewrite rules.Developer profiling: How to test a single request
  1. Print out/echo the runId returned by XhprofWrapper::postRequest()
    1. Replace <runId> in the URL below with this runId.
  2. Access http://<hostname>/xhprof_html/?run=<runId>&source=devprofile

Aggregate profiling: How to load test and generate an aggregate profile report

  1. Log into Redis Server machine:
    1. cd /opt/redis/latest/src
    2. ./redis-cli -h <hostname> -p <port number>
    3. “DEL runIds” will delete any existing runIds
  2. Run the load test
  3. Edit /opt/xhprof/XhprofAgg.php and set a Unique Aggregate run id; ALL, ALL2, ALL3 etc
  4. /usr/bin/php -f XhprofAgg.php to create Aggregate report
  5. Access http://<hostname>/xhprof_html/?run=ALL&source=aggregate to access the aggregate report.
  6. Repeat steps 2-6 for difference test scenarios if required

TODO

References

  • For more information see Xhprof.

GeoIP PHP extension

12 Feb

Install GeoIP PHP Extension

Install GeoIP C API

Install the PHP extension

  • Install the PHP extension using the PECL repository
    • pecl install geoip
  • Configure php.ini
    • echo “extension=geoip.so” > /etc/php.d/geoip.ini
  • Restart Apache
    • service httpd restart

Install GeoIP Lite Database

  • Downlad the Binary version of the GeoLite City Database from http://www.maxmind.com/app/geolitecity
  • Extract the contents of the distribution
    • gunzip GeoLiteCity.dat.gz
  • Move the dat file to Linux standard shareable location
    • mkdir -p /usr/local/share/GeoIP
    • mv GeoLiteCity.dat /usr/local/share/GeoIP/GeoIPCity.dat

      {info:title=Make Note}

      • In the copy/move step above ensure that you copy to is named GeoIPCity.dat, otherwise the APIs will not find it.

      {info}

       

Test the API

  • In your PHP code embed the following code:
$infos = geoip_db_get_all_info();
if (is_array($infos)) {
    echo '<pre>' . print_r($infos,TRUE) . '</pre>';
}

API reference

References

Ruckusing PHP DB Migrations Framework

10 Feb

Introduction

  • Ruckusing is a framework written in PHP5 for generating and managing a set of “database migrations”. Database migrations are declarative files which represent the state of a DB (its tables, columns, indexes, etc) at a particular state of time. By using database migrations, multiple developers can work on the same application and be guaranteed that the application is in a consistent state across all remote developer machines.

Setting up the Ruckusing PHP Framework

  • Ensure that the PHP CLI (usually in /usr/bin/php) is your PATH environment variable.
  • Ensure that the php executable has been built with support for Postgres and/or MySQL
  • If you have open_basedir in effect in your php.ini file (usually /etc/php.ini), edit and add an open_basedir entry for the folder that contains the ruckusing framework.
  • Set the date.timezone configuration parameter in /etc/php.ini as follows. This is required for the Timestamp based migrations to work correctly.
    date.timezone =  'America/New_York'

     

Configure Database Connectivity

  • Edit config/database.inc.php and enter DB details.
  • This should match the $configName entry in Service_Request/Config.php For example:
<?php
//---------------------------- // DATABASE CONFIGURATION // 'development' is default and required by ruckusing // 'sun' (Sunrise), 'tmk' (Terremark), 'vmw' (VMWare CentOS), 'win' (Windows XAMPP) //---------------------------- $ruckusing_db_config = array(

    'development' => array(
        'type'      => 'mysql',
        'host'      => 'localhost',
        'port'      => 3306,
        'database'  => 'item_1_1_1_m',
        'user'      => 'root',
        'password'  => 'XXXXXXXXX'
    ),
    'sun' => array(
 'type'    => 'mysql',
 'host'    => '10.16.35.213',
 'port'   => 3306,
 'database'  => 'item_1_1_1_m'',
 'user'    => 'root',
 'password'  => 'XXXXXXXX'
    )
);

?>

Initialize Database Migration

  • This task will create a schema_migrations table in your DB with a single column version which is used to keep track of the current version of your DB.
  • Ensure you are in the top level directory of the Ruckusing Framework and execute”
    • /usr/bin/php main.php db:setup

Test Current Version of Database Migration

  • This task will check the schema_migrations table in your DB and return the value of the “version” column
  • /usr/bin/php main.php db:version

Create a Migration Template – CREATE A TABLE

  • Let’s assume that we want to add a table for some new functionality to support blogging. For example, we want to create a table called posts.
  • Execute the following command:
    • /usr/bin/php generate.php create_posts_table
  • The previous command will create a PHP file under db/migrate/<timestamp>_CreatePostsTable.php

Edit the Migration Template File

  • Open the <timestamp>_CreatePostsTable.php in your favorite editor.
  • Note the empty up() and down() methods
    • The up() method contains the set of actions for migrations that have NOT been executed against your copy of the database yet and that are based in increasing timestamped order.
    • The down() method is used for rollback/UNDO of migration actions
      class CreatePostsTable extends Ruckusing_BaseMigration {
      
       public function up() {
      
                    $t = $this->create_table("posts", array("id" => false));
                    $t->column("post_id", "integer", array("null" => false, "primary_key" => true));
                    $t->column("subject", "string");
                    $t->column("body", "string");
                    $t->column("created_at", "datetime", array('null' => false, "primary_key" => true));
                    $t->column("author_id", "integer");
                    $t->finish();
                    $this->add_index("posts", "author_id");
      
       }//up() 
       public function down() {
                    $this->drop_table("posts");
       }//down() 

       

  • To see a list of column datatype mappings see https://github.com/ruckus/ruckusing-migrations/wiki/Adding-Columns
  • To see a list of Migration APIs you can use in the up()/down() methods see https://github.com/ruckus/ruckusing-migrations/wiki/Migration-Methods

Run the Migrations to create the new table

  • /usr/bin/php main.php db:migrate

Verify the current DB migration version

  • /usr/bin/php main.php db:version

Create a Migration Template – ADD A COLUMN

  • Execute the following command:
    • /usr/bin/php generate.php add_deleted_at_column_to_posts_table
  • The previous command will create a PHP file under db/migrate/<timestamp>_AddDeletedAtColumnToPostsTable.php

Edit the Migration Template File

  • Open the <timestamp>_AddDeletedAtColumnToPostsTable.php in your favorite editor and edit it as follows:
class CreatePostsTable extends Ruckusing_BaseMigration {

      public function up() {
                  $this->add_column("posts", "deleted_at", "datetime");
      }//up() 
      public function down() {
           $this->remove_column("posts", "deleted_at");
      }//down()

Run the Migrations to add the new column

  • /usr/bin/php main.php db:migrate

Verify the current DB migration version

  • /usr/bin/php main.php db:version

Undo/Rollback to a previous Migration version

  • If for example, the current version of the DB is 20101006114707 and we want to go down to 20100921114643:
    • /usr/bin/php main.php db:migrate VERSION=20100921114643

References

Installing NGINX and PHP-FPM on CentOS

20 Dec

We wanted to run some benchmarks comparing Apache/Mod_PHP and NGINX/PHP-FPM. Here are the steps I followed to install NGINX/PHP-FPM on our CentOS servers.

Configure Additional Yum Repositories

  • If you haven’t already added the EPEL and REMI repositories execute the following steps:
  1. Install the EPEL YUM Repository
  2. Install the REMI Yum Repository
  3. For more information see EPEL and REMI

NGINX installation

  1. yum install nginx

Install PHP packages

  1. Follow the steps specific to PHP installation at https://stansantiago.wordpress.com/2010/06/10/installing-apache-mysql-php-and-memcached-on-centos/

Install PHP-FPM

  1. yum –enablerepo=remi install php-fpm
  1. To upgrade to the latest PHP/PHP-FPM packages: yum –enablerepo=remi upgrade

Enable the NGINX and PHP-FPM as CentOS services

  1. chkconfig nginx on
  2. chkconfig php-fpm on

NGINX and PHP configuration changes

nginx.conf changes

  • Add the following fastcgi settings in the location for php section in the nginx.conf file:

    nginx.conf

    ...
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            location ~ \.php$ {
                root /usr/share/nginx/html;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  SCRIPT_FILENAME  $fastcgi_script_name;
                fastcgi_intercept_errors off;
                include        fastcgi_params;
            }
    
    ...

php.ini changes

  • Set log_error On in php.ini to enable php error logging.
    • The error output will be written to /var/log/httpd/error_log

NGINX Troubleshooting

  • If you see an error in the log file related to eventfd() and you are unable to access a web page, you will
    have to build NGINX from source
    • Install pre-reqs
      • yum install libaio libaio-devel
    • Download latest version of PCRE from http://www.pcre.org/ and extract under /opt/pcre
    • Download latest version of NGINX from http://nginx.org/en/download.html under /opt/nginx
    • Build nginx
      • cd /opt/nginx/nginx-XX
      • ./configure –with-pcre=/opt/pcre/pcre-XX
      • make
      • make install
  • The nginx scripts and config files are installed under /usr/local/nginx
  • If you already have installed NGINX using the yum method you can update /etc/init.d/nginx to point to the nginx executable
    and configuration under /usr/local/nginx

Important file2 and directory locations after installation

NGINX

  • /etc/nginx/nginx.conf (NGINX Configuration file)
  • /usr/share/nginx/html (NGINX Document Root)
  • /var/log/nginx/* (NGINX Log Files)

PHP-FPM

  • /etc/php-fpm.conf
  • /etc/php-fpm.d/www.conf

PHP

  • /etc/php.ini (Php INI file)

Start/Stop Scripts

  1. NGINX
    1. service nginx stop
    2. service nginx start
    3. service nginx restart
  2. PHP-FPM (Used with NGINX)
    1. service php-fpm stop
    2. service php-fpm start
    3. service php-fpm restart

References

  1. PHP-FPM configuration
  2. PHP-FPM vs FastCGI comparison
  3. http://www.cyberciti.biz/faq/rhel-fedora-install-configure-nginx-php5/
  4. http://vladgh.com/blog/install-nginx-and-php-533-php-fpm-mysql-and-apc

Installing Apache, MySQL, PHP and Memcached on CentOS

10 Jun

Introduction

This page covers installation and configuration of Apache, MySQL, PHP and Memcached.

Configure Additional Yum Repositories

  1. Install the EPEL YUM Repository
  1. Install the REMI Yum Repository
  2. For more information see EPEL and REMI

MySQL installation

Install MySQL packages

    1. yum –enablerepo=remi install mysql-server mysql mysql-devel
    2. chkconfig mysqld on (enables /etc/init.d/mysqld to run at startup)
    3. /etc/init.d/mysqld start OR service mysqld start

Setup MYSQL users:

    1. Setup a user/password for localhost. Replace ‘XXXXX’ with password.
      1. /usr/bin/mysqladmin -u root password ‘XXXXX’
    2. Setup remote users. Replace ‘XXXXX’ with password

      Setup Localhost user

      #mysql -p
      Enter password:
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 6
      Server version: 5.0.77 Source distribution
      
      Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
      
      mysql>
      mysql>
      mysql> CREATE USER 'root'@'10.16.35.211' IDENTIFIED BY 'XXXXX';
      Query OK, 0 rows affected (0.00 sec)
      
      mysql> CREATE USER 'root'@'10.16.35.212' IDENTIFIED BY 'XXXXX';
      Query OK, 0 rows affected (0.00 sec)
      
      mysql> GRANT ALL PRIVILEGES ON * . * TO 'root'@'10.16.35.211' IDENTIFIED BY 'XXXXX' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
      Query OK, 0 rows affected (0.01 sec)
      
      mysql> GRANT ALL PRIVILEGES ON * . * TO 'root'@'10.16.35.211' IDENTIFIED BY 'XXXXX' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
      Query OK, 0 rows affected (0.00 sec)
      
      mysql> GRANT ALL PRIVILEGES ON * . * TO 'root'@'10.16.35.212' IDENTIFIED BY 'XXXXX' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
      Query OK, 0 rows affected (0.00 sec)

Memcached (server-side) installation

Install Memcached packages

    1. yum install libevent
    2. yum install memcached
    3. chkconfig memcached on (enables /etc/init.d/memcached to run at startup)

To start Memcached

  1. Add memcached startup options to /etc/sysconfig/memcached

    /etc/sysconfig/memcached

    PORT="11211"
    USER="root"
    MAXCONN="1024"
    CACHESIZE="2048"
    OPTIONS=""
    1. To start memcached:
      1. /etc/init.d/memcached start OR service memcached on
    2. Listens on port 11211 with memory size of 2GG

Apache Installation

  • yum install httpd
  • chkconfig httpd on (enables /etc/init.d/httpd to run at startup)
  • /etc/init.d/httpd start OR service httpd start

PHP Installation

The following PHP packages will be installed:

  • php
  • mysql (Mysql CLI)
  • php-mysql
  • php-bcmath
  • php-xml
  • APC
    • php-pear
    • php-devel
    • httpd-devel
  • Memcache (client side)
    • zlib-devel (this is a prerequisite for the pecl memcache client library)

Install the PHP packages

Install all packages except APC.
  1. yum –enablerepo=remi install php mysql php-mysql php-bcmath php-xml
  1. To upgrade to the latest PHP/PHP-FPM packages: yum –enablerepo=remi upgrade
Install APC support.
  1. yum –enablerepo=remi install php-pear php-devel httpd-devel
  2. pear install pecl/apc-beta
  3. echo “extension=apc.so” > /etc/php.d/apc.ini
Install Memcache (client side) support.
  1. yum install zlib-devel
  2. pear install pecl/memcache
  3. echo “extension=memcache.so” > /etc/php.d/memcache.ini
Install Memcached (client-side) support.
  1. These three packages are required for the next step to build the libmemcached source code:
    1. yum install libevent memcached gcc-c++
  2. Download the latest version from http://libmemcached.org:
    1. mkdir /opt/libmemcached
    2. cd /opt/libmemcached
    3. wget http://launchpad.net/libmemcached/1.0/0.42/+download/libmemcached-0.42.tar.gz
    4. tar xvfz libmemcached-0.42.tar.gz
    5. cd libmemcached-0.42
    6. ./configure
    7. make
    8. make install (installs the libmemcached files to /usr/local)
  3. Next install the pecl/memcached client
    1. yum install zlib-devel (not required if you already installed it as part of memcache (client-side) support)
    2. pear install pecl/memcached
    3. echo “extension=memcached.so” > /etc/php.d/memcached.ini
Install PCRE
  1. yum install pcre pcre-devel
Compile and Install Bstrlib
  1. Download and extract the bstrlib source code from http://bstring.sourceforge.net/
  2. After extracting run the following commands to compile and install the package
    1. gcc -c -fPIC -O3 bstrlib.c -o bstrlib.o
      1. Note: -fPIC is required for 64bit systems. Optional otherwise.
    2. ar rcs libbstrlib.a bstrlib.o
    3. cp libbstrlib.a /usr/lib

Installing rpc.rstatd for remote performance monitoring

  1. yum install rusers-server
  2. chkconfig rstatd on
  3. /etc/init.d/rstatd start
  • We’ll be using HP LoadRunner for performance testing. rstatd is required by Loadrunner for Unix kernel performance metrics.
  • See http://www.pirzyk.org/?p=504 for more details on rstatd

Configuring SELinux on CentOS to enable Apache remote networking

This step is required otherwise PHP won’t be able to connect to a remote MySQL instance.

  • setsebool -P httpd_can_network_connect true