找回密码
 开放注册

QQ登录

只需一步,快速开始

微信登录

微信扫码,快速开始

搜索
查看: 1029|回复: 1

php安装脚本 PHPFirstInstall.vbs

[复制链接]

28

主题

849

回帖

1193

牛毛

二级牛人

我愿意努力

积分
1193
发表于 2008-8-4 19:57:53 | 显示全部楼层 来自 浙江省温州市
看不太懂哦

739

主题

468

回帖

4307

牛毛

论坛管理员

狼群

积分
4347
 楼主| 发表于 2008-8-2 12:22:36 | 显示全部楼层 |阅读模式
'/*=========================================================================
' * Intro PHP安装脚本,您所要做的操作是:保存这个文件与要安装的php文件夹放一起(不要放在C盘根目录下)
&#39; * (当前版本php-5.2.5-Win32如果是其它请替换当前文档相关文件名),然后双击运行这个文件,<?phpinfo()?>
&#39; * FileNamePHPFirstInstall.vbs
&#39; * Author黑狼
&#39; * Version v2.0
&#39; * WEB http://www.lang2008.cn
&#39; * Email zhy8888[at]vip.qq.com
&#39; * FirstWritehttp://www.lang2008.cn/blog/article/131.htm
&#39; * MadeTime2008-06-01 10:00:00
&#39; * LastModify2008-08-01 15:55:41
&#39; *==========================================================================*/
Wscript.Echo \"开始配置PHP\"
phpinstall \"php-5.2.5-Win32\", \"C:\\PHP\", \"C:\"
&#39;phpinstall \"php所在目录\",\"php要安装到哪\",\"系统盘(如:C:)\"

Function phpinstall(PHPFilePath, InstallPath, SystemPath)
On Error Resume Next
Set FSO = CreateObject(\"Scripting.FileSystemObject\")
&#39;添加环境变量,本来是想把PHP目录加到环境变量Path里,这样就不用复制文件了,试了下不成功,故注释掉
&#39;const HKEY_LOCAL_MACHINE = &H80000002
&#39;Set oreg=GetObject(\"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default:StdRegProv\")
&#39;strKeyPath = \"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\"
&#39;strValueName = \"Path\"
&#39;oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
&#39;strValue=strValue & \";\" & InstallPath
&#39;oReg.SetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

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

&#39;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\"

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

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

&#39;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\")
&#39;PHPStr = Replace(PHPStr, \";extension=php_dbase.dll\", \"extension=php_dbase.dll\")
&#39;PHPStr = Replace(PHPStr, \";extension=php_ldap.dll\", \"extension=php_ldap.dll\")
&#39;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\")

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



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

&#39;WScript.Echo \"添加web服务扩展(打开IIS6-->web 服务扩展-->右击空白,添加)\"
&#39;&#39;WebSvcExtRestrictionList,
IISWebServiceObj.AddExtensionFile InstallPath & \"\\php5isapi.dll\", True, \"php\", True, \"php\"
IIsWebServiceObj.SetInfo

&#39;WScript.Echo \"添加应用程序扩展名映射(网站属性-->主目录-->配置-->映射-->添加)\"
&#39;&#39;ScriptMaps
ArgScriptMap = \".php,\" & InstallPath & \"\\php5isapi.dll,5,GET,HEAD,POST,DEBUG\"
NewScriptMaps = IIsWebServiceObj.ScriptMaps
ReDim preserve NewScriptMaps(UBound(NewScriptMaps) + 1)
NewScriptMaps(UBound(NewScriptMaps)) = ArgScriptMap
IIsWebServiceObj.ScriptMaps = NewScriptMaps
IIsWebServiceObj.SetInfo

WScript.Echo \"OK,php环境安装完成,
您需要登录后才可以回帖 登录 | 开放注册

本版积分规则

帮助|Archiver|小黑屋|通信管理局专项备案号:[2008]238号|NB5用户社区 ( 皖ICP备08004151号;皖公网安备34010402700514号 )

GMT+8, 2025-1-13 13:30 , Processed in 0.117797 second(s), 26 queries , Yac On.

Powered by Discuz! X3.5

快速回复 返回顶部 返回列表