本文致力于描述如何在Windows Server 2003下安装配置PHP环境时遇到的问题及解决。

环境说明:

  • 操作系统:Windows Server 2003 Computing Cluster Edition,英文版(由Microsoft支持)
  • 相关软件:Internet Information Services 6.0
  • PHP:PHP 5.2.6 zip package。(最新版下载地址

PHP装多了,闭着眼也能装好。于是今天早晨却遇到一个诡异的问题。
用了5分钟装好PHP之后,刷新IE,我的index.php里很简单,就是简单的phpinfo:
[code=’c#’]

[/code]
熟悉的界面并没有出来,取而代之是连不上服务器。也不是500内部服务器错误,因为如果是500,说明PHP没配置正确。这次很诡异,就是连不上服务器。是这个样子的:

[singlepic=18201,640,480]

Continue reading

本文致力于描述如何在Windows Server 2008下安装配置用于开发或产品的MySQL及PHP环境。

环境说明:

  • 操作系统:Windows Server 2008 Standard Edition,英文版(由Microsoft DreamSpark支持)
  • 相关软件:Internet Information Services 7.0
  • MySQL:MySQL 5.0.67, Windows Essentials (x86)。(最新版下载地址
  • PHP:PHP 5.2.6 zip package。(最新版下载地址

1. 安装MySQL

这似乎是一个波澜不惊的过程,任何人都能做好。
[singlepic=18162]
安装欢迎界面。
[singlepic=18163]
这一步选Custom自定义安装比较好,指定安装位置,建议安装在D盘,避开系统盘C盘。由于UAC的问题,在Vista和2008下,C盘的文件搞得很特殊,一些原来好好的程序,由于权限问题的存在,会出现莫名奇妙的故障。
Continue reading

Windows Server 2008是最新的Windows Server。Windows Server 2008公平地说还是相当不错的,性能和安全性都没有太大的问题,稳定更不用说。

这篇文章里,我会详细介绍如何在Windows Server 2008下,安装使用和配置IIS 7.0的FTP服务。

环境说明:

  • 操作系统:Windows Server 2008 Standard Edition,英文版(由Microsoft DreamSpark支持)
  • 相关软件:Internet Information Services 7.0

首先假定IIS已经安装好。如果不会安装IIS,请参阅其他文章。

1. 安装FTP服务

[singlepic=18135,640,462]

在Server Manager中右键Roles中Web Server(IIS),添加服务器角色(Add Role Service)

[singlepic=18136,640,481]

添加的是FTP Publishing Service,同时要添加其他两个依赖项。

2. 配置FTP服务

[singlepic=18137,640,514]

很遗憾地是,Windows Server 2008中,FTP服务仍然需要老版本IIS6的管理器来管理。在管理工具中打开(Internet Information Services(IIS)6.0 Manager),可以看到一个FTP站点。

[singlepic=18138]

FTP Site,如端口等如果不希望是TCP 21,那么在这里修改。

[singlepic=18139]

Security Accounts,这是一个很危险的选项,默认打开了匿名访问,一定记得关掉。

[singlepic=18141]

Home Directory,这里设置FTP的根目录和权限,以及FTP的目录的列表方式,为了兼容性,我设成了UNIX。

[singlepic=18145]

Messages,这里可以设置当用户被FTP禁止、连接、离开和达到最大连接数时收到的消息。

[singlepic=18142]

Directory Security,这里可以设置默认的访问方式,默认是允许所有访问,然后除去下列表中的例外。也可以按照计算机IP打开某些访问,而禁止所有其他的连接。

3. 添加FTP用户

[singlepic=18147,640,458]

在Windows FTP中,用户是Windows用户。要想添加一个FTP用户,必须添加一个Windows用户,然后去设权限。在Computer Management中,Local Users and Groups下的Users中添加一个普通Windows用户。

[singlepic=18146,640,458]

也许你会担心添加Windows用户会导致安全问题,比如可以远程桌面连接之类,其实不必。首先,添加的Windows用户是普通用户,这样在权限上低于管理员。其次,一个Windows用户要想远程桌面连接服务器,必须同时是Remote Desktop Users这个组的成员,新建用户默认不是的,所以用户不能连接系统。

[singlepic=18143,640,514]

在IIS6 Manager中,右键FTP Site,选择Permissions,把刚才添加的用户赋予FTP权限。其实就是Add,然后找到刚才的用户,然后添加进列表,赋予相应的权限即可。
到这里,常规的FTP就可以连接了。

4. 高级应用——如何开启Passive Mode

主流的FTP客户端一般首选Passive Mode去连接FTP服务器,而Windows默认是不允许的。这样的后果就是在FTP客户端登陆时,可以看到通过了用户名密码认证,在列目录时卡住,不能进行。但是使用PORT Mode则可以连接。其实是可以解决的。方法如下:

[singlepic=18148,640,451]

首先,在IIS6 Manager中,右键整个计算机节点,选择属性。

[singlepic=18149]

然后打开Enable Direct Metabase Edit,允许在IIS运行中改变其配置。

[singlepic=18136,640,481]

然后安装IIS 6.0的脚本工具,默认是不安装的,不安装,则在C盘inetpub中就找不到AdminScripts这个文件夹,因为我们需要AdminScripts下的adsutil.vbs这个脚本。安装方法同添加FTP服务,只不过这次需要勾选“IIS 6 Scripting Tools”,同样有几个依赖项需要安装。

[singlepic=18150]

打开一个命令行(Command Prompt),注意,如果你不是Administrator帐户登陆Windows Server 2008,需要邮件使用“Run as administrator”打开,否则权限不足,会提示:

[code=’c#’]
Permission denied
Err Number: 70 (0x46)
Error Trying To Get the Object: MSFTPSVC
[/code]

正常打开后,输入这条命令:

[code=’c#’]CSCRIPT.exe C:\Inetpub\AdminScripts\adsutil.vbs set /MSFTPSVC/PassivePortRange “5500-5515″[/code]

这样可以允许FTP服务在5500到5515这16个端口中选择端口,供FTP客户端使用。需要说明的是,FTP Passive Mode合法的端口号是从5100到65535,但是都打开是明显不安全的,这个参数要根据你的服务器的并发连接数适当选择。

[singlepic=18151]

执行成功会显示:

[code=’c#’]
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

PassivePortRange : (STRING) “5500-5515”
[/code]
如果你的防火墙是关闭的,那就结
束了,可以在FTP客户端使用FTP Passive Mode连接了。

5. 高级应用——配置Windows Firewall with Advanced Security

[singlepic=18152,640,477]

Windows Server 2008默认配置并打开了Windows Firewall with Advanced Security这个高级Windows防火墙,很好很强大。我们刚才设置的16个端口,现在还通不过防火墙,必须加以配置。
下面开启5500到5515这16个端口的入站操作,也可以作为目的是打开某个端口的配置Windows Firewall with Advanced Security的一般方法。
Windows Firewall with Advanced Security区分Inbound Rules和Outbound Rules,分别对应入站和出站规则。FTP Passive Mode的实质其实是FTP Server选取一个没人(其他FTP客户)占用的端口,然后返还给你的FTP客户端,然后FTP客户端使用这个端口去连接FTP服务,这样可以提高并发连接数及并发连接性能。FTP Passive Mode对服务器来说是一种入站操作。
首先打开Windows Firewall with Advanced Security,然后在Inbound Rules上右键建立新的规则(New Rule)

[singlepic=18153,720,512]

在New Inbound Rule Wizard向导的Rule Type中选择Port,因为我们要配置TCP端口。

[singlepic=18154,720,512]

第二步Protocol and Ports中选择TCP端口,因为FTP属于TCP。下面选择Specific local ports指定特定端口,不要全部打开,否则防火墙变成李雷雷了。
遗憾地是,Windows Firewall with Advanced Security不能使用类似5500-5515的IP段(IP Address Range)表达式。不知道这是出于什么考虑,作为微软技术支持者,我不理解为低下的用户体验,而善意地理解为为了避免管理员图方便打开不必要的端口。因此你必须手工填入这16个端口,并用英文逗号分割。

[singlepic=18155,720,512]

Action中决定,对于前面选择的目标,Windows Firewall with Advanced Security采取何种操作。因为FTP是普通应用,不带安全选项,这里选择Allow the connection。

[singlepic=18156,720,512]

Profile中,可以指定连接来源类型,这是在其他防火墙中少见的一层,可以按照Domain,Private和Public来选择,Domain只允许当前AD中的连接,Private只允许本地网络的连接,Public则是所有连接。不用说,安全性又提高不少。

[singlepic=18157,720,512]

Name中,给这条规则取个名字和描述。将来管理方便,不至于在列表里找不到。

[singlepic=18159,640,477]

我们刚才做了什么?允许5500-5515这16个端口的入站连接。还是很不安全的,因为如果一个端口被打开,而没有相应的监听程序,属于一个安全漏洞。理想的状态是,给这条规则指定程序,指定到Windows FTP的服务。可惜我试了多次不能找到FTP的程序到底是哪一个(本来以为是C:\Windows\system32\inetsrv\inetinfo.exe,因为服务是启动了这一个。也不能只指定到FTP Publishing Service这个服务,连接不上)。
选择刚才添加规则的属性。

[singlepic=18160]

在Programs and Services中,选择Services Settings。

[singlepic=18161]

理想的情况应该是Apply to this service中选中FTP Publishing Service,这样就完美了。可惜这样其实连不上。无奈我只好选择了Apply to services only,只允许到系统服务。这样,除非另一个恶意程序把自己注册为系统服务来监听5500到5515这16个端口,其他普通程序是不可以的,安全性稍微提高了一些。
如此,一个完整的Windows Server 2008下IIS 7.0的FTP(支持Passive Mode)就建立起来了。

本文图片使用Nocoo.Tools提供的工作窗口截图工具ScreenCapture截取。

今天释出的KB958644号紧急更新,引起了我不小的兴趣,很希望知道到底是什么东西导致微软捅了这么大的篓子呢?无奈,因为出品公司(微软)承认这是一个严重的安全漏洞,提出问题的网站(http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4250)已经去除了关于此漏洞的详细说明。这条路不通了。
MS08-067(http://support.microsoft.com/?kbid=958644)描述了什么样的系统里具体什么样的文件会出问题。从中可以看到,主要问题出在Netapi32.dll这个DLL。可以看出,自Microsoft Windows 2000 Service Pack 4(不是说之前的就没有,而是只从SP4开始技术支持)开始的5.0.2195.7203版本的Netapi32.dll,直到Windows Vista、Windows Server 2008甚至Windows 7 Pre-Beta的6.1.6801.4106版本Netapi32.dll都逃脱不了噩运。
重要的提示来自Microsoft Security Bulletin MS08-067 – Critical(Vulnerability in Server Service Could Allow Remote Code Execution (958644))一文。文中特别指出,这个漏洞如此广泛,甚至Windows Server 2008的Server Core installation也会受到同样安全威胁等级的威胁。这说明,这个漏洞存在很基础的地方。
Server Core installation是Server功能的极小集,根据Compare Server Core Installation Options一文,Server Core installation可以安装以下功能:

  • Active Directory Domain Services
  • Active Directory Lightweight Directory Services
  • DHCP Server
  • DNS Server
  • File Services
  • Hyper-V
  • Print Services
  • Web Services (IIS) without ASP.NET

鉴于Windows 2000也是受害者,因此不可能是Active Directory Lightweight Directory Services和Hyper-V的问题。
Server Core Functions by DLL一文给出了netapi32.dll的详细功能说明。
我不辞辛苦地把提到的API函数进行Google,存在漏洞的API肯定是存在在Windows 2000以来所有版本Windows中的,例如DsGetDcCloseW这样的API,微软文档声称“Client:Requires Windows Vista or Windows XP,Server:Requires Windows Server 2008 or Windows Server 2003.”,因此不可能是与漏洞有关。
剩下的可疑的Windows API有这些:

  • netapi32.dll DsAddressToSiteNamesA
  • netapi32.dll DsAddressToSiteNamesExA
  • netapi32.dll DsAddressToSiteNamesExW
  • netapi32.dll DsAddressToSiteNamesW
  • netapi32.dll DsDeregisterDnsHostRecordsA
  • netapi32.dll DsDeregisterDnsHostRecordsW
  • netapi32.dll DsEnumerateDomainTrustsA
  • netapi32.dll DsEnumerateDomainTrustsW
  • netapi32.dll DsGetDcNameA
  • netapi32.dll DsGetDcNameW
  • netapi32.dll DsGetDcOpenA
  • netapi32.dll DsGetDcOpenW
  • netapi32.dll DsGetDcSiteCoverageA
  • netapi32.dll DsGetDcSiteCoverageW
  • netapi32.dll DsGetSiteNameA
  • netapi32.dll DsGetSiteNameW
  • netapi32.dll DsMergeForestTrustInformationW
  • netapi32.dll DsRoleFreeMemory
  • netapi32.dll DsRoleGetPrimaryDomainInformation
  • netapi32.dll NetApiBufferAllocate
  • netapi32.dll NetApiBufferFree
  • netapi32.dll NetApiBufferReallocate
  • netapi32.dll NetApiBufferSize
  • netapi32.dll NetConnectionEnum
  • netapi32.dll NetDfsAdd
  • netapi32.dll NetDfsAddFtRoot
  • netapi32.dll NetDfsAddStdRoot
  • netapi32.dll NetDfsAddStdRootForced
  • netapi32.dll NetDfsEnum
  • netapi32.dll NetDfsGetClientInfo
  • netapi32.dll NetDfsGetInfo
  • netapi32.dll NetDfsRemove
  • netapi32.dll NetDfsRemoveFtRoot
  • netapi32.dll NetDfsRemoveStdRoot
  • netapi32.dll NetDfsSetClientInfo
  • netapi32.dll NetDfsSetInfo
  • netapi32.dll NetFileClose
  • netapi32.dll NetFileEnum
  • netapi32.dll NetFileGetInfo
  • netapi32.dll NetGetAnyDCName
  • netapi32.dll NetGetDCName
  • netapi32.dll NetGetDisplayInformationIndex
  • netapi32.dll NetGetJoinableOUs
  • netapi32.dll NetGetJoinInformation
  • netapi32.dll NetGroupAdd
  • netapi32.dll NetGroupAddUser
  • netapi32.dll NetGroupDel
  • netapi32.dll NetGroupDelUser
  • netapi32.dll NetGroupEnum
  • netapi32.dll NetGroupGetInfo
  • netapi32.dll NetGroupGetUsers
  • netapi32.dll NetGroupSetInfo
  • netapi32.dll NetGroupSetUsers
  • netapi32.dll NetLocalGroupAdd
  • netapi32.dll NetLocalGroupAddMembers
  • netapi32.dll NetLocalGroupDel
  • netapi32.dll NetLocalGroupDelMembers
  • netapi32.dll NetLocalGroupEnum
  • netapi32.dll NetLocalGroupGetInfo
  • netapi32.dll NetLocalGroupGetMembers
  • netapi32.dll NetLocalGroupSetInfo
  • netapi32.dll NetLocalGroupSetMembers
  • netapi32.dll NetQueryDisplayInformation
  • netapi32.dll NetRemoteComputerSupports
  • netapi32.dll NetRemoteTOD
  • netapi32.dll NetRenameMachineInDomain
  • netapi32.dll NetScheduleJobAdd
  • netapi32.dll NetScheduleJobDel
  • netapi32.dll NetScheduleJobEnum
  • netapi32.dll NetScheduleJobGetInfo
  • netapi32.dll NetServerComputerNameAdd
  • netapi32.dll NetServerComputerNameDel
  • netapi32.dll NetServerDiskEnum
  • netapi32.dll NetServerEnum
  • netapi32.dll NetServerGetInfo
  • netapi32.dll NetServerSetInfo
  • netapi32.dll NetServerTransportAdd
  • netapi32.dll NetServerTransportAddEx
  • netapi32.dll NetServerTransportDel
  • netapi32.dll NetServerTransportEnum
  • netapi32.dll NetSessionDel
  • netapi32.dll NetSessionEnum
  • netapi32.dll NetSessionGetInfo
  • netapi32.dll NetShareAdd
  • netapi32.dll NetShareCheck
  • netapi32.dll NetShareDel
  • netapi32.dll NetShareEnum
  • netapi32.dll NetShareGetInfo
  • netapi32.dll NetShareSetInfo
  • netapi32.dll NetStatisticsGet
  • netapi32.dll NetUnjoinDomain
  • netapi32.dll NetUseAdd
  • netapi32.dll NetUseDel
  • netapi32.dll NetUseEnum
  • netapi32.dll NetUseGetInfo
  • netapi32.dll NetUserAdd
  • netapi32.dll NetUserChangePassword
  • netapi32.dll NetUserDel
  • netapi32.dll NetUserEnum
  • netapi32.dll NetUserGetGroups
  • netapi32.dll NetUserGetInfo
  • netapi32.dll NetUserGetLocalGroups
  • netapi32.dll NetUserModalsGet
  • netapi32.dll NetUserModalsSet
  • netapi32.dll NetUserSetGroups
  • netapi32.dll NetUserSetInfo
  • netapi32.dll NetValidatePasswordPolicy
  • netapi32.dll NetWkstaGetInfo
  • netapi32.dll NetWkstaSetInfo
  • netapi32.dll NetWkstaTransportAdd
  • netapi32.dll NetWkstaTransportDel
  • netapi32.dll NetWkstaTransportEnum
  • netapi32.dll NetWkstaUserEnum
  • netapi32.dll NetWkstaUserGetInfo
  • netapi32.dll NetWkstaUserSetInfo

接下来只能猜了…
基于以上各点线索,猜测KB958644特大漏洞的原理可能是以下:

  • 文件共享及发现(共享打印机等)
  • Active Directory目录服务

我们的域还比较小,只有几十个人,不到100台工作站和服务器。
昨天忽然想到不能马虎啊,再小的域早晚也有崩溃的时候,需要备份下域控制器吧。
网上去搜索,如何备份Windows Server的域控制器,或者如何建立Windows Server的备份域控制器,出乎我意料的是,无果…

在另一台IBM x3200上尝试建立另一个域,建立Additional Domain Controller。跟着提升一步步执行下去,然后重启,10分钟之后就建好了。怪不得搜不到结果,原来是因为这个过程如此之简单,根本用不着笔墨去谈这个问题…

不过,重启之后发现我们的SQL Server服务没能够自动启动起来(用作备份域服务器的本是一台数据库服务器),出现这个错误:

Error 1069:The service did not start due to a logon failure.
错误 1069:由于登录失败而无法启动服务

原因
SQL Server、SQL Agent 或 SQL Server Executive 启动服务帐户的密码不正确,因为密码可能已被更改了。
替代方法
若要解决此问题,请在 SQL Server 主机的 Microsoft SQL Server 服务帐户中键入正确的密码。
若要在 Microsoft Windows 2000 Server 和 Microsoft Windows XP 中更正该密码,请按照下列步骤操作:

  • 单击开始,指向设置,然后单击控制面板。
  • 双击管理工具,然后双击服务。
  • 双击 MSSQLSERVER,然后单击登录选项卡。
  • 在密码和确认密码文本框中键入正确的密码,然后单击确定。

双击MSSQLSERVER,在Log on里重新输入了一下域管理员密码,就可以启动了。这个很奇怪,因为我并没更改过密码。我的猜想,可能是因为机器本机也成为了域控制器,登陆的时候验证工作转移到本机了,因此原来的配置需要更新一下吧。