内容显示页
 
类别:ASP+VBS | 浏览(544) | 2009-5-3 18:57:33

'/*=========================================================================
' * Intro       PHP安装脚本,您所要做的操作是:保存这个文件与要安装的php文件夹放一起(不要放在C盘根目录下)
' *             (当前版本php-5.2.5-Win32如果是其它请替换当前文档相关文件名),然后双击运行这个文件,<?phpinfo()?>
' * FileName    PHPInstall.vbs
' * Author      yongfa365
' * Version     v3.1
' * WEB         http://www.yongfa365.com
' * Email       yongfa365@qq.com
' * FirstWrite  http://www.yongfa365.com/Item/PHPInstall.vbs.html
' * From        http://www.yongfa365.com/Item/PHPFirstInstall.vbs.html
' * 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

 


引用本页地址:http://www.yongfa365.com/item/PHPInstall.vbs.html
 
 
相关链接
 
网友评论:
1 ttplay - 2009-5-3 21:04:31
默认文档index.php没有加, 还有修改环境变量path比把php5ts.dll及libmysql.dll放system32更好吧?写了环境变量后可以在命令行执行php.

其实手工安装也很简单,解压到c:\php,修改环境变量path,将配置文件复制到windows,改几个参数,加服务扩展,应用扩展,修改默认文档,重启IIS.就可以了

最后,响应作者要求。
哈哈哈大笑三声

 
2 柳永法 - 2009-5-4 9:11:57
倒,手工太费劲了,下次还得找文档,这样一来,一键搞定。
你说的那个,index.php我没加,环境变量那个,整不进去,所以采用这种方法,
哈哈,还没正式用php只是配置环境,所以呀,在命令行执行,我还没想过。
 
3 ttplay - 2009-5-4 19:42:41
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
WshSysEnv.Item("Path")=WshSysEnv("Path") & ";" & InstallPath

应该可以成功
 
4 匿名网友 - 2009-5-4 21:50:16

shell呀,我系统优化时就已经把他去了,所以一般不考虑,过段时间写个winform的


不过还是谢谢啊

 
5 匿名网友 - 2009-5-8 6:02:05
哈哈哈,真是很棒!
 
6 玻璃钢格栅 - 2010-11-1 13:04:30
学习了
 
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片 看不清? 换张图试试
 
     
 
 
文章分类
 
 
.Net + C#(73)
 
 
ASP+VBS(161)
 
 
 
Linux(10)
 
 
 
web 2.0(26)
 
 
 
 
 
心程(68)
 
生活(97)
 
 
     

Power by :柳永法(yongfa365)'Blog  | 京ICP备07011491号  QQ:64049027  E-mail:64049027@qq.com yongfa365'CodePlex yongfa365'CodeGoogle

申请友情链接 要求:跟本站主题相类似正规网站,双方交换为首页位置

转载请注明来源,以便后人及时得到最新、修正、加强版!!!