iis PHP安装脚本 PHPInstall.vbs V3.1

所属分类: 脚本专栏 / vbs 阅读数: 872
收藏 0 赞 0 分享
复制代码 代码如下:

'/*=========================================================================
' * Intro PHP安装脚本,您所要做的操作是:保存这个文件与要安装的php文件夹放一起(不要放在C盘根目录下)
' * (当前版本php-5.2.5-Win32如果是其它请替换当前文档相关文件名),然后双击运行这个文件,<?phpinfo()?>
' * FileName PHPInstall.vbs
' * Author yongfa365
' * Version v3.1
' * MadeTime 2008-04-01 15:55:41
' * LastModify 2009-05-04 12:21:48
' *==========================================================================*/
Wscript.Echo "开始配置PHP"
phpinstall "php-5.2.5-Win32", "D:\PHP525", "C:"
'phpinstall "php所在目录","php要安装到哪","系统盘(如:C:)"

Function phpinstall(PHPFilePath, InstallPath, SystemPath)
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")

'WScript.Echo "删除C:\PHP"
FSO.DeleteFolder InstallPath
FSO.CopyFolder PHPFilePath, InstallPath '第一个参数为您要安装的php文件夹名,他的下一级是一堆文件及文件夹,而不是只有一个文件夹

'WScript.Echo "删除C:\Windows\system32\php5ts.dll及C:\Windows\system32\libmysql.dll,然后复制新的"
FSO.DeleteFile SystemPath & "\Windows\system32\php5ts.dll"
FSO.CopyFile InstallPath & "\php5ts.dll", SystemPath & "\Windows\system32\php5ts.dll"

FSO.DeleteFile SystemPath & "\Windows\system32\libmysql.dll"
FSO.CopyFile InstallPath & "\libmysql.dll", SystemPath & "\Windows\system32\libmysql.dll"

'MCrypt加密处理
FSO.DeleteFile SystemPath & "\Windows\system32\libmcrypt.dll"
FSO.CopyFile InstallPath & "\libmcrypt.dll", SystemPath & "\Windows\system32\libmcrypt.dll"

'WScript.Echo "读取C:\php\php.ini-dist内容到变量PHPStr"
PHPStr = FSO.OpenTextFile(InstallPath & "\php.ini-dist", 1, True).ReadAll

'WScript.Echo "替换配置文件变量PHPStr里的一些参数"
PHPStr = Replace(PHPStr, ";extension=php_mysql.dll", "extension=php_mysql.dll")
PHPStr = Replace(PHPStr, ";extension=php_gd2.dll", "extension=php_gd2.dll")
PHPStr = Replace(PHPStr, ";extension=php_mbstring.dll", "extension=php_mbstring.dll")
'PHPStr = Replace(PHPStr, ";extension=php_mssql.dll", "extension=php_mssql.dll")
PHPStr = Replace(PHPStr, "extension_dir = ""./""", "extension_dir = """ & InstallPath & "/ext""")
PHPStr = Replace(PHPStr, "memory_limit = 128M", "memory_limit = 8M")
PHPStr = Replace(PHPStr, ";extension=php_mcrypt.dll", "extension=php_mcrypt.dll")

PHPStr = Replace(PHPStr, ";session.save_path = ""/tmp""", "session.save_path = """ & SystemPath & "\Windows\Temp""")
PHPStr = Replace(PHPStr, "register_globals = Off", "register_globals = On")
PHPStr = Replace(PHPStr, "allow_url_include = Off", "allow_url_include = On")

'安全
PHPStr = Replace(PHPStr, "safe_mode = Off", "safe_mode = On")
PHPStr = Replace(PHPStr, "disable_functions =", "disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server")
'exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source,ini_alter
'system,exec,passthru,shell_exec,popen

'WScript.Echo "将修改后的配置文件变量PHPStr另存为:C:\Windows\php.ini"
FSO.CreateTextFile(SystemPath & "\Windows\php.ini", True).WriteLine PHPStr


Set IIsWebServiceObj = GetObject("IIS://localhost/W3SVC")

'WScript.Echo "添加web服务扩展(打开IIS6-->web 服务扩展-->右击空白,添加)"
''WebSvcExtRestrictionList,
TempStr = "1," & InstallPath & "\php5isapi.dll,1,php,php扩展"
For Each Str in IIsWebServiceObj.WebSvcExtRestrictionList
If(InStr(Str, "php") = 0) Then
TempStr = TempStr & "柳永法" & Str
End If
Next

IIsWebServiceObj.WebSvcExtRestrictionList = Split(TempStr, "柳永法")
IIsWebServiceObj.SetInfo

'WScript.Echo "添加应用程序扩展名映射(网站属性-->主目录-->配置-->映射-->添加)"
''ScriptMaps
TempStr = ".php," & InstallPath & "\php5isapi.dll,5,GET,HEAD,POST,DEBUG"
For Each Str in IIsWebServiceObj.ScriptMaps
If(InStr(Str, "php") = 0) Then
TempStr = TempStr & "柳永法" & Str
End If
Next

IIsWebServiceObj.ScriptMaps = Split(TempStr, "柳永法")
IIsWebServiceObj.SetInfo



'默认首页
'IIsWebServiceObj.DefaultDoc = "Index.htm,Index.html,Index.asp,Default.aspx,index.php,Default.htm,Default.asp"
'IIsWebServiceObj.SetInfo
If InStr(LCase(IIsWebServiceObj.DefaultDoc), "index.php") = 0 Then
IIsWebServiceObj.DefaultDoc = IIsWebServiceObj.DefaultDoc & ",index.php"
IIsWebServiceObj.SetInfo
End If

WScript.Echo "OK,php环境安装完成,为了对本程序作者:柳永法,表示感谢,请 大笑三声^_^"
End Function
更多精彩内容其他人还在看

用vbscript来添加ip策略 自动封IP

看过有网友介绍的方法,不过是手工一条一条地封,而攻击IP一般都是数千个不同的IP。用手工封IP的办法太麻烦。下面我们用程序来实现自动封这些IP!
收藏 0 赞 0 分享

vbs,hta中选择文件夹对话框实现代码

在vbs中选择文件夹可以直接调用系统的文件夹对话框
收藏 0 赞 0 分享

WMI 脚本高手不完全手册

要成为WMI脚本高手当要认识一下什么叫WMI啦,下面将介绍一下有关WMI的东西。
收藏 0 赞 0 分享

vbscript语句中“&amp;H”专用于16进制数表示

近段时间在做一个asp的项目,由于数据库里面的字段采用字母“h”开头,在sql语言时就出现了莫名其妙的错误,经过反复的检查,也没查出有错误的地方,整整给折腾了我一天的时间。
收藏 0 赞 0 分享

URL 筛选小工具 提取网页中的超链接地址

这个VBS是用来将一个本地网页中的URL筛选出来并保存在新的网页文件中。当然,只要改变里面的正则表达式,就可以作其他用途了。
收藏 0 赞 0 分享

VBScript 文件操作代码小结

下面是一些vbs下常用到的一些文件操作代码,整理了下方便以后开发使用,提高效率。
收藏 0 赞 0 分享

vbs 错误捕获器,用于捕获内部错误并进行手工处理

vbs中的错误捕获器,用于捕获内部错误并进行手工处理
收藏 0 赞 0 分享

查看SQL状态的vbs(检验SQL SERVER是否在这机器上工作 )

这篇文章主要介绍了查看SQL状态的vbs,主要检验SQL SERVER是否在这机器上工作,需要的朋友可以参考下
收藏 0 赞 0 分享

vbs 字符统计功能模块

TongJi()将上面代码保存为TongJi.vbs,在TongJi.vbs同目录下建立ok.txt文本文件,将你要统计的文本复制到ok.txt中,运行TongJi.vbs即可以统计字数,与word的功能一样。
收藏 0 赞 0 分享

重新安装ie的一个vbs

对于版本有点老,所以建议学习使用,不要随便直接运行。
收藏 0 赞 0 分享
查看更多