FCGI problem, help!!!

Discussion in 'Server Operation' started by erosbk, May 31, 2011.

  1. erosbk

    erosbk New Member

    If my site is using mod_php, this script works perfect.

    If I use FastCGI, I get an error 500 page... Is it possible that each page actually running ok in mod_php runs ok in fastcgi, or problems like this are common? please help! by the way, how can I make it work?

    Thanks!

    <?php
    $mail= 'admin@test.com.ar';
    $asunto= 'testing';
    $cuerpo= 'testing from web';
    $envio = mail($mail,$asunto,$cuerpo);

    if($envio == true)
    {
    echo'Send status:<br/>Sent ok!<br/>';
    }
    else
    {
    echo'Send status:<br/>Error sending!<br/>';
    }
    ?>

    Edit: Added SuEXEC to site and it works perfectly... FastCGI+SuEXEC is a must? thanks

    Edit2: my mails are being sending, with this script (FastCGI+SuEXEC) from sender: "web2@servername.domain.com". How can I change this for every website to be admin@userdomain.com (for example, would be great to us ServerAdmin as default sender!!)

    Really, thanks for your help, this are the last details that I have to correct in order to launch servers into production state!
     
    Last edited: May 31, 2011
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    No. But it is required for most scripts, otherwise the scripts run under the wrong user.

    The sender address is set automatically by php to the name of the linux system user @ the hostname of your server if no sender address is set in your script. Have you set the sender address in your scripts?
     
  3. erosbk

    erosbk New Member

    Then my scripts must work without suexec? why I get an error 500 without fastcgi with that simple script? (i will use suexec in everysite because what you said, but I just want to know why e500).

    No, I am not setting a sender. Is there a way to change this "default sender" of php? If I set mod_php, the sender is "webmaster@userdomain.com" instead "user@hostname".

    By the way, I need to restrict sender to be ONLY xxxx@samedomain.com (samedomain of the site, to avoid abuse). Is there a way to do this?

    Thanks!
     
  4. edge

    edge Active Member Moderator

    Add the "-f" option to your PHP mail code.
    PHP:
    mail('to@blah.com','subject!','body!','From: from@blah.com','-f from@blah.com');
    More info @ http://php.net/manual/en/function.mail.php
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Take a look in the error.log of the website, yozu will find the error message there that explains the reason.
     
  6. erosbk

    erosbk New Member

    Thank you but, I am needing to set a default sender, in case the owner of a vhost use phpmail function without a from (using, for example, the code that I wrote in the first post). Do you know how to do it? if I set a vsite with mod_php, a default address is set in the vhost file, I want to do something like it :p

    Thanks in advance!
     
  7. erosbk

    erosbk New Member

    Thanks, the error message was:

    Code:
    [Tue May 31 00:37:58 2011] [warn] [client 190.18.77.3] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
    [Tue May 31 00:37:58 2011] [error] [client 190.18.77.3] Premature end of script headers: mail.php
    
    but, if I enable suEXEC, it works perfectly without error (always using FastCGI). Do you know why, or where to find out the answers?

    Thanks for all your help
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Most likely the apache userw as not allowed to read the php file as it is obnwed by the web user. fastcgi with sueexec executes php files as website user while fastcgi without suexec executes the php file as apache user.
     

Share This Page