从shell_exec()权限执行symfony任务命令 [英] Execute symfony task command from the shell_exec() permission denied
问题描述
我有symfony任务调用"doNothing",并且我想通过执行shell_exec('/var/www/esm/symfony php symfony doNothing');
来执行它
I have symfony task call "doNothing" and i want to execute it from executing shell_exec('/var/www/esm/symfony php symfony doNothing');
通过调用我的symfony动作
by calling to my symfony action
apache错误,显示权限被拒绝.
apache error saying permission denied.
我认为www-data
用户没有权限,我该如何解决?
i think www-data
user dont have permission how could i resolved this?
已编辑
error is
sh:/var/www/esm/symfony:权限被拒绝
sh: /var/www/esm/symfony: permission denied
推荐答案
您应该查看脚本所在的目录.
You should look in the directory where your script is.
使用ls -la
显示文件夹中的所有文件及其权限(要执行php脚本文件,必须至少将x
位分配给www-data或其组).
Use ls -la
to show all files in the folder and their permissions (to execute php script file must have at least x
bit assigned to www-data or its group).
所有直到/
的父目录都必须为用户/组分配x
位,以便apache能够将目录更改为.
Also all the parent directories up to /
MUST have x
bit assigned to user/group for apache to be able to change directory to.
看.您具有树形文件系统:
Look. You have Tree structured Files system:
-
/var/www
在/var
中
-
/var/www/esm
在/var/www
中
-
/var/www/esm/symfony
在/var/www/esm
中
/var/www
is in/var
/var/www/esm
is in/var/www
/var/www/esm/symfony
is in/var/www/esm
因此www数据用户应该能够执行(x
位)所有这些目录.
So www-data user should have the ability to Execute (x
bit) all of that directories.
因此,在/
中执行ls -l
并查看/var
具有www数据用户或其所属组(drw x
rw x
---)的x
位时,它拥有此目录.在/var
中执行ls -l
等等...
So when in /
execute ls -l
and look wheter /var
has x
bit for www-data user or it's group (drwx
rwx
---) and it owns this directory. When in /var
execute ls -l
an so on...
您可以将每个目录的权限更改为777.但是请勿使用-R
键.只需将权限更改为仅目录.
You can change permissions to 777 for every directory. But DO NOT use -R
key. Just change permissions to the directory only.
这篇关于从shell_exec()权限执行symfony任务命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!