doufuhao8085 2011-12-20 13:20
浏览 63
已采纳

PHP不会在Ubuntu LAMP Web应用程序中打开文件

I am working a LAMP web app running on Ubuntu 11.10. I followed instructions on the web to harden my apache, php and mysql.

I have a PHP script which work fine when I run from the command line under my own id. But when I put the scripts into the web app framework, it can't not even open a log file to write (in /tmp) and it can't read other files in /var/www/myapp/html as well.

I used Ajax to retrieve file contents on the server and then serve those files to the browser. So my url will look like: "php/myphpscript.php?arg=.......".

My directory structure is /var/www/myapp/html|php|js|cfg.

I know this problem has something to do with permission, security but I am quite at loss. Can someone describe what I need to do here?

Thanks,

  • 写回答

1条回答 默认 最新

  • dt102282 2011-12-20 13:28
    关注

    I suspect you copied the files with your username, but apache executes as user www-data an thus has no access to your files. Either change them to belong to the apache user, or if you are the only develper on this machine, cahnge apache to run as you.

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

报告相同问题?