Tuesday, December 6, 2011

PHP Accelerator for XAMPP on Linux

Since PHP 5.3 was released, it had been even harder to find stable accelerator to boost up the performance. Recently, I searched through the news and blogs about any breakthrough of PHP accelerator and found some good news. One of those package called APC has released new packages which claimed to fully support PHP 5.3. So far it has good responses among the users regarding stability and performance. Also, APC is going to be deployed as built-in accelerator in PHP 5.4 soon.

To install new package of APC from the scratch, we need something more installed on Linux platform:

Packages required:
Autoconf: Whatever version is fine.
XAMPP: Version from 1.7.2 to 1.7.7 should be okay.
XAMPP development source: This must be corresponding to the original version of XAMPP package.
APC: Latest APC package available for the best support.

To install Autoconf on Linux, like Ubuntu:
#
$sudo apt-get install autoconf


To install XAMPP:
Download and install XAMPP package from http://www.apachefriends.org/en/xampp-linux.html
#
$wget http://www.apachefriends.org/download.php?xampp-linux-1.7.7.tar.gz

$sudo tar xvfz xampp-linux-1.7.7.tar.gz -C /opt


Of course, you need to finish the basic setup and make sure Apache server and MySQL are running before you proceed to the following steps.

To install XAMPP development source:
Use the following link and modify version of XAMPP pacakge as required.
Here, assuming we have installed XAMPP 1.7.7 package:
#
$wget http://www.apachefriends.org/download.php?xampp-linux-devel-1.7.7.tar.gz




$sudo tar xvfz xampp-linux-devel-1.7.7.tar.gz -C /opt




To compile and install APC source:
#Download and extract source files

#
$wget -O APC-latest.tar.gz http://pecl.php.net/get/APC

$tar xvfz APC-latest.tar.gz

$cd APC-*


#run phpize while in APC source directory
#
$sudo /opt/lampp/bin/phpize

#Configure source with setting appropriate config path pointing to XAMPP php-config file
#
$sudo ./configure --with-php-config=/opt/lampp/bin/php-config

#Compile and install
#
$sudo make

$sudo make install


Now, add new line into php.ini and restart Apache server to initialize APC module:

#
$sudo sh -c "echo 'extension=apc.so' >> /opt/lampp/etc/php.ini"

$sudo /opt/lampp/lampp stopapache



$sudo /opt/lampp/lampp startapache


To check if APC is running, type the following command:
#
$sudo /opt/lampp/bin/php -r 'echo phpinfo();' | grep apc --color

And then you should see some related information about running APC module when things don't go wrong.





No comments:

Post a Comment