Extension alternative php cache

How to install APC (Alternative PHP Cache) in Linux

To Install APC (Alternative PHP Cache) in Linux

APC -Alternate PHP Cache is an open source cache for PHP code . It provides robust framework for caching and optimizing PHP code . The procedures to install and enable APC caching for PHP in Linux is explained.

Installation of Dependency Packages for APC

Firstly install required packages namely pecl , phpize and apxs commands, in order to install APC using YUM package manager tool.

[[email protected] ~]# yum install php-pear php-devel httpd-devel pcre-devel gcc make -y Loaded plugins: aliases, changelog, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock Loading support for CentOS kernel ABI Setting up Install Process Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net Package pcre-devel-7.8-7.el6.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package gcc.x86_64 0:4.4.7-16.el6 will be updated --> Processing Dependency: gcc = 4.4.7-16.el6 for package: gcc-java-4.4.7-16.el6.x86_64 --> Processing Dependency: gcc = 4.4.7-16.el6 for package: gcc-gfortran-4.4.7-16.el6.x86_64 --> Processing Dependency: gcc = 4.4.7-16.el6 for package: gcc-c++-4.4.7-16.el6.x86_64 --> Processing Dependency: gcc = 4.4.7-16.el6 for package: gcc-objc-4.4.7-16.el6.x86_64 --> Processing Dependency: gcc = 4.4.7-16.el6 for package: gcc-gnat-4.4.7-16.el6.x86_64 . . . Installed: php-devel.x86_64 0:5.3.3-47.el6 Updated: gcc.x86_64 0:4.4.7-17.el6 httpd-devel.x86_64 0:2.2.15-53.el6.centos make.x86_64 1:3.81-23.el6 php-pear.noarch 1:1.9.4-5.el6 Dependency Updated: cpp.x86_64 0:4.4.7-17.el6 gcc-c++.x86_64 0:4.4.7-17.el6 gcc-gfortran.x86_64 0:4.4.7-17.el6 gcc-gnat.x86_64 0:4.4.7-17.el6 gcc-java.x86_64 0:4.4.7-17.el6 gcc-objc.x86_64 0:4.4.7-17.el6 gcc-objc++.x86_64 0:4.4.7-17.el6 httpd.x86_64 0:2.2.15-53.el6.centos httpd-manual.noarch 0:2.2.15-53.el6.centos httpd-tools.x86_64 0:2.2.15-53.el6.centos libgcc.i686 0:4.4.7-17.el6 libgcc.x86_64 0:4.4.7-17.el6 libgcj.x86_64 0:4.4.7-17.el6 libgcj-devel.x86_64 0:4.4.7-17.el6 libgfortran.x86_64 0:4.4.7-17.el6 libgnat.x86_64 0:4.4.7-17.el6 libgnat-devel.x86_64 0:4.4.7-17.el6 libgomp.x86_64 0:4.4.7-17.el6 libobjc.x86_64 0:4.4.7-17.el6 libstdc++.x86_64 0:4.4.7-17.el6 libstdc++-devel.x86_64 0:4.4.7-17.el6 mod_ssl.x86_64 1:2.2.15-53.el6.centos php.x86_64 0:5.3.3-47.el6 php-cli.x86_64 0:5.3.3-47.el6 php-common.x86_64 0:5.3.3-47.el6 php-gd.x86_64 0:5.3.3-47.el6 php-ldap.x86_64 0:5.3.3-47.el6 php-mysql.x86_64 0:5.3.3-47.el6 php-odbc.x86_64 0:5.3.3-47.el6 php-pdo.x86_64 0:5.3.3-47.el6 php-pgsql.x86_64 0:5.3.3-47.el6 php-soap.x86_64 0:5.3.3-47.el6 php-xml.x86_64 0:5.3.3-47.el6 php-xmlrpc.x86_64 0:5.3.3-47.el6 Complete!

Installating APC Using PECL

Use PECL command to install it and ensure to select default settings when asked.

[[email protected] ~]# pecl install apc downloading APC-3.1.13.tgz . Starting to download APC-3.1.13.tgz (171,591 bytes) . done: 171,591 bytes 55 source files, building running: phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 Enable internal debugging in APC [no] : Enable per request file info about files used from the APC cache [no] : Enable spin locks (EXPERIMENTAL) [no] : Enable memory protection (EXPERIMENTAL) [no] : Enable pthread mutexes (default) [no] : Enable pthread read/write locks (EXPERIMENTAL) [yes] : building in /var/tmp/pear-build-rootF4pGGV/APC-3.1.13 . . . Build process completed successfully Installing ' /usr/include/php/ext/apc/apc_serializer.h' Installing ' /usr/lib64/php/modules/apc.so' install ok: channel://pecl.php.net/APC-3.1.13 configuration option " php_ini" is not set to php.ini location You should add " extension=apc.so" to php.ini

The following command enables APC extension in Apache configuration.

[[email protected] ~]# echo " extension=apc.so" > /etc/php.d/apc.ini

Restart Apache Service for APC

Restart the Apache service to bring new changes.

[[email protected] ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]

Verifing APC

Now you have to create a file info.php in Apache web root directory. For instance, /var/www/html/info.php

Читайте также:  Moving color text html

Next add the following code to it, then save and close.

phpinfo

Navigate to http://localhost/info.php

Enabling PHP administration

In order to enable APC administration panel, copy the following file.

[[email protected] ~]# cp /usr/share/pear/apc.php /var/www/html/

Open the file apc.php with VI editor.

Set your username and password in the file apc.php .

defaults(' ADMIN_USERNAME' ,' admin' ) // Admin Username defaults(' ADMIN_PASSWORD' ,' linuxc' ) // Admin Password - CHANGE THIS TO ENABLE.

view host information

To View Host information status, click View Host Stats tab.

To view cache entries, click System Cache Entries tab.3

Click User Cache Entries.
cache entries
APC Login Screen prompts. Type the user credentials to authenticate.
APC Login Screen prompts

Now enter the cache entries.
cache entries
Click APC Version Check, to know your APC version.
 APC version

To Upgrade using PECL

Execute following command to upgrade it. It will download and then upgrade APC .

To Uninstall

Type the following command to uninstall APC completely from your machine.

Источник

Install APC (Alternative PHP Cache) in CentOS 5/6/7 and Fedora 20/21

APC (Alternative PHP Cache) is a free and open source tool to cache PHP codes.

phpapc

1. Install Dependency Packages for APC

yum install php-pear php-devel httpd-devel pcre-devel gcc make -y

2. Install APC using PECL (PHP Extension Community Library)

Press “Enter” for the following options

Enable internal debugging in APC [no] : Enable per request file info about files used from the APC cache [no] : Enable spin locks (EXPERIMENTAL) [no] : Enable memory protection (EXPERIMENTAL) [no] : Enable pthread mutexes (default) [yes] : Enable pthread read/write locks (EXPERIMENTAL) [no] :

2a. [Alternative]

If the above command fails, you can use the following method to install APC as well.

3. Enable APC PHP Extension

echo "extension=apc.so" > /etc/php.d/apc.ini

4. Restart Apache Service for APC

sudo service httpd restart

5. Verify APC Installation

Create a file named phpinfo.php in Apache web root directory. For example our Apache web root directory is /var/www

And add the following code to the php file

[Optional] If you do not have nano installed

Open the following url in your web browser

http://yourdomain.com/phpinfo.php

Screen Shot 2015-08-02 at 2.48.22 pm

6. Enable PHP APC administration

Copy the following file to any web directory that you want. For example, in this case we will copy it to the web root directory.

cp /usr/share/pear/apc.php /var/www/html/

Open the file apc.phpÂÂ

In nano editor, use “Ctrl-w” to search for the username and password field to modify.

defaults('ADMIN_USERNAME','apc'); // Admin Username
defaults('ADMIN_PASSWORD','password'); // Admin Password - CHANGE THIS TO ENABLE.

Open the following link in your web browser.

You should see your APC stats and that’s it!

Источник

Оцените статью