Wow. Take Windows Server 2008 Server Core + PHP + IIS7 + MySQL + WordPress, mix them together, will they blend well and work out as a nice concoction? Matty challenged me to this blend, and guess what, we have a powerful cocktail to offer after all!
I scuffled around to see if anyone had come up with this powerful blend. Surprisingly, no one offered it on Server Core. There are bits and pieces everywhere, but none quite fit the blend we needed. I then decided to take up Matty’s challenge and come up with one.
With my buddy Matty, we decided to take a spin for it (He challenged me to it). The whole ordeal was over in a day and we finally got it working. Thanks to another great pal in the next cube, Chris Ismael (Interop Expert).
Alright, here is the story on my adventure.
Matty brought me his machine for the adventure. A cool looking machine with a red glow. Deserves some mention because he sponsored this equipment to mess with. It is a Dell XPS. But it is more like desktop replacement than a laptop. 😉 It is powered by an Intel Core2DUO 2GHz with 4GB of ram. In this adventure, a Server Core installation took a mere 4 minutes to complete on this beast.
I chose to do my adventure using Virtualization technology. I loaded a Windows 2008 x64 onto the Dell machine and installed the Virtualization server role. Using virtualization allows me to take snap shots in time. This will allow me to revert back to a previous time in seconds. So for example, if I crash and made a grave mistake, I do not have to redo or try figure out what to undo. Windows Server Virtualization is definitely a technology every one serious in optimizing the data centre should take a serious thought about it.
The Ordeal Begins
Alright, let’s get to our stuff and begin our adventure.
I will take you through Server Core, IIS7 with FastCGI, PHP, MySQL and WordPress. The rest are on your own. Seriously, there is nothing else apart from learning how to use WordPress. 😉
Getting Server Core onto the Network
You will setup Server Core the same way as you setup a typical Windows server, except you select “Core” installation. The first thing Server Core will get you to do is force you to change your admin password.
A Server Core in Windows Server Virtualization (WSV) will not have any network card installed. We will need to install Integration Services into the Virtual Machine (VM). By the way, my tests so far, WSV allows my VMs to run 3 times faster than on Virtual Server 2005 R2.
Here are some tasks you need to get over;
1. Install Integration Services (Skip this if you’re not using WSV)
On the VM Connection Window, Click on Action -> Insert Integration Services Setup Disk or Hit Ctrl+I. This step loads vmguest.iso onto the VM’s DVD Drive and lets you access the ISO contents. In this case, the Integration Services.
Auto run won’t happen. So you need to execute “<DRIVE>:\support\x86\ and execute setup.exe”
You will be prompted to reboot twice, go ahead.
This will load up the smooth mouse integration, NICs bla bla.. I’ll save the details. Let’s move on.
2. Verifying NIC and IPConfig
If you have a DHCP server running on the network, you can skip this unless you want to use static IP configuration
To fix an IP Address;
netsh interface ipv4 set address name=”Local Area Connection” source=static address=<IPADDRESS> mask=<255.255.255.0> gateway=<GatewayIP>
To add a DNS Server entry;
netsh interface ipv4 add dnsserver name="Local Area Connection" address=<IPAddress of DNS>
3. Changing the Computer Name & Joining a Domain if needed
Find out the current hostname: "hostname" (Take note of it)
To change the computer name:
netdom renamecomputer <Current Computer name> /NewName:<NewComputerName>
To join the domain (if you need to, Server Core and be in workgroup mode):
netdom join <ComputerName> /domain:<DomainName> /Userd:<UserName> /passwordd: *
4. Opening an Exception for MySQL
netsh firewall add portopening tcp 3306 "MySQL"
This step prevents a setup error in MySQL later.
You need to reboot at this stage to take effect: shutdown /r /t 0
5. Activation of Windows Server Core
If you are connected to Internet: slmgr.vbs –ato
Else to use phone activation:
slmgr.vbs –dti (Displays the Installation ID to be given to Microsoft)
slmgr.vbs –atp <ConfirmationID> (Activates server using Confirmation ID given by Microsoft)
Loading IIS 7.0 with FastCGI
This is where Microsoft has placed lots of focus on making IIS 7.0 highly secure, highly modular and highly interoperable. For more details on the installation commands, you may visit this web page for installation tips.
For this adventure, I will install the minimum required. I used the following command;
start /w pkgmgr /iu:IIS-WebServerRole;WAS-WindowsActivationService;WAS-ProcessModel;IIS-CGI
To verify the installation, use this command “oclist” and verify the installation.
Extract contents of downloaded files onto c:\php\
Updating the PHP.INI File
– Copy c:\php\php.ini-recommended c:\php\php.ini
– Notepad c:\php\php.ini
– Change: extension_dir=”c:\php\ext”
– Uncomment: extension=php_mysql.dll
– Add: Extension=php_gd.dll
– Save the file php.ini and exit notepad
Creating PHP Handler in IIS 7.0
appcmd set config /section:system.webServer/fastCGI /+[fullPath=’c:\php\php-cgi.exe’]
appcmd set config /section:system.webServer/handlers /+[name=’PHP-FastCGI’,path=’*.php’,verb=’*’,modules=’FastCgiModule’,scriptProcessor=’c:\php\php-cgi.exe’,resourceType=’Either’]
Setting Default Document to index.php
appcmd set config "Default web site" /section:defaultDocument /enabled:true
appcmd set config "Default Web Site" /section:defaultDocument /+files.[value=’index.php’]
Download: MySQL 5.0.45
This is the only section where you will encounter a GUI setup. 😉 Enjoy.
Running the Setup:
Execute the file, mysql-essential-5.0.45-win32.msi
At Welcome, Click next
Select Typical, Click next
Click Install, Next all the way and Finish.
Instance Configuration will now begin:
At Welcome, Click next
Select Standard Configuration, Click next
Select Install as Windows Service, Click next
Specify the root password and Click next
Click Execute and Finish
Creating a MySQL Database
Reference: PHP on IIS7.0 WordPress
Execute “c:\Program Files\MySQL\MySQL Server 5.0\bin\mysql.exe –u root –p”
Key in your root password specified earlier.
mysql> create database wordpress;
mysql> grant all privileges on wordpress.* to ‘wordpress’@’%’ identified by ‘password’;
Extract the download file’s contents into c:\inetpub\wwwroot\wordpress\
Next make a copy of the WordPress Configuration Sample file;
copy wp-config-sample.php wp-config.php
We need to modify the wp-config.php to reflect the right UserID, Password, MySQL Database Name and server. So we need to modify these 4 attributes to reflect what we have setup so far; DB_NAME, DB_USER, DB_PASSWORD, DB_HOST
// ** MySQL settings ** //
define(‘DB_NAME’, ‘wordpress’); // The name of the database
define(‘DB_USER’, ‘wordpress’); // Your MySQL username
define(‘DB_PASSWORD’, ‘password’); // …and password
define(‘DB_HOST’, ‘localhost’); // Change this to IP address of your database
We are done. Open a browser from a client that can see this server we have setup. Browse to http://<Server>/wordpress/wp-admin/install.php and start configuring the WordPress application.
We now have a running Web Server (on Server Core) with PHP enabled running the WordPress application. In essence, we have pieced together the following technologies; Windows 2008 Server Core + PHP + MySQL + IIS 7.0 + WordPress.
Off my mind, there are many aspects which are compelling;
– Small foot print – Server Core is light in foot print. Much lesser binary. Takes about 1/4 to 1/5 the footprint of a full install. Disk storage is less demanding.
– Small surface attack area – Less binaries, less requirements to update the binaries if a vulnerability is discovered
– Requires less resources to run
– Concentrated workload
– Fast and speed server provisioning
I had fun in this adventure and thanks to Matty and Chris. We are looking out for more fun and will share with you what we have. If you have an idea or would like to know more, contact me or Matty anytime. Drop us an email today.
BTW, this is a supported scenario in IT Pro Momentum. So if you like to give Server Core running IIS7 a try in your environment and receive a free 1 year TechNet+ Subscription, wait no further, drop me an email now.