In server administration, optimizing PHP performance is a common task. One effective way to achieve this is by using the Alternative PHP Cache (APC), a robust and open-source framework designed for caching and optimizing PHP intermediate code. APC is a PECL extension, sharing the packaging and distribution system with its sister, PEAR.
This comprehensive guide will walk you through the steps to enable the admin script of APC, building on our previous tutorial on how to enable APC with PHP on CentOS 6.3.
Step 1: Create an APC Directory on Document Root
First, you need to create a directory named ‘apc’ on the document root. This can be done using the following command:
[root@centos63 ~]# mkdir /var/www/html/apc
Step 2: Copy apc.php from php-pecl-apc Folder to Document Root
Next, copy the ‘apc.php’ file from the ‘php-pecl-apc’ folder to the document root. Use the command below:
[root@centos63 ~]# cp /usr/share/doc/php-pecl-apc-*/apc.php /var/www/html/apc
Step 3: Create a New File Named apc.conf.php
Now, create a new file named ‘apc.conf.php’. This can be done using the ‘vi’ command as shown below:
[root@centos63 ~]# vi /var/www/html/apc/apc.conf.php
Step 4: Create a New File Named apc.conf
In this step, create another new file named ‘apc.conf’. Use the following command:
[root@centos63 ~]# vi /etc/httpd/conf.d/apc.conf
<Directory /var/www/html/apc> Order Deny,Allow Deny from all Allow from 127.0.0.1 192.168.1.0/24 // IP address you allow </Directory>
Step 5: Restart Apache HTTPD
After creating the necessary files, it’s time to restart Apache HTTPD. Use the command below:
[root@centos63 ~]# /etc/rc.d/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
Step 6: Navigate to the APC Admin Script
Finally, navigate your browser to ‘http://servername/apc/apc.php’. The APC admin script should now be enabled and visible.
Commands Mentioned
- mkdir /var/www/html/apc – Creates a new directory named ‘apc’ on the document root.
- cp /usr/share/doc/php-pecl-apc-*/apc.php /var/www/html/apc – Copies the ‘apc.php’ file from the ‘php-pecl-apc’ folder to the document root.
- vi /var/www/html/apc/apc.conf.php – Creates a new file named ‘apc.conf.php’ and opens it for editing.
- vi /etc/httpd/conf.d/apc.conf – Creates a new file named ‘apc.conf’ and opens it for editing.
- /etc/rc.d/init.d/httpd restart – Restarts the Apache HTTPD service.
Conclusion
Enabling the admin script of APC is a straightforward process that involves creating and editing a few configuration files, and then restarting the Apache HTTPD service. This guide has provided step-by-step instructions to help you accomplish this task. By following these steps, you can optimize your PHP performance by leveraging the power of APC.
For more information on web server optimization and other related topics, check out our articles on Apache, Nginx, LiteSpeed, dedicated server, VPS server, cloud hosting, and shared hosting.
Remember, the key to successful web server administration is continuous learning and adaptation to new technologies and techniques.
Stay informed, stay ahead!
FAQs
-
What is the Alternative PHP Cache (APC)?
The Alternative PHP Cache (APC) is a free, open, and robust framework for caching and optimizing PHP intermediate code. It is a PECL extension.
-
What is the purpose of the ‘apc.conf.php’ file?
The ‘apc.conf.php’ file is used to set the username and password for the APC admin script.
-
What does the ‘apc.conf’ file do?
The ‘apc.conf’ file is used to set the directory permissions for the APC admin script, including which IP addresses are allowed access.
-
Why do we need to restart Apache HTTPD?
Restarting Apache HTTPD ensures that the server recognizes and implements the changes made to the APC configuration.
-
How do I access the APC admin script?
You can access the APC admin script by navigating to ‘http://servername/apc/apc.php’ in your web browser.