日期:2014-05-16  浏览次数:20671 次

linux给文件或目录添加apache权限

系统环境:ubuntu11.10/apache2/php5.3.6

在LAMP环境中,测试一个简单的php文件上传功能时,发现/var/log/apache2/error.log中出现如下php警告:

  1. [Tue Jan 31 09:40:27 2012][error] [client 127.0.0.1] PHP Warning: move_uploaded_file(/home/leotody/32883679.jpeg): failed to open stream: Permission denied in /var/www/upload_file.php on line 25, referer: http://localhost/info.html  
  2. [Tue Jan 31 09:40:27 2012][error] [client 127.0.0.1] PHP Warning: move_uploaded_file(): Unable to move '/tmp/phps05ssU' to '/home/leotody/32883679.jpeg' in /var/www/upload_file.php on line 25, referer: http://localhost/info.html  

提示没有访问权限,文件上传的代码如下:
    1. if (file_exists("upload/"$_FILES