Introduction

The xPhp module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit, which is a collection of DSC Resources produced by the PowerShell Team. This module contains the xPhp resource. This DSC Resource allows you to Setup PHP in IIS.

All of the resources in the DSC Resource Kit are provided AS IS, and are not supported through any Microsoft standard support program or service. The ""x" in xPhp stands for experimental, which means that these resources will be fix forward and monitored by the module owner(s).

Please leave comments, feature requests, and bug reports in the Q & A tab for this module.

If you would like to modify xPhp module, feel free. When modifying, please update the module name, resource friendly name, and MOF class name (instructions below). As specified in the license, you may copy or modify this resource as long as they are used on the Windows Platform.

For more information about Windows PowerShell Desired State Configuration, check out the blog posts on the PowerShell Blog (this is a good starting point). There are also great community resources, such as PowerShell.org , or PowerShell Magazine . For more information on the DSC Resource Kit, check out this blog post.

Installation

To install xPhp module

To confirm installation:

Requirements

This module requires the latest version of PowerShell (v4.0, which ships in Windows 8.1 or Windows Server 2012 R2). To easily use PowerShell 4.0 on older operating systems, install WMF 4.0. Please read the installation instructions that are present on both the download page and the release notes for WMF 4.0.

Description

The xPhp module contains the xPhp DSC Resource. This DSC Resource allows you to Setup PHP in IIS and optionally register the MySql extention.

Details

xPhp resource has following properties:

Renaming Requirements

When making changes to these resources, we suggest the following practice:

  1. Update the following names by replacing MSFT with your company/community name and replacing the "x" with "c" (short for "Community") or another prefix of your choice:
    • Module name (ex: xPhp becomes cPhp)
    • Resource folder (ex: MSFT_xPhp becomes Contoso_cPhp)
    • Resource Name (ex: MSFT_xPhp becomes Contoso_cPhp)
    • Resource Friendly Name (ex: xPhp becomes cPhp)
    • MOF class name (ex: MSFT_xPhp becomes Contoso_cPhp)
    • Filename for the <resource>.schema.mof (ex: MSFT_xPhp.schema.mof becomes Contoso_cPhp.schema.mof)
  2. Update module and metadata information in the module manifest
  3. Update any configuration that use these resources

We reserve resource and module names without prefixes ("x" or "c") for future use (e.g. "MSFT_Php" or "Php"). If the next version of Windows Server ships with a "Php" resource, we don't want to break any configurations that use any community modifications. Please keep a prefix such as "c" on all community modifications.

Versions

1.0.1

Example: Setup a Php Server on a single node

This configuration will setup a Php Server on a sigle node.
Note: this requires the following other modules: xWebAdministration, and xPsDesiredStateConfiguration. (see Example: Install xPhp Module and the other required modules).

PowerShell
Edit|Remove
# This configuration will, via the xPHP composite configuration: 
# 1) Make sure IIS is installed 
# 2) Make sure PHP is present 
# 3) Make sure that PHP is registered with IIS 
# 4) Make sure PHP is in the path 
# 
# ********* NOTE *********** 
# PHP changes their download URLs frequently.  Please verify the URL. 
# the VC Redist URL changes less frequently, but should still be verified. 
# After verifying the download URLs for the products and update them appropriately. 
# ************************** 
$scriptRoot = Split-Path $MyInvocation.MyCommand.Path 
$phpIniPath = (Join-Path $scriptRoot "phpConfigTemplate.txt"if (-not (Test-Path $phpIniPath)) 
{ 
    $message = "Missing required file $phpIniPath" 
    # This file is in the samples folder of the resource 
    throw $message 
} 
Configuration SamplePhp 
{ 
    # Import composite resources 
    Import-DscResource -module xPhp 
 
    Node "localhost" 
    { 
 
        File PackagesFolder 
        { 
            DestinationPath = "C:\package" 
            Type = "Directory" 
            Ensure = "Present" 
        } 
 
        # Make sure PHP is installed in IIS 
        xPhp  php 
        { 
            InstallMySqlExt = $true 
            PackageFolder =  "C:\package" 
            # Update with the latest "VC11 x64 Non Thread Safe" from http://windows.php.net/download/ 
            DownloadURI = "http://windows.php.net/downloads/releases/php-5.5.14-nts-Win32-VC11-x64.zip" 
            DestinationPath = "C:\php" 
            ConfigurationPath = $phpIniPath 
            Vc2012RedistDownloadUri = "http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe" 
 
            # Removed because this dependency does not work in Windows Server 2012 R2 and below 
            # This should work in WMF v5 and above 
            # DependsOn = "[IisPreReqs_WordPress]Iis" 
        } 
    } 
} 
 
SamplePhp 
 
Start-DscConfiguration -path .\SamplePhp -wait -verbose
 



Example: Install xPhp Module and the other required modules

Note: This require a version of WMF 5 see the Powershell Resource Gallery for more details

# This Script installs the required modules for the PHP Sample
# It uses the PowerShell Resource Gallery, see https://msconfiggallery.cloudapp.net/
# This requires WMF 5.   If you don't have WMF 5, Please install the modules manually.

Write-Host "Installing required modules..."

Install-Module xWebAdministration -MinimumVersion 1.3.2 -Force
Install-Module xPSDesiredStateConfiguration -MinimumVersion 3.0.1 -Force
Install-Module xPhp -MinimumVersion 1.0.1 -Force