PhpRiot
Follow phpriot on Twitter
Sponsored Link
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Command line tools for managing PHP in IIS

Note: This article was originally published at Planet PHP on 28 June 2011.
Planet PHP

The latest release of PHP Manager 1.2 for IIS now includes Windows PowerShell commands that can be used to install, configure and manage PHP on IIS 7 from command line. In addition those commands can be used to automate the configuration and management tasks.

Here are examples of what can be done with PHP Manager command line tools:

  • Register a new PHP version:
PS C:\Users\AdministratorNew-PHPVersion -ScriptProcessor "C:\PHP\536\php-cgi.exe"
  • Get information about current PHP configuration:
PS C:\Users\Administrator Get-PHPConfiguration HandlerNameA A A A A A A A A A A A A  : php-5.3.6 VersionA A A A A A A A A A A A A A A A A  : 5.3.6 ScriptProcessorA A A A A A A A A  : C:\php\536\php-cgi.exe HandlerTypeA A A A A A A A A A A A A  : Local ErrorLogA A A A A A A A A A A A A A A A  : C:\Windows\Temp\php-5.3.6_errors.log PHPIniFilePathA A A A A A A A A A  : C:\php\536\php.ini InstalledExtensionsCount : 35 EnabledExtensionsCountA A  : 9
  • Change PHP version for a particular web site or a folder:
PS C:\Users\Administrator Set-PHPVersion -HandlerName php-5.3.6 -SiteName "Default Web Site" PS C:\Users\Administrator Get-PHPVersion -SiteName "Default Web Site" HandlerNameA A A A A  VersionA A A A A  ScriptProcessorA A A A A A A A A A A A  Active ------------A A A A  -------A A A A A  ---------------A A A A A A A A A A A A  ------ php-5.3.6A A A A A A A  5.3.6A A A A A A A  C:\php\536\php-cgi.exeA A A A A  True php-5.2.17A A A A A A  5.2.17A A A A A A  C:\php\5217\php-cgi.exeA A A A  False
  • Change PHP settings:
PS C:\Users\Administrator Set-PHPSetting -Name display_errors -Value On PS C:\Users\Administrator Get-PHPSetting -Name *error* NameA A A A A A A A A A A A A A A A A A A A A A A A  ValueA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  Section ----A A A A A A A A A A A A A A A A A A A A A A A A  -----A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  ------- error_reportingA A A A A A A A A A A A A  E_ALLA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  PHP display_errorsA A A A A A A A A A A A A A  OnA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  PHP display_startup_errorsA A A A A A  OffA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  PHP log_errorsA A A A A A A A A A A A A A A A A A  OnA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  PHP log_errors_max_lenA A A A A A A A A A  1024A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  PHP ignore_repeated_errorsA A A A A A  OffA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  PHP track_errorsA A A A A A A A A A A A A A A A  OffA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  PHP html_errorsA A A A A A A A A A A A A A A A A  OffA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  PHP mssql.min_error_severityA A A A  10A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  MSSQL error_logA A A A A A A A A A A A A A A A A A A  C:\Windows\temp\php53_errors.logA A A  WebPIChanges
  • Enable PHP extensions:
PS C:\Users\Administrator Get-PHPExtension -Name *pdo*sql* | Set-PHPExtension -Status enabled PS C:\Users\Administrator Get-PHPExtension -Name *pdo*sql* NameA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  Status ----A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A  ------ php_pdo_mysql.dllA A A A A A A A A A A A A A A A A A A  Enabled php_pdo_sqlite.dllA A A A A A A A A A A A A A A A A A  Enabled php_pdo_sqlsrv.dllA A A A A A A A A A A A A A A A A A  Enabled php_pdo_pgsql.dllA A A A A A A A A A A A A A A A A A A  Enabled

Note that the example above demonstrates that it is possible to pipe several commands together. In this particular example the commands are used to enable all PHP extensions that contain a€opdoa€ and a€osqla€ in their names.

  • Get detailed help for commands and their usage examples:
PS C:\Users\Administrator get-help Get-PHPExtension NAME Get-PHPExtension SYNOPSIS Gets the list of PHP extensions available in the currently active PHP version. SYNTAX Get-PHPExtension [[-Name] ] [[-Status] ] [-SiteName ] [-VirtualPath ] [] DESCRIPTION The Get-PHPExtension cmdlet outputs the list of all PHP extensions available in the currently active PHP version. The list can be filtered by extension name and by the status (enabled or disabled). RELATED LINKS Set-PHPExtension REMARKS To

Truncated by Planet PHP, read more at the original (another 1044 bytes)