Cara menggunakan php accelerator install

This guide explains how to integrate eAccelerator into PHP5 on a CentOS 5.0 system. From the eAccelerator project page: "eAccelerator is a free open-source PHP accelerator, optimizer, and dynamic content cache. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times."

This document comes without warranty of any kind! I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I have tested this on a CentOS 5.0 server with the IP address 192.168.0.100 where Apache2 and PHP5 are already installed and working. I'll use Apache's default document root /var/www/html in this tutorial for demonstration purposes. Of course, you can use any other vhost as well, but you might have to adjust the path to the info.php file that I'm using in this tutorial.

 

2 Checking PHP5's Current State

First, before we install eAccelerator, let's find out about our PHP5 installation. To do this, we create the file info.php in our document root /var/www/html:

vi /var/www/html/info.php
<?php
phpinfo();
?>

Afterwards, we call that file in a browser: http://192.168.0.100/info.php

As you see, we have PHP 5.1.6 installed...

... but eAccelerator isn't mentioned anywhere on the page:

 

3 Installing eAccelerator

Unfortunately, there's no eAccelerator package for CentOS 5.0 in the official repositories, therefore we must compile and install it from the sources. Before we can do this, we need to install some prerequisites:

yum install php-devel
yum groupinstall 'Development Tools'

Now we can download and install eAccelerator like this (make sure that you get the latest version from the eAccelerator web site):

cd /tmp
wget http://bart.eaccelerator.net/source/0.9.5.2/eaccelerator-0.9.5.2.tar.bz2
tar xvfj eaccelerator-0.9.5.2.tar.bz2
cd eaccelerator-0.9.5.2
phpize
./configure
make
make install

eAccelerator is now installed. Now we have to tell our PHP installation that it should make use of eAccelerator. On CentOS 5.0, the configuration files for the various PHP 5 modules are stored in the /etc/php.d directory, and this directory is referenced in the main PHP5 configuration file /etc/php.ini, meaning all files in /etc/php.d are read in whenever Apache is started/restarted. So all we do is create the file /etc/php.d/eaccelerator.ini:

vi /etc/php.d/eaccelerator.ini
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/var/cache/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

(You can read up on the various configuration settings on this page: http://www.eaccelerator.net/wiki/Settings.)

As you see, we are using the disk cache directory /var/cache/eaccelerator which we must create now and make it world-writable:

mkdir -p /var/cache/eaccelerator
chmod 0777 /var/cache/eaccelerator

Afterwards, we restart Apache so that our new PHP configuration takes effect:

/etc/init.d/httpd restart

Afterwards, open info.php again in a browser: http://192.168.0.100/info.php

You should now see eAccelerator mentioned on the page which means it has successfully been integrated and is working as expected (I've marked the eAccelerator line in the below screenshot for better visibility):

Apa eAccelerator?
Ya, sebelum menuju langsung ke langkah-langkah instalasi, Anda harus tau terlebih dahulu tentang eAccelerator. Seperti namanya, itu accelerator untuk script PHP / file pada website Anda. Ini adalah perangkat lunak open source yang digunakan untuk meningkatkan kecepatan loading halaman PHP.
eAccelerator adalah akselerator PHP berasal dari ekstensi MMCache untuk bahasa pemrograman PHP. eAccelerator menyediakan cache bytecode. eAccelerator adalah open source dan dengan demikian bebas untuk menggunakan dan mendistribusikan. Versi dulu dan sekarang juga dilengkapi dengan encoder.
Setiap kali script PHP diakses, PHP biasanya mem-parsing dan mengkompilasi script untuk bytecode. Setelah terinstal, eAccelerator mengoptimalkan bytecode dikompilasi dan cache ini untuk memori bersama atau disk atau keduanya. Setelah berikutnya akses ke naskah, eAccelerator akan mengakses bytecode cache jika tersedia bukan script yang disusun. Hal ini untuk menghindari overhead kinerja parsing berulang dan kompilasi.
Jadi kita bisa menyimpulkan, eAccelerator membantu untuk meningkatkan kinerja dengan menggunakan kembali skrip PHP disusun dan mengoptimalkan mereka untuk mempercepat eksekusi mereka.

Pemasangan eAccelerator pada server cPanel menggunakan skrip phpextensionmgr
Langkah I: Login ke server sebagai root.
Langkah II: Jalankan script disisipkan di bawah:

/scripts/phpextensionmgr install EAccelerator

Perintah untuk Un-installation eAccelerator
/scripts/phpextensionmgr uninstall EAccelerator

Bagaimana / Perintah untuk memeriksa apakah eAccelerator diinstal atau tidak pada server cPanel?
Ini sangat sederhana untuk memeriksa apakah eAccelerator diinstal atau tidak pada server. Anda dapat menggunakan perintah "php -v" untuk memeriksa dari server Anda.
Lihat contoh di bawah ini:
root@angga [~]# php -v
PHP 5.4.26 (cli) (built: Mar 14 2014 02:39:49)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with eAccelerator v0.9.6.1-ea, Copyright (c) 2004-2012 eAccelerator, by eAccelerator

Metoda Alternatif
Instalasi eAccelerator dari kode sumbernya.
Metode ini sangat membantu untuk menginstal eAccelerator di server tanpa menggunakan cPanel. Anda dapat men-download versi terbaru dari SINI.
Silahkan ikuti langkah-langkah di bawah ini untuk menginstal eAccelerator dari file sumbernya.
wget http://downloads.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip
unzip eaccelerator-0.9.6.1.zip
cd eaccelerator-0.9.6.1
phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/bin/php-config
make
make install

Pastikan bahwa file eaccelerator.so tersedia pada direktori ekstensi setelah instalasi eAccelerator.
/usr/local/lib/php/extensions/no-debug-non-zts-20090626

Tambahkan baris berikut pada akhir php.ini

extension=”eaccelerator.so”

Restart Apache web-server.
service httpd restart

Semoga bermanfaat.

Baca Juga

Powered by WHMCompleteSolution