(os.path.abspath(".").replace("\\","/"), os.path.abspath(".").replace("\\","/"))
if os.path.exists(os.path.abspath(".").replace("\\","/")+"/php/php5apache2_4.dll"):
line = s_temp + line;
else:
print("###ERROR:Can not find "+os.path.abspath(".").replace("\\","/")+"/php/php5apache2_4.dll")
#这里是多个站点设置
elif 'mod_vhost_alias.so' in line:
line = line.replace("#","")
#这里是多个站点设置
elif 'httpd-vhosts.conf' in line:
line = line.replace("#","")
else:
line = line
f2.write(line);
f2.close()
#将apache24添加到服务
s = os.path.abspath(".").replace("\\","/")+"/"+pathname+'/bin/httpd.exe -k uninstall -n "Apache24"'
os.system(s)
s = os.path.abspath(".").replace("\\","/")+"/"+pathname+'/bin/httpd.exe -k install -n "Apache24"'
os.system(s)
print (s)
os.rename(pathname + "/conf/httpd_new.conf", pathname + "/conf/httpd.conf")
f = open(pathname + "/conf/extra/httpd-vhosts.conf", "a")
f.write("""
<VirtualHost *:80>
DocumentRoot "%swww_1_com"
ServerName www.1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "%swww_2_com"
ServerName www.2.com
</VirtualHost>
""" % (os.path.abspath(".").replace("\\","/"), os.path.abspath(".").replace("\\","/")))
os.mkdir("%swww_1_com" % os.path.abspath("."))
os.mkdir("%swww_2_com" % os.path.abspath("."))
os.system("net stop apache24 & net start apache24 & pause")
if __name__ == "__main__":
mo = Moments();
mo.configApache24("Apache24");
print "请修改hosts 127.0.0.1 www.1.com"
print "请修改hosts 127.0.0.1 www.2.com"
os.system("net stop apache24 & net start apache24 & pause")
|