PhpRiot
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 29 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 HandlerNameAAAAAAAAAAAAA : php-5.3.6 VersionAAAAAAAAAAAAAAAAA : 5.3.6 ScriptProcessorAAAAAAAAA : C:\php\536\php-cgi.exe HandlerTypeAAAAAAAAAAAAA : Local ErrorLogAAAAAAAAAAAAAAAA : C:\Windows\Temp\php-5.3.6_errors.log PHPIniFilePathAAAAAAAAAA : C:\php\536\php.ini InstalledExtensionsCount : 35 EnabledExtensionsCountAA : 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" HandlerNameAAAAA VersionAAAAA ScriptProcessorAAAAAAAAAAAA Active ------------AAAA -------AAAAA ---------------AAAAAAAAAAAA ------ php-5.3.6AAAAAAA 5.3.6AAAAAAA C:\php\536\php-cgi.exeAAAAA True php-5.2.17AAAAAA 5.2.17AAAAAA C:\php\5217\php-cgi.exeAAAA False
  • Change PHP settings:
PS C:\Users\Administrator Set-PHPSetting -Name display_errors -Value On PS C:\Users\Administrator Get-PHPSetting -Name *error* NameAAAAAAAAAAAAAAAAAAAAAAAA ValueAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Section ----AAAAAAAAAAAAAAAAAAAAAAAA -----AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ------- error_reportingAAAAAAAAAAAAA E_ALLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA PHP display_errorsAAAAAAAAAAAAAA OnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA PHP display_startup_errorsAAAAAA OffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA PHP log_errorsAAAAAAAAAAAAAAAAAA OnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA PHP log_errors_max_lenAAAAAAAAAA 1024AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA PHP ignore_repeated_errorsAAAAAA OffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA PHP track_errorsAAAAAAAAAAAAAAAA OffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA PHP html_errorsAAAAAAAAAAAAAAAAA OffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA PHP mssql.min_error_severityAAAA 10AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA MSSQL error_logAAAAAAAAAAAAAAAAAAA C:\Windows\temp\php53_errors.logAAA 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* NameAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Status ----AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ------ php_pdo_mysql.dllAAAAAAAAAAAAAAAAAAA Enabled php_pdo_sqlite.dllAAAAAAAAAAAAAAAAAA Enabled php_pdo_sqlsrv.dllAAAAAAAAAAAAAAAAAA Enabled php_pdo_pgsql.dllAAAAAAAAAAAAAAAAAAA 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 aopdoa and aosqla 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)