ftp, sftp and php
Hi,
PHP runs as 'nobody' on my dedicated server. I have a php script that needs to copy a template file from a file or from a mysql db to the web directory.
Once it is in the web directory it needs to change ownership and group to the owner of the web directory (not 'nobody').
Initially I tried php functions chown(), chmod() etc but of course because the web dir is not owned by 'nobody' php has insufficient permissions, it cannot write the files to the directory and it cannot modify the directory (chmod 777) to allow the files to be written.
So I need to follow the ftp route, I want to ftp_connect() using php, to the server locally using the web directory owner's login details, but I have hit a problem, the server is setup to only allow sftp login.
Is there a way to allow ftp login but only locally from within the server, so php can login and chmod the directory to 777, copy in the template file and then chmod back to 755?
What is a good secure ftp program to install on the server?
Is there a better way?
Any help or pointers appreciated.
__________________
$wisdom = array('knowledge', 'patience', 'experience', 'compassion', 'sympathy', 'humour', 'courage', 'tolerance', 'humility', 'Linux');
|