Tag Archives: php

Storing images on file system vs database

While researching efficient methods of storing large numbers of images on my server, I came across this post detailing the process of returning an image from a mysql server. The process described is common, except that it is inspected at a much lower level, complete with mode switching between kernel and user on a linux server:

Your systems network buffer fills with a new packet containing a new request from the network card. The system delivers the packet to your Apache, switching from kernel mode into user mode.

Apache processes the packet, handing it internally to its mod_php for processing. The mod_php parses the request, constructing a SQL query for the image blob, and pushes the SQL query into a kernel buffer, switching from user mode into kernel mode.

Check out the full post at http://mysqldump.azundris.com/archives/36-Serving-Images-From-A-Database.html

Installing XDebug on Virtualmin

XDebug helps you debug or profile your php code. It is useful for complex sites where it is not feasible to read each line of source to determine where you should start optimizing (especially if those are not your own code, as in the case of contributed extensions). One point to note is that XDebug does not output in a human readable way, you need to use tools like kcachegrind to parse the output to gather information from it.

To install with pecl:
pecl install xdebug

You can craft your own .ini, or you can get a default (albeit unsupported) xdebug.ini from http://gggeek.altervista.org/2007/11/26/the-completely-unofficial-xdebugini/ and place it in /etc/php.d along with the ini’s of other modules.

Important directives:
zend_extension="/usr/lib/php5/20060613/xdebug.so" <– to enable this module, but set the path to your own path to xdebug.so. (use find -name xdebug.so to locate it)
xdebug.profiler_enable=1 to enable the profiller
xdebug.profiler_output_dir is the output directory for the logs. You can leave it as the default /tmp directory

restart apache