Consider the scenario of a PHP script which can be run for a period of time, stopped, and continue its task later on. A common necessity for such a script may be to detect when the script is terminated, and perform some functions at that time. This can be accomplished by having the script capture… Continue reading Capturing Termination Signals in PHP
Tag: php
PHP-FPM on Amazon’s Linux
Update (Oct 1, 2011): The release notes for the newest version of Amazon’s Linux (2011.09) state that “PHP scripts have the option of using PHP-FPM.” PHP-FPM is now included in the amzn-main repository, and can be installed via yum install php-fpm (it is installed to /usr/sbin). As a point of mention, if you want to… Continue reading PHP-FPM on Amazon’s Linux
Prime Factoring with PHP
A surprisingly large number of math based computer problems appear to require factorization, finding prime number, or prime factoring. Presented below is a reasonably fast algorithm for prime factoring a number – it is limited to the integer size on PHP (231-1). It should be a fairly trivial exercise to modify the function below to… Continue reading Prime Factoring with PHP
Hardening PHP with Suhosin
Suhosin is a package designed to harden PHP, in the sense that it addresses potential vulnerabilities that might be introduced through user scripts. It comes as both a patch which can be applied directly to the PHP source code and as an extension that can be built for PHP. This article looks at how to… Continue reading Hardening PHP with Suhosin
Fractions
For many people the mere mention of fractions elicits a wince, and while these lovely math constructs played a notable role in our early years of math, they are reasonably simple entities. While most humans revisit fractions over many years and often still fail to grasp the concept, for a computer, the elementary operations with… Continue reading Fractions
Setting the timezone on PHP
Versions of PHP after 5.10 include the date.timezone directive in php.ini. Many applications which reference time need this directive to be set. A list of accepted values can be found at: http://www.php.net/manual/en/timezones.php The timezone is set as a quoted string, with no delimiter at the end, for example: date.timezone = “Continent/City” The location of the… Continue reading Setting the timezone on PHP
Installing mcrypt (PHP) on AWS Linux AMI
Update: with the update of PHP to v5.3.3, the amzn repository now includes php-mcrypt, rendering the steps below unnecessary. At the moment, the amzn repository has v5.3.2 of PHP (while the latest version is v5.3.3) – it also does not offer php-mcrypt. While in previous servers I have included a wider selection of repositories, I… Continue reading Installing mcrypt (PHP) on AWS Linux AMI
Installing APC on AWS Linux AMI
Update: Current versions of Amazon’s Linux AMI include the package php-pecl-apc (v3.1.9 – the same as the latest from PECL) in the repository. Using a package manager is usually preferable to using PECL- it will help you keep up to date, is centrally managed, and minimizes unnecessary dependencies (especially build tools). APC can be installed… Continue reading Installing APC on AWS Linux AMI