Thursday, 15 September 2011

php copy function does not work when called from http -



php copy function does not work when called from http -

my php function works when called within shell

php script.php

here in script.php:

copy("/home/mysite/public_html/streams/videos/1_video.flv","/home/mysite2/public_html/uploads/recordings/video.flv");

but when running script through http, re-create not work.

i guess permissions problems cannot solve.

any idea?

i got error/warning:

failed open stream: permission denied.

but when running script through http, re-create not work.

yes, when run script via command line run under individual user permissions.

but when run same script via http—meaning goes through apache server—then user connected apache needs have read permissions source & read/write permissions destination.

so chances either other source or destination not set apache web server user. assuming apache user www-data alter ownership of files in /home/mysite/public_html/ follows:

sudo chown www-data -r /home/mysite/public_html/

there 2 basic ways can determine apache user on server. 1 via command line this:

ps aux | egrep '(apache|httpd)'

which homecoming list of processes this:

www-data 13047 0.0 1.9 405496 11628 ? s jun15 0:00 /usr/sbin/apache2 -k start www-data 13048 0.0 1.8 405280 11248 ? s jun15 0:00 /usr/sbin/apache2 -k start www-data 14547 0.0 1.8 405488 11028 ? s jun15 0:00 /usr/sbin/apache2 -k start www-data 14649 0.0 1.8 405520 11044 ? s jun15 0:01 /usr/sbin/apache2 -k start www-data 16155 0.0 1.8 405496 11200 ? s jun17 0:00 /usr/sbin/apache2 -k start www-data 29323 0.0 1.7 405240 10876 ? s jun18 0:00 /usr/sbin/apache2 -k start

the user first entry on each line. in case www-data user.

another way handle determining user in php create little php file named whoami.php this:

sudo nano whoami.php

and place script in file:

<?php echo exec('whoami'); ?>

when load whoami.php in web browser see output of whoami in case www-data.

php

No comments:

Post a Comment