APC (Alternative PHP Cache) is a free and open source tool to cache PHP codes.
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)
pecl install apc
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.
yum install php-pecl-apc -y
3. Enable APC PHP Extension
echo "extension=apc.so" > /etc/php.d/apc.ini
4. Restart Apache Service for APC
CentOS
sudo service httpd restart
Fedora
/etc/init.d/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
nano /var/www/phpinfo.php
And add the following code to the php file
<?php phpinfo(); ?>
[Optional] If you do not have nano installed
yum install nano
Open the following url in your web browser
http://yourdomain.com/phpinfo.php
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ÃÂ
nano /var/www/html/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.
http://yourdomain.com/apc.php
You should see your APC stats and that’s it!
0 Comments