quot;.").replace("\\","/") + "/php/php.ini", "w")
for line in f5:
if '''extension_dir = "ext"''' in line:
line = """extension_dir = "ext"\n"""
elif """;extension=php_mysql.dll""" in line:
line = """extension=php_mysql.dll\n"""
elif """;extension=php_mysqli.dll""" in line:
line = """extension=php_mysqli.dll\n"""
elif """;extension=php_pdo_mysql.dll""" in line:
line = """extension=php_pdo_mysql.dll\n"""
else:
line = line
f6.write(line)
f6.close()
f3 = open(os.path.abspath(".").replace("\\","/") + "/mysql/my-default.ini", "r").readlines()
f4 = open(os.path.abspath(".").replace("\\","/") + "/mysql/my.ini", "w")
for line in f3:
if "basedir" in line:
line = "basedir = %s\n" % (os.path.abspath(".").replace("\\","/") + "/mysql")
elif "datadir" in line:
line = "datadir = %s\n" % (os.path.abspath(".").replace("\\","/") + "/mysql/data")
elif "port" in line:
line = "port = 3306\n"
else:
line = line
f4.write(line)
f4.write("""# 服务端的编码方式
character-set-server = utf8
[client]
#客户端编码方式,最好和服务端保存一致
loose-default-character-set = utf8""")
f4.close()
s = os.path.abspath(".").replace("\\","/") + "/mysql/bin/mysqld.exe --remove mysql"
os.system(s)
s = os.path.abspath(".").replace("\\","/") + "/mysql/bin/mysqld.exe --install mysql"
os.system(s)
os.system("net stop mysql & net start mysql & pause")
if os.path.exists(pathname + "/conf/httpd.conf.bak"):
os.remove(pathname + "/conf/httpd.conf")
#os.rename(pathname + "/conf/httpd.conf.bak", pathname + "/conf/httpd.conf")
else:
os.rename(pathname + "/conf/httpd.conf", pathname + "/conf/httpd.conf.bak")
f = open(pathname + "/conf/httpd.conf.bak", "r").readlines()
f2 = open(pathname + "/conf/httpd_new.conf", "w")
#改变appache路径
for line in f:
if 'c:/Apache24' in line:
#line = "#"+line+"\n"+"ServerRoot "+os.path.abspath(".").replace("\\","/")+"/"+pathname
line = line.replace("c:/Apache24", os.path.abspath(".").replace("\\","/")+"/"+pathname)
#多个站点设置上级目录(这里直接写成根目录)
line = line.replace("Apache24/htdocs", "")
elif '<IfModule unixd_module>' in line:
s_temp = """# php5 support
LoadModule php5_module "%s/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .html .htm
# configure thepath to php.ini
PHPIniDir "%s/php"
""" % |