Category Archives: PHP

PHP exec in background

So, in one of my projects/products/services, I need to execute ffmpeg via PHP…
Usually I use at do send the job to a queue list.. unfortunately in two different clients’ servers somehow PHP + exec and at doesn’t work well….

This is how we send a PHP exec to background

exec(command > /dev/null 2>/dev/null &);

 

As seen on http://stackoverflow.com/questions/8961470/how-to-make-shell-exec-run-in-background-while-php-continues

PHP Browser language detection

This is how….

<?php
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){
    case "pt":
        echo "Browser lang PT!";
        break;
    case "it":
        echo "Browser IT";
        break;
    case "en":
        echo "Browser lang EN";
        break;        
    default:
        echo "Browser lang EN - Setting Default";
        break;
}
?>

 

PHP – 500 internal server error – cPanel

I’v been struggling for hours to solve a weird problem with PHP in a cPanel environment.

This is how my log (/usr/local/apache/logs/error_log) looks like

[Tue Dec 30 21:13:09 2014] [error] [client 88.94.5.xxx] SoftException in Application.cpp:601: Directory "/home/dee/subdomains/www2.domain.com/members" is writeable by group
[Tue Dec 30 21:13:09 2014] [error] [client 88.94.5.XXX] Premature end of script headers: index.php
[Tue Dec 30 21:13:09 2014] [error] [client 88.94.5.XXX] File does not exist: /home/dee/subdomains/www2.domain.com/500.shtml

I thought that was some bad configuration on .htaccess … but that was wrong!
On some environments we need to have the right file/directory permissions so it work…

  • files: 644
  • directories: 755

Continue reading PHP – 500 internal server error – cPanel