The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Site visitor to upload files to multiple server accounts

Discussion in 'General Discussion' started by GoWilkes, May 25, 2012.

  1. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    367
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    I have two accounts on one server, and I'm trying to modify an existing script so that when they upload an image to one account, it will also be copied to the second account.

    FWIW, this is only temporary; the new account is a beta release for the first account, and in 30 days I'll set the domain to point to the second account and then delete the first one. But for those 30 days, I need for the same images to be available on both accounts.

    I should also mention that this is a dedicated server, so all of the accounts are mine.

    After setting the permission to the directory on the second account to 777, I still get a "permission denied" error. Can you guys suggest how I might make it writable from the other account?
     
  2. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    367
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Any ideas?
     
  3. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Rather than doing it the way you are doing it, why don't you simply copy the files periodically to the other account and then chown them to the right user? You could use a simple cron job that runs every 15 minutes to do this, then the cron script could be a simple bash script to copy the contents of the directory to the other directory and chown to the right user.
     
  4. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    367
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    If that's the only way to do it, then I can, but there are problems with it:

    1. The site that I'm moving over is pretty high-traffic, so I'd have to copy every 1-minute instead of 15. There's already a pretty high server load as it is, and running a script like that every minute would be very taxing.

    2. There are actually 3 separate directories of images that would be copied: classifieds, attachments to Private Messages, and a "cache" folder (where the uploads go before they're approved, resized, and copied to their final directory). Even a 1-minute delay of an ad or a PM saying that there's an image, but then one not being available, is going to cause me to get a lot of emails of "where's my image?"


    So, while it CAN be done with a cron, it would be infinitely better if I could just modify the script so that it could upload to two accounts at once.
     
  5. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You'd either need to turn off FileProtect to allow the script to do it if you are using suPHP, or else you'd have to run in DSO and have these owned by nobody.
     
  6. GoWilkes

    GoWilkes Well-Known Member

    Joined:
    Sep 26, 2006
    Messages:
    367
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    I'm actually working with Perl scripts, not PHP, but the permission logic should be the same.

    I tried changing the owner to nobody:nobody, but this just resulted in an Internal Server Error when running the script. I tried a simple "Hello World" script and changed the owner to nobody, but that, too, gave an ISE.

    Is there a setting I need to change in cPanel or Apache in order to make Perl run as nobody (or, run a script that is owned by nobody)? Or would that break my other Perl scripts?
     
  7. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You could try turning off suEXEC in WHM > Apache Configuration > PHP and SuExec Configuration area. CGI and Perl will be user-specific when suEXEC is enabled.

    Otherwise, you can turn it off in command line:

    Code:
    /usr/local/cpanel/bin/rebuild_phpconf --current
    That lists the current configuration. Once you have it, you can then run the options such as let's say you have suPHP and only PHP 5 as the default with PHP 4 not enabled, you'd do:

    Code:
    /usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 0
    Where 5 is PHP 5 as default, none is no handler for PHP 4, suphp is suPHP for PHP 5 and 0 is disabled for suEXEC.

    Thanks!
     
Loading...

Share This Page