我有一个路由,它本质上是一个运行 Artisan 命令的钩子",它接受一些 get
参数作为参数:
I have a route that is essentially a "hook" to run an Artisan command, it accepts some get
parameters as arguments:
Route::get('hook', function()
{
$param = Input::get('param');
Artisan::call('myCommand', array('param' => $param));
}
myCommand
只需在根目录中创建一个名为 param
的目录和一个 hello.txt
文件.
myCommand
simply creates a directory in the root called param
and a hello.txt
file.
我可以使用 php artisan myCommand param1
很好地运行 myCommand
并且它按预期工作.我也可以使用 Artisan 的 tinker
命令并完美地运行 Artisan::call()
.
I can run myCommand
fine using php artisan myCommand param1
and it works as expected. I can also use Artisan's tinker
command and run Artisan::call()
perfectly fine too.
但是,当我通过访问 URL(例如 example.com/hook¶m=hello
)尝试该命令时,我的命令没有按预期创建任何内容.如果它也有帮助,我正在 Laravel Forge 上尝试这个.在我的本地开发机器上一切正常.
However when I try the command via visiting the URL (e.g. example.com/hook¶m=hello
), my command does not create anything as expected. If it helps as well, I'm trying this on Laravel Forge. On my local dev machine everything works fine.
知道出了什么问题吗?
您可以通过
chmod 777 -R /path/to/folder
绝对不应该做的事,因为每个人之后都可以编写和执行此目录中的所有内容
或者,我更喜欢的是,您创建一个新组,我们称之为用户组:
or, what I would prefer, you create a new group, let's call it usergroup:
sudo groupadd usergroup
现在组已经存在,添加两个用户:
Now that the group exists, add the two users to it:
sudo usermod -a -G usergroup <your username>
sudo usermod -a -G usergroup www-data
现在剩下的就是设置目录的权限了:
Now all that's left is to set the permissions on the directory:
sudo chgrp -R usergroup /path/to/the/directory
sudo chmod -R 770 /path/to/the/directory // <<<<<< change this to 775
现在只有用户组的成员才能读取、写入或执行目录中的文件和文件夹.注意 chmod
和 chgrp
命令的 -R
参数:这告诉它们递归到目标目录的每个子目录并修改每个文件和目录可用.
Now only members of the usergroup group can read, write, or execute files and folders within the directory. Note the -R
argument to the chmod
and chgrp
commands: this tells them to recurse into every sub directory of the target directory and modify every file and directory available.
如果您希望其他人能够读取文件,您可能还需要将 770 更改为 774,如果您希望其他人读取和执行文件,则为 775,等等.组分配更改将在用户退出并重新登录.
You may also want to change 770 to something like 774 if you want others to be able to read the files, 775 if you want others to read and execute the files, etc. Group assignment changes won't take effect until the users log out and back in.
在你的情况下,你肯定应该在之后将其更改为 775...
In your case, you should definately change it to 775 afterwards...
这篇关于设置用户权限 |Artisan 命令不会在代码中运行,但在命令行上运行良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!