How to give apache permission to write to home directory?

前端 未结 4 1226
深忆病人
深忆病人 2020-12-14 03:21

My server is in /var/www/html I have a php script in /var/www/html/fileio_test/io_test.php



        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-14 04:09

    As your file residing in your Home directory, I would suggest one of following approaches.

    1. Give 0777 permission to file itself.

      chmod 0777 /home/djameson/test.txt
      
    2. Change Ownership to apache user www-data and give owner-write permission.

      sudo chown www-data:www-data /home/djameson/test.txt
      chmod 0744 /home/djameson/test.txt
      
    3. Add your user to www-data group or vice-verse add www-data user to your group. And then group write permission.

      sudo usermod -a -G www-data djameson
      chmod 0764 /home/djameson/test.txt
      

    NOTE : I am assuming apache user name & group name is www-data & www-data respectively. You must change accordingly your server apache username/group name.

提交回复
热议问题