Installing PHP accelerators Tutorials

Installing PHP accelerators

All about PHP eAccelerator, XCache and APC accelerators

 

What is PHP accelerators?

PHP accelerators are extensions that are installed on the same server and are primarily responsible for increasing the performance of loading files with the PHP language. They work by caching PHP SCRIPTS compiled in binary code so that every time they are requested, they do not have to be loaded again, so they reduce the server load to half and in some cases the reduction can be 10 times more , depending on the structure of PHP files.

The PHP Accelerators listed below can only work on Servers that function as Apache Module or FASTCGI.

 

What PHP Accelerator can I use on my server?

There are many PHP accelerators that can be used on servers. We will name and explain the most widespread ones.

eAccelerator: The most popular of all and the most widespread. It comes preconfigured within the server options with Cpanel for APACHE/PHP. It can reduce the server load by two to 10 times less.

 

Eaccelerator

 

APC (Alternative PHP Cache): It is free open source and very good for caching intermediate php codes. Includes a Script to view APC performance statistics.

 

Download APC

 

XCache: Notone of the most used, one of its developers is the same one that designed LIGHTTPD. It also has a performance statistics dashboard like APC but is less visually appealing. Quality and performance is similar to APC, so you can use one or the other.

 

Download XCache

 

Choosing the use of one type of PHP Accelerator or another is not easy. They all perform quite well and perform their functions correctly, however depending on the characteristics of each Server, it may be better to use one instead of the other. We recommend that you all experience each other and given the individual experience of each one, you choose the one that best performs on your web server.

 

Steps to install the PHP Accelerator

To install any of the PHP Accelerator packages you must have a VPS or DEDICTED server and have SHELL access, otherwise you would have to ask your Hosting provider to perform such installation as you would not have access to be able to do it yourself. In Shared Hostings you would not have the option to install any PHP acceleratoras as this would affect the other Webs hosted on the same server and the same Hosting providers do not allow it to maintain security and avoid errors.

Install using PECL

The APC Accelerator can be installed using PECL on the Linux server Cpanel.

1) Run the following command in Shell as the Root user:

pecl install apc

and select the options that are required.

2) Update and add the following in the php.ini file:

extension=”apc.so”

3) Restart the Apache service with the following command:

# /etc/init.d/apache2 restart

(Apache server can be restarted from the same Cpanel or Plesk control panel)

 

Install on Linux Servers

1) Enter Shell and identify yourself as root user and type the following command:

#cd /usr/local/src

2) Go to http://pecl.php.net/package/APC and copy the download link from the version of APC you want to install. Once this is done, type the following command with the APC version download link.

#wget http://pecl.php.net/get/APC-3.1.19.tgz

3) Extract the file with the following command:

#tar -xzf APC-3.1.19.tgz

cd APC-3.1.19

phpize

./configure –enable-apc –enable-apc-mmap –with-apxs –with-php-config=/usr/local/bin/php-config

make

make install

4) Check the location of the PHP file by typing the following:

# php -i | grep php.ini

5) Add the installed extension by editing the php.ini file and adding the following line:

extension=”apc.so”

6) Proceed to restart the Apache server by typing the following command:

# /etc/init.d/apache2 restart

(Apache server can be restarted from the same Cpanel or Plesk control panel)

7) You should check the PHP modules to see that everything has been installed correctly.

Note: If the operating system is Centos 5.5, then install the PCRE module if it is not installed, with the following command:

# yum install pcre-devel

To install the Accelerator, we need to have SHELL access to be able to write the following commands:

1) We enter the following directory:

cd /usr/local/src

2) Download and unzip the Accelerator installation package (We must type the corresponding URL that directs us to the direct download of the package from the official page http://eaccelerator.net/:

wget https://github.com/eaccelerator/eaccelerator/tarball/master -O eaccelerator.tar.gz
tar zxvf eaccelerator.tar.gz

3) Access the folder:

cd eaccelerator

4) We prepare the PHP extension build environment:

phpize

./configure
make
make install

5) It is an application to automatically build RPM/Debian packages

checkinstall

6) Create the file to edit the Accelerator settings:

nano /etc/php5/conf.d/eaccelerator.ini

7) We add the following lines to the created eaccelerator.ini file:

extension=”eaccelerator.so”
eaccelerator.shm_size=”128″
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″

8) Create the folder for the package cache:

mkdir -p /var/cache/eaccelerator

9) We assign you access permissions:

chmod 0777 /var/cache/eaccelerator

10) Reboot the Apache server for the changes to take effect:

/etc/init.d/apache2 restart

11) We can create a file to be able to view the settings from the browser:

echo ” > /var/www/phpinfo.php

12) We verify the information by typing the following url in the browser:

http://localhost/phpinfo.php

In order to install this Accelerator, you must have SHELL access to be able to enter the commands listed below.

 

Instalación en sistemas operativos RHEL/CentOS/Fedora Linux

1) Download the Accelerator installation package from the developer’s website http://xcache.lighttpd.net/pub/Releases/ and choose the download URL corresponding to the version of the Accelerator that we want to install and write the following command replacing the url that we indicate with the one you have chosen with (in this case we have as reference version 3.0.1)

wget http://xcache.lighttpd.net/pub/Releases/3.0.1/xcache-3.0.1.tar.gz

2) Unzip the downloaded package and access the directory where it is located:

3) After the download we unzip the file and access the xcache directory(xcache-3.0.1)

tar xzvf xcache-3.0.1.tar.gz
cd xcache-3.0.1

4) We perform the compilation and installation of the unzipped package:

phpize
./configure –enable-xcache
make
make xcachetest
make install

Depending on the architecture of each operating system, the package will be installed in a different directory as follows:

64 bit: /usr/lib64/php/modules/xcache.so
32 bit: /usr/lib/php/modules/xcache.so
5) We create and edit the Accelerator configuration file (In this case we will use the nano, but you can use any plain text editor):

touch /etc/php.d/xcache.ini
nano /etc/php.d/xcache.ini

We introduce the following content:

xcache-common]
; change me – 64 bit php => /usr/lib64/php/modules/xcache.so
; 32 bit php => /usr/lib/php/modules/xcache.so
zend_extension = /usr/lib64/php/modules/xcache.so
[xcache.admin]
xcache.admin.auth = On
xcache.admin.user = “admin”
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = “”
[xcache]
xcache.shm_scheme = “mmap”
xcache.size = 32M
xcache.count = 1
xcache.slots = 8K
xcache.ttl = 3600
xcache.gc_interval = 300
; Same as aboves but for variable cache
; If you don’t know for sure that you need this, you probably don’t
xcache.var_size = 0M
xcache.var_count = 1
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
; N/A for /dev/zero
xcache.readonly_protection = Off
xcache.mmap_path = “/dev/zero”
xcache.cacher = On
xcache.stat = On

6) Save the changes made to xcache.ini and restart the Apache server with the following command:

service httpd restart
7) We check if everything has gone well and the module is running correctly:

php -v

Artículos relacionados

Need help? Chat with us
Please accept our Data Privacy and Polcily before starting the conversation.
This website uses both its own and third-party cookies to measure visits and sources of web traffic. The legal basis is the user's consent, except in the case of basic cookies, which are essential to navigate this website.