bash 使所有 PHP 文件可执行(递归)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4539470/
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
Making executable all PHP files (recursively)
提问by usr-local-ΕΨΗΕΛΩΝ
I just downloaded MediaWiki software on my server for installation. After decompressing it, I noticed that PHP files were not executable.
我刚刚在我的服务器上下载了 MediaWiki 软件进行安装。解压后,我发现 PHP 文件不可执行。
I ran chmod +x *.php*(there are also .php5 files) but it didn't work in subdirectories.
我运行了 chmod +x *.php*(也有 .php5 文件),但它在子目录中不起作用。
How can I add the executable flag to all PHP scripts inside the MediaWiki folder recursively scanning the subfolders?
如何将可执行标志添加到 MediaWiki 文件夹内的所有 PHP 脚本以递归方式扫描子文件夹?
Thank you in advance.
先感谢您。
回答by shfx
Use bash in the MediaWiki directory
在 MediaWiki 目录中使用 bash
find . -iname "*.php" | xargs chmod +x
回答by philonous
It does not work in subdirectories, because *.php*does not match any directories and hence does not include it.
它在子目录中*.php*不起作用,因为不匹配任何目录,因此不包含它。
Therefore you should use something like find ./ -iname "*.php*" -exec chmod 755 {} \;with the respective bits to set.
因此,您应该使用类似find ./ -iname "*.php*" -exec chmod 755 {} \;的内容来设置相应的位。

