本文介绍了“拒绝取消链接许可"尝试删除deleteme.txt时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Ubuntu Web服务器中删除deleteme.txt.

所以我让4.php执行以下操作:

<?php
unlink('deleteme.txt');
?>

deleteme.txt具有以下权限状态:

-rwxrwxrwx 1 ubuntu ubuntu    19 Jun 12 06:18 deleteme.txt

当我执行"4.php"时,总是会发生此错误

Warning: unlink(deleteme.txt): Permission denied in /var/www/html/4.php on line 2

我已经在包含"deleteme.txt"的目录上尝试过chmod 777 deleteme.txtchown ubuntu /var/www/html

我还在该文件的父目录上尝试过chown ubuntu /var/www/.

解决方案

您需要将其锁定为www-data,因此,这意味着www-data将获得文件的所有权,从而允许您通过与php取消链接来删除它. /p>

像这样:

$ chown www-data <file or folder>

I want to delete deleteme.txt in the Ubuntu web server.

So I made 4.php do the following:

<?php
unlink('deleteme.txt');
?>

deleteme.txt has the following permission status:

-rwxrwxrwx 1 ubuntu ubuntu    19 Jun 12 06:18 deleteme.txt

When I execute "4.php", this error always occurs

Warning: unlink(deleteme.txt): Permission denied in /var/www/html/4.php on line 2

I already tried chmod 777 deleteme.txt and chown ubuntu /var/www/html on the directory which contains "deleteme.txt"

I also tried chown ubuntu /var/www/ on the parent directory of that file.

解决方案

you need to chown to www-data, thus meaning that the www-data will gain ownership of the file allowing you to delete it through unlink with php.

Like so:

$ chown www-data <file or folder>

这篇关于“拒绝取消链接许可"尝试删除deleteme.txt时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 23:08