-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake.php
More file actions
39 lines (37 loc) · 1.12 KB
/
make.php
File metadata and controls
39 lines (37 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
$s="#GENERATED BY make.php AT ".date("Y-m-d H:i:s").".\n#@author:Liu Guangfeng\n#@email:[email protected]\n\nNameVirtualHost *:80\n";
$dir=opendir(".");
$i=0;
$owners=array();
while(($owner=readdir($dir))!==false){
if(is_dir($owner)&&$owner!="."&&$owner!=".."&&$owner!="xampp"&&$owner!="webalizer"){
$owners[]=$owner;
}
}
unset($owner);
sort($owners);
foreach($owners as $owner){
//so i go to your dir.
$yourdir=opendir($owner);
$s.="\n########for {$owner}\n";
while(($site=readdir($yourdir))!==false){
if(is_dir($owner."/".$site)&&$site!="."&&$site!=".."){
$i++;$realpath=realpath(".") ."/{$owner}/{$site}";
$s.=<<<EOF
<VirtualHost *:80>
ServerAdmin admin@{$site}
DocumentRoot "{$realpath}"
ServerName {$site}
ServerAlias www.{$site}
ErrorLog "logs/{$site}-error.log"
CustomLog "logs/{$site}-access.log" combined
</VirtualHost>
EOF;
}
}
}
file_put_contents("/opt/lampp/etc/extra/httpd-vhosts.conf",$s);
echo "i found {$i} sites in total\n开始重启apche。。。\n";
exec("/opt/lampp/lampp restartapache",$out);
foreach($out as $v)echo $v."\n";
?>