php create_directory 权限被拒绝 : when attempting shell_exec script

标签 php apache shell ubuntu permissions

当我尝试 shell_exec('/home/user/scripts/./script') 时,出现以下错误:

terminate called after throwing an instance of 'boost::filesystem3::filesystem_error'
  what():  boost::filesystem::create_directory: Permission denied: "/.script"
Aborted (core dumped)
shell_exec('whoami') 在我的面向 Web 的 php 脚本中返回 www-data

目录和文件的权限完全相同:
-rwxrwxr-x 1 user123   group456     8246 Jun 25 06:10 script
drwxrwxr-x 7 user123   group456     4096 Jul 10 14:54 . 

事实上,我可以 shell_exec('touch /home/user/scripts/test') 并且它会毫无问题地创建文件。
$ ls -l /home/user/scripts/test
-rw-r--r-- 1 www-data www-data          0 Jul 10 14:54 test123

这是为每个用户设置我的组的方式:
$ groups user123
user123 : group456
$ groups www-data
www-data : group456

为什么我会收到此错误?

最佳答案

您运行的脚本有错字:它正在尝试创建文件夹 /.script在根文件夹中而不是 ./script (相对路径)。

关于php create_directory 权限被拒绝 : when attempting shell_exec script,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17574260/

相关文章:

php - 使用 where 子句创建自定义 View 时出现问题

perl - 模板工具包字符编码

linux - 自动添加带空格的 SVN 命令行

python - 简单 python 模块出错

javascript - 文本区域值不保留变量的换行符

php - 如何在 CodeIgniter 的一个 View 中使用多种语言?

php - 如何从 mktime 到 datetime 对象?

python - 在一台 Xampp Windows Apache Mod_WSGI 服务器上部署两个 Django 项目

apache - 使用 S3/EC2 时删除 ".php"文件扩展名

linux - 为什么 'until'存在?