Posts Tagged ‘php’

’502 Bad Gateway’ when running WordPress with spawn-fcgi nginx php

I am running a WordPress blog using nginx + PHP + spawn-fcgi and it works fine, but once a day spawn-fcgi seems to crash.

(more…)

SugarCRM Inbound E-mail problem

I’ve just got the following error message while accessing the Inbound E-mail feature in SugarCRM:

Inbound Email cannot function without the IMAP c-client libraries enabled/compiled with the PHP module

To fix this error on my Debian server I’ve had to install the PHP IMAP module via

apt-get install php5-imap

HipHop: PHP to C++ transformer

Nice compiler Facebook developed and use for optimizing their web application.

HipHop for PHP transforms PHP source code into highly optimized C++. It was developed by Facebook and was released as open source in early 2010.

HipHop transforms your PHP source code into highly optimized C++ and then compiles it with g++ to build binary files. You keep coding in simpler PHP, then HipHop executes your source code in a semantically equivalent manner and sacrifices some rarely used features – such as eval() – in exchange for improved performance.

Facebook sees about a 50% reduction in CPU usage when serving equal amounts of Web traffic when compared to Apache and PHP. Facebook’s API tier can serve twice the traffic using 30% less CPU.

via Home – hiphop-php – GitHub.

Check with PHP if a process id (PID) is active

I just had the problem of checking with a PHP script if a process is still running on my Debian machine. I searched a little bit and found different approaches like this one in a posting of the php.net exec manual page:

    function PsExists($pid) {
        exec("ps ax | grep $pid 2>&1", $output);
        while( list(,$row) = each($output) ) {
                $row_array = explode(" ", $row);
                $check_pid = $row_array[0];
                if($pid == $check_pid) {
                  return true;
                }
        }
        return false;
    }

For me this seemed to be somehow too much code, so I used the following little approach for my script:

exec("ps -p $pid", $output);
if (count($output) > 1) {
 // Process is running
}

This worked because ps -p PID will return information about the process if the PID is still active. And then the output array will have a length > 1.

Use HTML Tidy with PHP5 under Ubuntu/Debian

Install it via

sudo apt-get install php5-tidy

Then use it for example this way:

    $config = array(
            'indent'         => true,
            'output-xhtml'   => true,
            'show-body-only' => true,
            'wrap'           => 0);

    $tidy = new tidy;
    $tidy->parseString($html_txt, $config, 'utf8');
    $tidy->cleanRepair();

    echo $tidy;

phpize not found

I needed to install phpize on my Ubuntu system

The phpize command is used to prepare the build environment for a PHP extension. [...]

and got the following error:

phpize not found

To solve this problem i needed to install the php5-dev package

sudo apt-get install php5-dev