Question

I switched hosting providers and now have the following problem.

A function, imagecreatefromjpeg(), is trying to read a file from its URL path (http://mydomain.com/contents/category/certificate/1/template.jpg). This function was working on old setup but fails with the following error on the newer setup.

(104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
Premature end of script headers: index.php

The problem went away once I replaced the URL path with absolute path of the same file.

The differences I can see are

  1. the new setup is using nginx as Apache's reverse proxy.
  2. the PHP version on new setup is 5.3.3, older setup had 5.3.14

We've tried many things but can't understand how to make URL paths work on the newer setup. Can anybody help?

Was it helpful?

Solution

Are you sure you configured your nginx webserver accordingly ? Here are some good tutorials that can explain some of the more relevant nginx and php fastcgi process manager common pitfalls:

  1. Ars Technica: Web Served part 1: Setting up a web server

  2. Ars Technica: Web Served part 3: Installing PHP Fastcgi Process Manager

  3. Nginx common pitfalls

I linked these resources because it seems as if you have a missconfiguration of your rewrite engine. In any case, please provide better context !

OTHER TIPS

try to change url 'http://mydomain.com/' by a function

    function selfURL(){
    $server1 = $_SERVER['HTTPS'];
    $server2 = $_SERVER['SERVER_PROTOCOL'];
    $server3 = $_SERVER['SERVER_PORT'];
    $server4 = $_SERVER['SERVER_NAME'];


    $s = empty($server1) ? '' : ($server1 == "on") ? "s" : "";
    $protocol = strleft(strtolower($server2), "/").$s;
    $port = ($server3 == "80") ? "" : (":".$server3);
    return $protocol."://".$server4.$port;

    }
function strleft($s1, $s2){
return substr($s1, 0, strpos($s1, $s2));
}
print(selfURL());

you can replace '$port' if it not used

i have issues with this on my server when i am running cron.

here is what i can say based on a similar topic.

1) a page loads at something like ~/.

2) You reference another page located at ~/../private/hello/derp.php

3) inside derp.php it is under the assumption that you are running the file from ~/../private/hello/.'

4) in actuality you are running it from ~/.

5) file references are wrong because PWD is wrong.

it was annoying for my stuff to figure out but when i was looking at it in depth, i relized it was trying to load stuff from something like ~/../private/hello/images/hi.jpg where in actuality because of PWD, it was looking in ~/images/hi.jpg which didnt exist.

Maybe this helps you. I hope it does.

Edit You also want to know that a lot of time, the ~/. for YOU can be different then the ~/. of PUBLIC. That is also something to keep note of.

Try to make proper use of terminal variables via bash scripting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top