如何修复在 Laravel 项目中运行 vendor/bin/phpunit 时权限被拒绝的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38521329/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix permission denied while running vendor/bin/phpunit in a laravel project
提问by Jin Aazoe
Whenever I execute vendor/bin/phpunit
in root path of my laravel project, it gives back a Permission deniederror. How can I fix this problem?
每当我vendor/bin/phpunit
在 laravel 项目的根路径中执行时,它都会返回一个Permission denied错误。我该如何解决这个问题?
Important: I don't want to use composer update
or delete some or all the vendor/
dir then use composer install
as these methods will change too much files, which my master will not agree.
重要提示:我不想使用composer update
或删除部分或全部vendor/
目录然后使用,composer install
因为这些方法会更改太多文件,我的主人不会同意。
ps: lrwxrwxrwx 1 work work 26 Jul 21 07:10 phpunit -> ../phpunit/phpunit/phpunit
-rwxrwxrwx 1 work work 1199 Jul 22 08:19 ./vendor/phpunit/phpunit/phpunit
ps:lrwxrwxrwx 1 work work 26 Jul 21 07:10 phpunit -> ../phpunit/phpunit/phpunit
-rwxrwxrwx 1 work work 1199 Jul 22 08:19 ./vendor/phpunit/phpunit/phpunit
and chmod 775 -R vendor
doesn't work.
并且 chmod 775 -R vendor
不起作用。
回答by Julio Garcés Teuber
What you should do is call with php:
你应该做的是用php调用:
$ php ./vendor/bin/phpunit
PHPUnit 4.8.35 by Sebastian Bergmann and contributors.
I get the same error tying to execute it without php interpreter:
我在没有 php 解释器的情况下执行它时遇到了同样的错误:
$ ./vendor/bin/phpunit
bash: ./vendor/bin/phpunit: Permission denied
Hope this helps you.
希望这对你有帮助。
回答by Babatunde Adeyemi
You can solve this by updating the Vagrantfile of your setup, particularly the fmode
of your web root synced_folder
folder.
您可以通过更新您的设置的 Vagrantfile 来解决这个问题,尤其fmode
是您的 web 根synced_folder
文件夹。
Change:
改变:
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777", "fmode=666"]
to :
到 :
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777", "fmode=777"]
For scotch-box,
对于苏格兰威士忌,
Change:
改变:
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
to :
到 :
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=777"]
After doing this, reload your configuration:
执行此操作后,重新加载您的配置:
$ vagrant reload
回答by Robertme
Deleting the vendor
folder and doing composer install
worked for me.
删除vendor
文件夹并composer install
对我来说有效。
回答by Poiz
Try and open your terminal and issue the command: The 1st one with the -R Flag means change permission also for sub-directories -Recursive
尝试并打开您的终端并发出以下命令:一日一用-r标志意味着变更许可也为子目录- [R ecursive
sudo chmod 777 -R PATH_TO/vendor
sudo chmod 777 PATH_TO/vendor/phpunit/phpunit
sudo chmod 777 PATH_TO/vendor/phpunit/phpunit/phpunit && chmod +x PATH_TO/vendor/phpunit/phpunit/phpunit
回答by Maksim Ivanov
What you see in the vendor/bin
directory is symlinks. Symlinks might have the right permissions, but the files they are pointing to might not. Ensure that both symlinks and the files they are pointing to have the execute (x
) bit on.
您在vendor/bin
目录中看到的是symlinks。符号链接可能具有正确的权限,但它们指向的文件可能没有。确保符号链接和它们指向的文件都x
启用了执行 ( ) 位。
# symlink
sudo chmod 0775 vendor/bin/phpunit
# the actual executable
sudo chmod 0775 vendor/phpunit/phpunit/phpunit