The problem I encountered was simple, the code base is written for PHP 5.1.6 and my environment is already at PHP 5.3.10. There are also differences on my PHP settings such as strict warnings and the like. One of my side projects is throwing a lot of PHP warnings that I need to get rid of it.
The main objective is to make the application run/compatible with my current setup without affecting my other applications in my local machine. This could be done by setting PHP settings specific to a virtual host. This could be done in
.htaccess file but I prefer to use the Apache config file to not pollute the application’s code.
I always see this warning when I went
E_ALL | E_STRICT mode. This is the missing timezone setting that PHP cry wolf for letting him guess the appropriate time setting. This could be fixed by setting the default timezone either via application or via PHP configuration. However, I don’t want to touch the application’s code, therefore, I set the default timezone via PHP config via Apache.
Next is to set the error reporting mode to less strict and less verbose so that PHP warning will not explode on my screen.
Last is the short open tag mode in PHP
<?=$blah ?> which was disabled in my global setup. I have to enable this only to this specific application.
Simple. Simply modify the vhost configuration to add the PHP configurations. The syntax is:
php_value name value
Here is my final configuration.
<VirtualHost *:80> ServerAdmin email@example.com DocumentRoot "/var/www/htdocs/burf.darkstar.net" ServerName burf.darkstar.net <Directory "/var/www/htdocs/burf.darkstar.net"> AllowOverride All Order allow,deny Allow from all </Directory> ErrorLog "/var/log/httpd/burf.darkstar.net-error_log" CustomLog "/var/log/httpd/burf.darkstar.net-access_log" common php_value error_reporting "E_ALL ^ E_NOTICE" php_value date.timezone "Asia/Manila" php_value short_open_tag "On" </VirtualHost>
After setting the new vhost configuration, restart Apache then those PHP warnings are now gone.