全程记录 Server Core 上部署 II7 + PHP FastCGI + MySQL
前言:
近段时间由于网站服务器断电而出现一系列问题,让人感到很是郁闷!虽然目前 Blog 能够正常运转,但是效率明显降低很多。于是萌发将系统升级到 Windows Server 2008 平台的想法,这几天一直都在做 Windows Server 2008 和 IIS7 的评估测试,收获颇丰!不敢独享,特以大家都很关注的 Server Core 为中心,撰写此篇关于在 Server Core 上部署 IIS7、PHP FastCGI 和 MySQL 的 Blog 与大家一同学习分享。同时也希望大家能参与讨论。之所以拿 Server Core 来讲,我个人感觉非常有代表性,而且在部署过程中通过相对复杂的命令行反而更能深入地了解和认识 Server Core 与 IIS7 的特性和相关知识。
目标:
此次部署过程将使大家详细了解如何在一台全新安装的 Windows Server 2008 Web Edition Server Core (以下简称:WS08WebCore)上部署以 IIS7 为 Web 平台的 PHP + MySQL 服务器,同时会向大家展现如何修改服务器名称、分配静态IP、开启远程桌面、在防火墙上开启远程桌面支持、开启自动更新、安装 II7、安装配置 PHP FastCGI 以及 安装 MySQL 的全部过程。
涉及到的关键词:Windows Server 2008 Web,Server Core,IIS7,FastCGI,PHP,Netsh,Scregedit.wsf,Pkgmgr,Ocsetup,Oclist,Appcmd
测试环境:
宿主:
ThinkPad X60 1706-BM8:T7200/2G*2/120G/3945ABG/Windows Vista Ultimate with SP1
虚拟机平台:Virtual PC 2007 with SP1
虚拟机:Windows Server 2008 Web Edition Server Core,分配 512M 内存和 20G VHD,桥接到宿主3945ABG,开启VT支持
Step By Step :
安装 WS08WebCore 的过程就不再复述,对于新一代操作系统的安装过程所体现出的特性,相信不少朋友与我有一样的认可度。
在开始之前我们先来了解并确定一些信息!根据新加坡
StreetDirectory.com 网站的数据了解到他们在 WS08 发布之际就已经开始在测试评估该产品,并取得了让人为之兴奋的成果,经过他们的实际评估,在 WS08 的 IIS7 上以 FastCGI 方式运行 PHP 的效率远远高出原生的 LAMP 环境,而这个数据着实的让人为之震惊和兴奋!足足的高出一倍还多——130%!注意这个数据是在没有进行任何优化的情况下得到的。如果这个数据还不能让你振奋,你现在就可以打开该网站亲身体验一下最终的效果。

启动我事先安装好的 WS08WebCore,键入帐号密码进入系统操作界面!

一套全新的系统,在部署运营程序之前,我想还是应该先为其命名一个简单而又易于标注的计算机名。重新命名前,我们可以使用“hostname”命令来获取当前的计算机名。之后,使用“netdom renamecomputer . /newname:web-core”,依照提示键入“Y”,最后使用“shutdown -r -t 0”重新启动计算机使其新命名生效。使用“netdom renamecomputer help”可以获得详细参数说明。




Use the listed update names with Ocsetup.exe to install/uninstall a server role or optional feature.
Adding or removing the Active Directory role with OCSetup.exe is not supported. It can leave your server in an unstable state. Always use DCPromo to install or uninstall Active Directory.
===========================================================================
Microsoft-Windows-ServerCore-Package
Not Installed:BitLocker
Not Installed:BitLocker-RemoteAdminTool
Not Installed:IIS-WebServerRole
|
|--- Not Installed:IIS-FTPPublishingService
| |
| |--- Not Installed:IIS-FTPServer
| |
|
|
|--- Not Installed:IIS-WebServer
| |
| |--- Not Installed:IIS-ApplicationDevelopment
| | |
| | |--- Not Installed:IIS-ASP
| | |
| | |
| | |--- Not Installed:IIS-CGI
| | |
| | |
| | |--- Not Installed:IIS-ISAPIExtensions
| | | |
| | | |--- Not Installed:IIS-ASP
| | | |
| | |
| | |
| | |--- Not Installed:IIS-ISAPIFilter
| | |
| | |
| | |--- Not Installed:IIS-ServerSideIncludes
| | |
| |
| |
| |--- Not Installed:IIS-CommonHttpFeatures
| | |
| | |--- Not Installed:IIS-DefaultDocument
| | |
| | |
| | |--- Not Installed:IIS-DirectoryBrowsing
| | |
| | |
| | |--- Not Installed:IIS-HttpErrors
| | |
| | |
| | |--- Not Installed:IIS-HttpRedirect
| | |
| | |
| | |--- Not Installed:IIS-StaticContent
| | |
| |
| |
| |--- Not Installed:IIS-HealthAndDiagnostics
| | |
| | |--- Not Installed:IIS-CustomLogging
| | |
| | |
| | |--- Not Installed:IIS-HttpLogging
| | |
| | |
| | |--- Not Installed:IIS-HttpTracing
| | |
| | |
| | |--- Not Installed:IIS-LoggingLibraries
| | |
| | |
| | |--- Not Installed:IIS-ODBCLogging
| | |
| | |
| | |--- Not Installed:IIS-RequestMonitor
| | |
| |
| |
| |--- Not Installed:IIS-Performance
| | |
| | |--- Not Installed:IIS-HttpCompressionDynamic
| | |
| | |
| | |--- Not Installed:IIS-HttpCompressionStatic
| | |
| |
| |
| |--- Not Installed:IIS-Security
| | |
| | |--- Not Installed:IIS-BasicAuthentication
| | |
| | |
| | |--- Not Installed:IIS-ClientCertificateMappingAuthentication
| | |
| | |
| | |--- Not Installed:IIS-DigestAuthentication
| | |
| | |
| | |--- Not Installed:IIS-IISCertificateMappingAuthentication
| | |
| | |
| | |--- Not Installed:IIS-IPSecurity
| | |
| | |
| | |--- Not Installed:IIS-RequestFiltering
| | | |
| | | |--- Not Installed:IIS-ASP
| | | |
| | |
| | |
| | |--- Not Installed:IIS-URLAuthorization
| | |
| | |
| | |--- Not Installed:IIS-WindowsAuthentication
| | |
| |
|
|
|--- Not Installed:IIS-WebServerManagementTools
| |
| |--- Not Installed:IIS-IIS6ManagementCompatibility
| | |
| | |--- Not Installed:IIS-LegacyScripts
| | |
| | |
| | |--- Not Installed:IIS-Metabase
| | | |
| | | |--- Not Installed:IIS-FTPServer
| | | |
| | | |
| | | |--- Not Installed:IIS-LegacyScripts
| | | |
| | |
| | |
| | |--- Not Installed:IIS-WMICompatibility
| | | |
| | | |--- Not Installed:IIS-LegacyScripts
| | | |
| | |
| |
| |
| |--- Not Installed:IIS-ManagementScriptingTools
| |
|
Not Installed:NetworkLoadBalancingHeadlessServer
Not Installed:SNMP-SC
Not Installed:TelnetClient
Not Installed:WAS-WindowsActivationService
|
|--- Not Installed:WAS-ProcessModel
| |
| |--- Not Installed:IIS-ASP
| |
| |
| |--- Not Installed:IIS-BasicAuthentication
| |
| |
| |--- Not Installed:IIS-CGI
| |
| |
| |--- Not Installed:IIS-ClientCertificateMappingAuthentication
| |
| |
| |--- Not Installed:IIS-CustomLogging
| |
| |
| |--- Not Installed:IIS-DefaultDocument
| |
| |
| |--- Not Installed:IIS-DigestAuthentication
| |
| |
| |--- Not Installed:IIS-DirectoryBrowsing
| |
| |
| |--- Not Installed:IIS-HttpCompressionDynamic
| |
| |
| |--- Not Installed:IIS-HttpCompressionStatic
| |
| |
| |--- Not Installed:IIS-HttpErrors
| |
| |
| |--- Not Installed:IIS-HttpLogging
| |
| |
| |--- Not Installed:IIS-HttpRedirect
| |
| |
| |--- Not Installed:IIS-HttpTracing
| |
| |
| |--- Not Installed:IIS-IISCertificateMappingAuthentication
| |
| |
| |--- Not Installed:IIS-IPSecurity
| |
| |
| |--- Not Installed:IIS-ISAPIExtensions
| | |
| | |--- Not Installed:IIS-ASP
| | |
| |
| |
| |--- Not Installed:IIS-ISAPIFilter
| |
| |
| |--- Not Installed:IIS-LoggingLibraries
| |
| |
| |--- Not Installed:IIS-ODBCLogging
| |
| |
| |--- Not Installed:IIS-RequestFiltering
| | |
| | |--- Not Installed:IIS-ASP
| | |
| |
| |
| |--- Not Installed:IIS-RequestMonitor
| |
| |
| |--- Not Installed:IIS-ServerSideIncludes
| |
| |
| |--- Not Installed:IIS-StaticContent
| |
| |
| |--- Not Installed:IIS-URLAuthorization
| |
| |
| |--- Not Installed:IIS-WindowsAuthentication
| |
|
Not Installed:WindowsServerBackup
Adding or removing the Active Directory role with OCSetup.exe is not supported. It can leave your server in an unstable state. Always use DCPromo to install or uninstall Active Directory.
===========================================================================
Microsoft-Windows-ServerCore-Package
Not Installed:BitLocker
Not Installed:BitLocker-RemoteAdminTool
Not Installed:IIS-WebServerRole
|
|--- Not Installed:IIS-FTPPublishingService
| |
| |--- Not Installed:IIS-FTPServer
| |
|
|
|--- Not Installed:IIS-WebServer
| |
| |--- Not Installed:IIS-ApplicationDevelopment
| | |
| | |--- Not Installed:IIS-ASP
| | |
| | |
| | |--- Not Installed:IIS-CGI
| | |
| | |
| | |--- Not Installed:IIS-ISAPIExtensions
| | | |
| | | |--- Not Installed:IIS-ASP
| | | |
| | |
| | |
| | |--- Not Installed:IIS-ISAPIFilter
| | |
| | |
| | |--- Not Installed:IIS-ServerSideIncludes
| | |
| |
| |
| |--- Not Installed:IIS-CommonHttpFeatures
| | |
| | |--- Not Installed:IIS-DefaultDocument
| | |
| | |
| | |--- Not Installed:IIS-DirectoryBrowsing
| | |
| | |
| | |--- Not Installed:IIS-HttpErrors
| | |
| | |
| | |--- Not Installed:IIS-HttpRedirect
| | |
| | |
| | |--- Not Installed:IIS-StaticContent
| | |
| |
| |
| |--- Not Installed:IIS-HealthAndDiagnostics
| | |
| | |--- Not Installed:IIS-CustomLogging
| | |
| | |
| | |--- Not Installed:IIS-HttpLogging
| | |
| | |
| | |--- Not Installed:IIS-HttpTracing
| | |
| | |
| | |--- Not Installed:IIS-LoggingLibraries
| | |
| | |
| | |--- Not Installed:IIS-ODBCLogging
| | |
| | |
| | |--- Not Installed:IIS-RequestMonitor
| | |
| |
| |
| |--- Not Installed:IIS-Performance
| | |
| | |--- Not Installed:IIS-HttpCompressionDynamic
| | |
| | |
| | |--- Not Installed:IIS-HttpCompressionStatic
| | |
| |
| |
| |--- Not Installed:IIS-Security
| | |
| | |--- Not Installed:IIS-BasicAuthentication
| | |
| | |
| | |--- Not Installed:IIS-ClientCertificateMappingAuthentication
| | |
| | |
| | |--- Not Installed:IIS-DigestAuthentication
| | |
| | |
| | |--- Not Installed:IIS-IISCertificateMappingAuthentication
| | |
| | |
| | |--- Not Installed:IIS-IPSecurity
| | |
| | |
| | |--- Not Installed:IIS-RequestFiltering
| | | |
| | | |--- Not Installed:IIS-ASP
| | | |
| | |
| | |
| | |--- Not Installed:IIS-URLAuthorization
| | |
| | |
| | |--- Not Installed:IIS-WindowsAuthentication
| | |
| |
|
|
|--- Not Installed:IIS-WebServerManagementTools
| |
| |--- Not Installed:IIS-IIS6ManagementCompatibility
| | |
| | |--- Not Installed:IIS-LegacyScripts
| | |
| | |
| | |--- Not Installed:IIS-Metabase
| | | |
| | | |--- Not Installed:IIS-FTPServer
| | | |
| | | |
| | | |--- Not Installed:IIS-LegacyScripts
| | | |
| | |
| | |
| | |--- Not Installed:IIS-WMICompatibility
| | | |
| | | |--- Not Installed:IIS-LegacyScripts
| | | |
| | |
| |
| |
| |--- Not Installed:IIS-ManagementScriptingTools
| |
|
Not Installed:NetworkLoadBalancingHeadlessServer
Not Installed:SNMP-SC
Not Installed:TelnetClient
Not Installed:WAS-WindowsActivationService
|
|--- Not Installed:WAS-ProcessModel
| |
| |--- Not Installed:IIS-ASP
| |
| |
| |--- Not Installed:IIS-BasicAuthentication
| |
| |
| |--- Not Installed:IIS-CGI
| |
| |
| |--- Not Installed:IIS-ClientCertificateMappingAuthentication
| |
| |
| |--- Not Installed:IIS-CustomLogging
| |
| |
| |--- Not Installed:IIS-DefaultDocument
| |
| |
| |--- Not Installed:IIS-DigestAuthentication
| |
| |
| |--- Not Installed:IIS-DirectoryBrowsing
| |
| |
| |--- Not Installed:IIS-HttpCompressionDynamic
| |
| |
| |--- Not Installed:IIS-HttpCompressionStatic
| |
| |
| |--- Not Installed:IIS-HttpErrors
| |
| |
| |--- Not Installed:IIS-HttpLogging
| |
| |
| |--- Not Installed:IIS-HttpRedirect
| |
| |
| |--- Not Installed:IIS-HttpTracing
| |
| |
| |--- Not Installed:IIS-IISCertificateMappingAuthentication
| |
| |
| |--- Not Installed:IIS-IPSecurity
| |
| |
| |--- Not Installed:IIS-ISAPIExtensions
| | |
| | |--- Not Installed:IIS-ASP
| | |
| |
| |
| |--- Not Installed:IIS-ISAPIFilter
| |
| |
| |--- Not Installed:IIS-LoggingLibraries
| |
| |
| |--- Not Installed:IIS-ODBCLogging
| |
| |
| |--- Not Installed:IIS-RequestFiltering
| | |
| | |--- Not Installed:IIS-ASP
| | |
| |
| |
| |--- Not Installed:IIS-RequestMonitor
| |
| |
| |--- Not Installed:IIS-ServerSideIncludes
| |
| |
| |--- Not Installed:IIS-StaticContent
| |
| |
| |--- Not Installed:IIS-URLAuthorization
| |
| |
| |--- Not Installed:IIS-WindowsAuthentication
| |
|
Not Installed:WindowsServerBackup
在了解了系统角色和功能的安装状态之后,就可以根据需要来进行 IIS7 + CGI 的定制安装。为此,键入“start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-CGI;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-Performance;IIS-HttpCompressionStatic;WAS-WindowsActivationService;WAS-ProcessModel”,注意:命令行中间没有换行。有关 pkgmgr 安装 IIS7 的有关参数可以参考:
在 Server Core 下执行 IIS7 的完整安装、
脚本方式安装 IIS7、
IIS7安装场景对照表,这几篇日志。其实经过我个人亲身实践证明,IIS7 的默认安装包含了静态内容的访问支持,而这些功能也正是我们所需要的,那么我个人认为使用“ocsetup”反而更为简便,因为不需要再输入繁琐的命令参数。在执行“start /w ocsetup IIS-WebServerRole”后,再执行“start /w ocsetup WAS-WindowsActivationService”,才算真正的安装上了 IIS7,因为 IIS7 需要 “WAS-WindowsActivationService”支持。至此,还只是完成了一半,因为我们完成了 IIS7 的默认安装,并没有安装上 CGI 支持,为此我们还需要执行“start /w ocsetup IIS-CGI”才是真正的完成安装,当安装了“IIS-CGI”后系统会提示重新启动,根据向导完成即可!而使用“pkgmgr”则不会出现此步骤,而两者的区别也并非仅仅如此!这里,大家不禁要问到为什么每个执行命令先都要加上“start /w ”,这是为了能够识别出该命令是否执行结束,如果不加之,那么在执行命令后会直接回到光标状态,而很难识别该命令的是否执行完毕。





本文转自 苏繁 51CTO博客,原文链接:http://blog.51cto.com/goxia/224762,如需转载请自行联系原作者