Archive for the ‘Web Platforms’ Category

WordPress and PHP on Windows Server 2008

Guess what? WordPress rocks on Windows Server 2008 and IIS7. Congratulation to Microsoft for the effort. If you didn’t know Microsoft created the FastCGI component to address previous performance issues with PHP on Windows. At the same time Zend worked to make PHP more stable on Windows. The two combined to make reliable and high performance PHP on Windows. FastCGI support is now built in to Windows Server 2008. There is plenty of documentation available for setting everything up manually but let me tell you this, don’t waste your time. Microsoft is really getting serious about PHP on Windows. They have created the Web Platform Installer 2.0 and that’s all you really need. Once you install the Web Platform Installer you can run it and choose to install applications like WordPress and Joomla. The installer checks to see if you have the necessary components, if you don’t then it downloads and installs them. This includes PHP, MySQL, and the application, like WordPress. It also installs an IIS URL ReWrite module so you can have pretty permalinks for your WordPress Blog. For novice or inexperienced Windows server admins I recommend you let the Platform Installer take care of everything for you.

For advanced users I will warn you that, at the time of my last install you could not change the default install path for MySql or PHP. This is easy to get around, just download and install PHP and MySql before you use the Platform Installer for the first time to set up WordPress. The Platform Installer will recognize your installations. Happy Blogging.

Almost forgot, here is how you create 301 redirects on Windows Server 2008 (and server 2003 with IIS6) if you are migrating from an existing site to a CMS platform.

—David Blizzard

301 Redirect on Windows Server

I see a lot of complaints from SEO and Internet Marketing agencies about the hoops they jump through to get Windows Server admins or hosts to create 301 redirects for clients. It is really not difficult at all. I decided to outline the steps so the next time one of you has an issue with a web host you can just copy this info and send it to them or link to it 😉 That might make them feel pretty dumb, but it will get the job done.

IIS6:

Redirect a single file.

  1. Open IIS Manager and locate the website
  2. Right click the file you want to redirect and choose properties
  3. Change the selector to “A Redirection to a URL”
  4. In the “Redirect To:” box type the new URL
  5. Put a check in “A permanent redirection for this resource” (this results in an HTTP status code of: HTTP/1.1 301 Moved Permanently)

That’s it!

Redirect an entire domain name – website.

  1. Open IIS Manager and locate the website
  2. Right click the Website you want to redirect and choose properties
  3. Select the “Home Directory Tab”
  4. Change the selector to “A Redirection to a URL”
  5. In the “Redirect To:” box type the new URL
  6. Put a check in “A permanent redirection for this resource” (this results in an HTTP status code of: HTTP/1.1 301 Moved Permanently)

OPTIONAL: Check “The exact URL entered above” if you want all pages redirected to the home page of the new domain rather than relative pages in the new domain.

IIS 7:

Redirect a single file.

  1. Open IIS Manager and locate the website under sites
  2. Right click the website and choose “switch to content view”
  3. In the right hand pane locate the file you want to redirect
  4. Right click the file and choose “switch to features view”
  5. Important! Verify that it shows the correct file name at the top of the screen
  6. Under the IIS section open “HTTP Redirect”
  7. Put a check in “Redirect requests to this destination” and type in the new URL
  8. Change the status code to “Permanent 301”
  9. Click Apply (this results in an HTTP status code of: HTTP/1.1 301 Moved Permanently)

That’s it!

Redirect an entire domain name – web site.

  1. Open IIS Manager and locate the website under sites
  2. Important! Verify that it shows the correct website name at the top of the screen
  3. Under the IIS section open “HTTP Redirect”
  4. Put a check in “Redirect requests to this destination” and type in the new URL
  5. Change the status code to “Permanent 301”
  6. Click Apply (this results in an HTTP status code of: HTTP/1.1 301 Moved Permanently)

OPTIONAL: Check the “redirect all requests to exact destination (instead of relative to destination)”

New in IIS 7:

For those that understand XML and the web.config file you can add a line similar to the following in the <configuration> section rather than using IIS Manager:

Domain redirect:

<system.webServer>
<httpRedirect enabled=”true” destination=”http://www.my-new-site.com” httpResponseStatus=”Permanent” />
</system.webServer>

File Redirect:

<location path=”my-old-file.htm”>
<system.webServer>
<httpRedirect enabled=”true” destination=”http://www.new-domain.com/my-new-file.htm” exactDestination=”true” httpResponseStatus=”Permanent” />
</system.webServer>
</location>

* copy and pasting the web.config examples could result in the wrong quotes which will cause an error. Re-type your quotes.

—David Blizzard

ASP.NET and XHTML Validation

If you’ve ever created an XHTML 1.0 Strict page containing an ASP.NET form element and ran it through the W3 Validator, you’ve undoubtedly noticed it’s reported as being invalid no matter what you do and no matter how valid the code actually appears. This is because ASP.NET adjusts the way it renders markup according to the requesting user agent. ASP.NET pities the W3 Validator and sends it bad code. This can be fixed with a “browser” file. The file and instructions on its use are available from that page.

However, that’s not all. The validator will now see your pages the way you see them in your browser, but ASP.NET is still rendering an invalid name attribute on your form element! You need to add a line to the system.web section of your web.config file:

<xhtmlConformance mode="Strict" />

Now ASP.NET plays nice with the W3 Validator and renders a valid XHTML Strict form! Now you can stop using the XHTML Transitional doctype and start using the XHTML Strict doctype on your ASP.NET pages!

—Kyle Blizzard

Why Use WordPress on Windows Server 2003?

UPDATE: This document is not for Windows Server 2008 please see WordPress and PHP on Windows Server 2008

We have tried a few DotNet blogs and were not completely happy so we have decided to go with WordPress. I will note that Subtext has potential and those of you like us that build sites based on DotNet and MS SQL might want to give that a try if WIMP is not an option. [Download Subtext DotNet Blog]

Another option is to build your own DotNet Blog application from scratch. We started that project but it’s always on the shelf while we keep up with our current customer requests and new design projects. So that leaves us with the option of WordPress on Windows.

Pros: It’s a full featured application with plenty of support articles. It can validate as strict XHTML with the right theme or some minor tweaking. If you want to roll your own using DotNet you have a long way to go just to get 75% of the features that you get in WordPress. It looks, functions, and feels like a commercial application. It’s not difficult to install and performance is quite good using FastCGI on IIS.

Cons: If you are a DotNet website developer then you probably don’t have PHP and MySQL installed on your servers. You might not be comfortable, from a security perspective, running software you are not familiar with on your servers.

Tips:

  1. Use FastCGI from Microsoft to increase PHP performance.
  2. Use this URL rewrite ISAPI filter to remove index.php from WordPress permalinks

Warnings: The above mentioned ISAPI filter seems to have an issue if your WordPress installation is not in the root.

Update: This is a good IIS 6 mod-rewrite workaround that works even when the blog is in a sub folder. Copy John’s code from that website into a custom 404 file in your blog root. Be sure you use a file extension of php and then map your 404 in IIS to the custom file. Choose URL and not File in the custom errors tab of IIS for the 404.

—David Blizzard

WordPress and PHP

I can’t believe we’re actually using PHP on Bliznet.com, and WordPress no less.

Doesn’t mean I’m going to give up on the BlizDev ASP.NET Blog though.

Addendum: This is intimidating. Maybe I will.

—Kyle Blizzard