Command line tools for managing PHP in IIS
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\Administrator>New-PHPVersion -ScriptProcessor "C:\PHP\536\php-cgi.exe"
- Get information about current PHP configuration:
PS C:\Users\Administrator> Get-PHPConfiguration HandlerName : php-5.3.6 Version : 5.3.6 ScriptProcessor : C:\php\536\php-cgi.exe HandlerType : Local ErrorLog : C:\Windows\Temp\php-5.3.6_errors.log PHPIniFilePath : C:\php\536\php.ini InstalledExtensionsCount : 35 EnabledExtensionsCount : 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" HandlerName Version ScriptProcessor Active ------------ ------- --------------- ------ php-5.3.6 5.3.6 C:\php\536\php-cgi.exe True php-5.2.17 5.2.17 C:\php\5217\php-cgi.exe False
- Change PHP settings:
PS C:\Users\Administrator> Set-PHPSetting -Name display_errors -Value On PS C:\Users\Administrator> Get-PHPSetting -Name *error* Name Value Section ---- ----- ------- error_reporting E_ALL PHP display_errors On PHP display_startup_errors Off PHP log_errors On PHP log_errors_max_len 1024 PHP ignore_repeated_errors Off PHP track_errors Off PHP html_errors Off PHP mssql.min_error_severity 10 MSSQL error_log C:\Windows\temp\php53_errors.log 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* Name Status ---- ------ php_pdo_mysql.dll Enabled php_pdo_sqlite.dll Enabled php_pdo_sqlsrv.dll Enabled php_pdo_pgsql.dll 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 “pdo” and “sql” 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] <String>] [[-Status] <PHPExtensionStatus>] [-SiteName <String>] [-VirtualPath <String>] [<CommonParameters>] 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 see the examples, type: "get-help Get-PHPExtension -examples". For more information, type: "get-help Get-PHPExtension -detailed". For technical information, type: "get-help Get-PHPExtension -full".
Also, refer to the PHP Manager Documentation to get more information and usage examples.
Other improvements in the v1.2 include French translation (thanks to Emmanuel Boersma and Sylvain Lecerf) and several bug fixes.
Use Web Platform Installer to get the latest release of PHP Manager for IIS.
9,535 views
ruslany on June 28th 2011 in PHP



(3 votes, average: 3.67 out of 5)