uploaded files owned by apache

Discussion in 'General' started by rad, May 4, 2007.

  1. rad

    rad New Member

    Hello everyone .
    I have just installed ispConfig on Centos 4.4 server ( I followed exactly the tutorial in this site ) .
    eveything works fine . just when I uploade a file via php the owener and the groupe of the uploaded file is apache not the script owner r .

    [root@ns1 uploads]# ls -alt
    total 156
    drwxrwxrwx 2 web1_username web1 4096 May 4 14:36 .
    -rw------- 1 apache apache 143476 May 4 14:36 settings.jpg
    drwxrwxrwx 4 web1_username web1 4096 May 4 14:35 ..
    [root@ns1 uploads]#

    can someone help please .

    below is the php file
    <?php

    $uploaddir = '/var/www/web1/web/uploads/';
    $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

    echo "<p>";

    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    echo "File is valid, and was successfully uploaded.\n";
    } else {
    echo "Upload failed";
    }

    echo "</p>";
    echo '<pre>';
    echo 'Here is some more debugging info:';
    print_r($_FILES);
    print "</pre>";

    ?>
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    A uploaded script is always owned by the user that runs the script, in your case is the script run by the apache user. If you want your script to be owned by the admin user of the website, you will have to run your php scripts with e.g. SuPHP and not mod_php.
     
  3. rad

    rad New Member

    I see that suexec is installed and working isn't enough , do I need to install suPHP as well ? and if so what modifications I need to do ? Can you please guide me in details as I'm new to Linux as well .
    Thank you very much
     
  4. Hans

    Hans Moderator ISPConfig Developer

    Hi,

    I want you to know that you will not able to run suPHP AND suexec as well, because suPHP is not compatible with suexec. For this reason do not run those together.

    To give you an idea how you can setup suPHP on an ISPConfig server, you can have a look here: http://www.howtoforge.com/suphp_debian_etch_ispconfig

    The howto is written for Debian Etch but with some modifications, you're able to use the setup for your Linux distribution as well.
     
  5. rad

    rad New Member

    is suexec not enough to handel this issue ? also If I'm going to remove suexec am I going to have problems with ISPconfig or with other scripts ( cgi , Perl script )

    Thanks
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    You may handle this with SuEXEC + PHP as cgi too. But then you will have to add the PHP-CGI action definition and addhandler lines to the apache directives field of the website.

    1) Install php as cgi.

    2)Add these lines in the apache directives field of the website:

    Action php-cgi /cgi-bin/php
    AddHandler php-cgi .php

    and make sure that the php, php-safemode and cgi checkboxes are not enabled in the website.

    No, beacuse SuPHP replaces the suexec functionality of other cgi scripts too.
     
  7. rad

    rad New Member

    Thank you for your reply ,
    I have used yum to install php as in this tutorial http://www.howtoforge.com/perfect_setup_centos_4.4 ,
    My understanding is that, yum did not install php as cgi script . ( If I'm wrong please correct for me as I'm only 4 weeks old in Linux world ) . So I have to remove PHP ( yum remove * PHP* ) which will remove the following

    php i386 4.3.9-3.22.4 installed 3.2 M
    php-devel i386 4.3.9-3.22.4 installed 920 k
    php-gd i386 4.3.9-3.22.4 installed 286 k
    php-imap i386 4.3.9-3.22.4 installed 83 k
    php-ldap i386 4.3.9-3.22.4 installed 39 k
    php-mysql i386 4.3.9-3.22.4 installed 40 k
    php-odbc i386 4.3.9-3.22.4 installed 55 k
    php-pear i386 4.3.9-3.22.4 installed 1.2 M
    php-xmlrpc i386 4.3.9-3.22.4 installed 72 k

    then I have to get the source code from www.PHP.net and compile it .and install it . ( and aging if I'm wrong please correct for me ).
    I'll use this command ./configure --without-apache --without-apxs --with-other-options then make && make install

    The question now , What about Mysql , apache , and ISPconfig are they going to work fine or do I have to reinstall all of them .
    Thank you again for your help
     
    Last edited: May 5, 2007
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    You dont have to remove PHP, php as module is fine for many applications and much faster the php as cgi. I recommend to install php as cgi beside your current php installation, so you can switch between the two different php installs.
     

Share This Page