Skip to content

Instantly share code, notes, and snippets.

@vibbow
Created April 21, 2014 00:12
Show Gist options
  • Save vibbow/11128729 to your computer and use it in GitHub Desktop.
Save vibbow/11128729 to your computer and use it in GitHub Desktop.
Ubuntu /var/www 目录权限修复脚本
<?php
$path = '/var/www';
`chown -R www-data:www-data {$path}`;
`chown root:root {$path}`;
mod_dir($path);
function mod_dir($path) {
$files = scandir($path);
foreach ($files as $file) {
if ($file == '.' || $file == '..')
continue;
$file_path = "{$path}/{$file}";
if (is_dir($file_path)) {
chmod($file_path, 0755);
mod_dir($file_path);
} else {
chmod($file_path, 0644);
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment