Install APC for PHP on Debian 5 Lenny

I have recently moved from hosting on a CentOS box to Debian and needed to install PHP’s APC opcode cache on it. I’ve posted about how to do this before on a CentOS box which is a very manual process and now add this post to install APC on Debian which is much easier.

As the root user or using sudo run the following command:

aptitude install php-apc

Everything else is done for you and all that is needed now is to gracefully reload Apache, again running as the root user or using sudo:

apache2ctl graceful

The configuration file is at /etc/php5/conf.d/apc.ini should you wish to change any of the settings such as the APC memory size etc.

If you want to have a page showing the current APC statistics, run the following command:

gzip -dc /usr/share/doc/php-apc/apc.php.gz > /path/to/apc.php

Make sure /path/to/apc.php is a location available in a web browser (and ideally password and/or IP address restricted) and then you can view detailed statistical information. I have some screenshots available here from an older post.

Fetching data using PHP and PDO with bound placeholders

This post shows how to fetch data from a MySQL database using PHP’s PDO library with bound placeholders. This is a fairly basic tutorial and the functions used in it will be used in a post tomorrow titled "Load JSON data with jQuery, PHP and MySQL".

Exiting from within a PHP exception

This is the final post in my series about PHP exceptions and looks at how when an exception occurs, script execution may continue depending on how the exception is handled.

Categories PHP

Converting an array to JSON data with PHP

PHP’s json_encode function converts a PHP variable into a JSON string which can then be used in Javascript, for example using jQuery’s JSON functions. This is easy to do and I’ll be combining the two together in tomorrow’s post to show how to fetch data from a MySQL database with PHP into Javascript via JSON.

Categories PHP