doushang4293 2017-02-20 10:09
浏览 74
已采纳

浏览器上的Rsync不起作用

I am trying to transfer files from one server to another with the code below.

rsync -avz -e "ssh -i /root/.ssh/somekey" /var/www/admin/somefiles.txt root@xxx.xxx.xxx.xxx:/var/www/html_public/some-folder/

It works just fine if I do this on putty but if I do shell_exec this code on a php page and run the page on a browser. It does not work. It returns an empty string.

I hope someone can help me with this. Thanks in advance.

  • 写回答

1条回答 默认 最新

  • doutang6819 2017-02-20 10:14
    关注

    First, you need to check if you need to be a root or (sudo user) for running rsync.

    If yes then exec() command will only work if it is run by same user on php-cli (not on browser by Apache user). i.e. Which user you are loggined into shell for run rsync.

    If it is root or any elavated permission user with sudo permission then, This rsync command may not be available to apache/www-data user which is working when php script run from browser.

    So You try to make a normal user and login through it, Then try rsync if you are successful then it may be interesting to see what are other problems can be, But if you getting access/permission denied then obviously you can not run this script at-least on browser.

    Besides this One more thing permission may not be directly related to rsync command itself but with folder /etc/test/ which is owned by root user in normal scenario.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?