In a Windows server environment, IIS can be used instead of Apache for the web server for activeCollab.
The following describes the steps needed to set up an environment to run an "Apache/MySQL/PHP" (using PHP5.*) web application on a Windows Server 2008 R2 server using IIS as the web server. This description assumes that the (MySQL) database is on a separate server, and therefore does not include instructions on installing MySQL on the web server. For all of the following, you need to be logged in to Window Server 2008 with an account that has administrative privileges.
(The instructions for the non-R2 version of Windows Server 2008 are essentially the same. For Windows Server 2003, you first need to install the FastCGI extension from Microsoft - http://www.microsoft.com/downloads/details.aspx?FamilyID=227219AA-6AEC-4B80-A9FA-76F811EE9E84 - and then install IIS in Control Panel, and then follow the intent of the remainder of the instructions; using Control Panel “Add/Remove Windows Components” instead of “Server Manager”, for example, to install IIS and SMTP.)
Installing IIS in Windows Server 2008
==========================
Run the Server manager application in Windows. If the "Web Server (IIS)" role is not already enabled, click the "Add Roles" link and add the "Web Server (IIS)" role. Ensure that all the appropriate services are installed in the "Web Server (IIS)" role, either while adding the role, or if the role is already added, check in the Server Manager application that the appropriate role services are added, and if not, click the "Add Services" link under "Web Server (IIS)" and add the necessary role services.
The services that are needed are: everything under "Common HTTP Features" except for "WebDAV Publishing", everything under "Application Development", only "HTTP Logging" and "Request Monitor" under "Health and Diagnostics", and everything under "Security"; do not install any of the "IIS 6" management tools (at least not in this step) or any of the "FTP Server" items.
SMTP email
========
PHP can send email directly via a remote SMTP server, or it can send emails to localhost where the IIS SMTP Server can forward the emails to a designated SMTP host. If you will be sending SMTP mail from PHP through IIS, you also need to install the SMTP Server feature. To do this, run the Server manager application. Select "Features" in the left-side tree and then click "Add Features". Scroll down and check "SMTP Server" and click "Next"; you will need to click "Add Required Role Services" on the dialog that tells you that IIS6 management tools and SMTP Server tools are also required for "SMTP Server"; proceed until you complete the installation of "SMTP Server" and the associated tools.
NOTE: After you install the SMTP Server, open the Services control panel application, find the "Simple Mail Transfer Protocol (SMTP)" service, and change its startup type to "Automatic" (for some reason, the installation of the feature sets the startup to "Manual" and SMTP thus won't start when the server reboots or IIS is restarted).
You can either download the "ZIP" version and install and configure everything manually, or (recommended) download the "Installer" version and run it to install and configure PHP5 for Windows.
It is recommended that you use a non-thread safe build of PHP with IIS FastCGI. A non-thread safe build of PHP provides significant performance gains over the standard build by not doing any thread-safety checks, which are not necessary, since IIS FastCGI ensures a single threaded execution environment.
Select the "VC9 x86 Non Thread Safe (msi) Installer PHP 5.3.x" version for download (as of early August 2010, I installed version 5.3.3). If you install a version prior to 5.3.0, you will need to make some additional configuration settings that are now performed by the installer for version 5.3. Run the installer and select "IIS FastCGI", and then select the items that you want to install; depending on the needs of the PHP web application that you want to use you may need to install PEAR under Extras, and some of the extensions under Extensions (such as Multi-byte string, and Oracle or PostgreSQL extensions if you are using those databases, imap, ldap, openssl, etc), and you should select "Register *.php files to open automatically with PHP". NOTE: It may be easier to simply select that all options are installed. When the install completes, the PHP files should be in either "C:\Program Files\PHP" or "C:\Program Files (x86)\PHP" (depending on whether it’s 32-bit or 64-bit Windows), and IIS should have a registered handler for PHP (named "PHP_via_FastCGI").
Installing PHP5 – updating PHP.INI
========================
There will be a PHP.INI file in the PHP installation folder, modified during the install process to have some Windows/IIS-specific settings. Edit this file (do this from a command prompt that you started with "run as administrator", or you may not have permissions to update the file) and check that the following settings have been made.
Note that, typically, these settings are not located close to where the individual settings are documented (in the php.ini file), but are grouped together later in the file. Search for "; Dynamic Extensions ;" in the php.ini file, and look for the settings several lines above that (around line 910 in the version 5.3.3 file).
The following values should already be set in the php.ini file by the installer:
cgi.force_redirect=0
fastcgi.impersonate=1
fastcgi.logging=1
extension_dir="C:\Program Files (x86)\PHP\ext"
The three cgi/fastcgi values shown here are important for use with IIS.
You need to make one more change in the php.ini file. Find the timezone line (that starts with ";date.timezone ="), uncomment this line (remove the leading ";") and set an appropriate timezone value such as "America/New_York" (from the list here: http://us3.php.net/manual/en/timezones.php ). PHP starting from version 5.3 may log or display an error if a valid timezone value is not set.
Also, set the SMTP values in php.ini. Find "[mail function]" in the file, and set a value for SMTP and smtp_port. You will probably also need to set "sendmail_from" to a valid email address in your organization (not necessarily an address that can receive emails, but at least an address within the same domain). I suggest setting SMTP to "localhost" and smtp_port to 25 - this will forward/relay emails via IIS/SMTP on the same server, and you will need to configure IIS to send SMTP emails to the appropriate server.
Alternatively, you can specify the direct SMTP server in the php.ini file, but you will then need to make sure that the remote SMTP server will accept SMTP connections directly from the PHP process. (In a corporate environment, it's usually easier to have the IIS SMTP connection allowed and then forward PHP emails via IIS.)
Configure IIS SMTP
=============
(If you are forwarding PHP emails via IIS SMTP on the same server) To set up the IIS SMTP server, start the "IIS 6.0 Manager" application. Expand the node name, right click on the "SMTP Virtual Server" entry and select "Properties". Select the "Access" tab. Click the "Connection" button and check that it's set to "All except the list below" with no entries in the list; click OK. Click the "Relay" button, select "Only the list below", then click the "Add..." button and add the IP address of the server; click the "Add..." button again and add the IP address "127.0.0.1" (for localhost). Click OK and OK again until you return to the IIS6 Manager screen. Close this screen.
Start the “IIS Manager” application (not the IIS 6.0 version). Select the server name in the left side tree. In the ASP.NET section, double-click the “SMTP E-mail” item. In the SMTP E-mail screen, enter a valid organizational email address in the “address” field, select “Deliver e-mail to SMTP server”, enter your organization’s SMTP server in the “SMTP Server” box, and click the “Apply” button. Depending on the setup at your organization, you may also need to change the port number and you may need to specify credentials under the “Authentication Settings”.
Test with PROBE.PHP
===============
Download the probe.php zip file from this site and use it to test the installation for use with activeCollab.
==========================
NOTE: The following information on PEAR and PEAR modules is not necessary for activeCollab (I believe). However, if you are installing other PHP-based web applications on the same web server, many applications will require PEAR and some PEAR modules; so I'm including this information for completeness.
PHP PEAR
=======
Open a command prompt (CMD) window with "run as administrator" selected. Change directory (CD) to the folder where PHP is installed, such as "C:\Program Files\PHP" or "C:\Program Files (x86)\PHP". Execute the batch file "go_pear.bat". At the prompts, press Enter to select the default "system", then Enter to accept the default "all", then Y and Enter to update the php.ini file, Enter again, and Enter again. This will create several new files in the PHP folder, including a "pear.bat" file.
You need to edit the pear.bat file, because it doesn't correctly handle install paths containing characters such as "(" in "Program Files (x86)" or perhaps space characters. At the line just before ":END" (the third line from the end of the file), change the section:
-d include_path="%PHP_PEAR_INSTALL_DIR%"
to:
-d "include_path='%PHP_PEAR_INSTALL_DIR%'"
Note the addition of the single quotes around %PHP_PEAR_INSTALL_DIR% and the movement of the first double quote to before include_path. The double quotes are for the CMD shell and the inside single quotes are used by PHP. (I found this fix on the web somewhere.)
Install additional PEAR modules
======================
After fixing pear.bat this way, you can then use it in this same command window (still running as administrator) to install any needed additional modules. For example, run each of the following commands in the command window to install the DB, MDB, and Auth modules if those modules are required for your application.
pear install DB-1.7.13
pear install MDB2-2.4.1
pear install pear/MDB2#mysql
pear install pear/MDB2#mysqli
pear install Auth-1.6.2
The commands shown above install the latest stable (non-beta) versions of each of these (as of early August 2010). You can install different versions or even the latest beta versions if you prefer.
Test with PHPINFO
=============
In the top-level IIS/web folder (normally “C:\Inetpub\wwwroot”), create a file named phpinfo.php containing the single line:
<?php phpinfo(); ?>
If PHP is installed correctly and configured in IIS, this page will display a detailed list of information about the installed version of PHP and its configuration and modules. This does not necessarily tell you whether all the add-on modules required for the application are installed.
You should probably delete this file after testing so that users cannot browse to this page and learn specific details about the PHP installation or configuration.
Install the application
===============
At this point, you should be able to install the desired PHP-based web application on the server and start using it.
HTTP 500 error for any missing modules
============================
If you attempt to run the PHP-based web application after installing it and you receive a generic HTTP 500 server error, the most likely cause is that you are still missing a necessary PHP or PEAR module.
On Windows Server 2008/IIS7, the account that needs to have write permission is the IUSR account (or NT AUTHORITY\IUSR). Note that when you create a new folder or IIS application under the wwwroot folder in IIS, that IIS will add the account IIS_IUSRS with read permission. However, granting this account write permission will still not allow the web application to write to the folders. You need to grant the separate IUSR account write permission.
You can set the permissions one folder at a time by right clicking on the folder in Windows Explorer, selecting Properties, selecting the Security tab, clicking the "Edit" button, then clicking "Add...", typing in servername\IUSR and then OK, checking the "Modify" checkbox, then OK, then OK again; repeat for each folder in the list above.
Alternatively, you can achieve the same result by using the Windows CACLS utility from the command line (or the newer ICACLS utility in Windows Server 2008) to update the Access Control List (ACL).
If you use CACLS, the syntax is "/G account:C" to grant an account "Change" permission (Write and Modify), and "/E" to edit (add to) the ACL instead of replacing the entire ACL.
NOTE: Be careful with the CACLS utility, because using it with the wrong switches can make a folder no longer accessible, regardless of your account privileges. Enter CACLS /? to see the command syntax.
The "IUSR" account is specified as "NT AUTHORITY\IUSR" at the command line.
If you open a CMD window with the "run as administrator" option, the following commands should set the permissions correctly for activeCollab on a Windows Server 2008 system. This assumes that you have changed your working directory in the command window to the top level folder of your activeCollab installation.
The following describes the steps needed to set up an environment to run an "Apache/MySQL/PHP" (using PHP5.*) web application on a Windows Server 2008 R2 server using IIS as the web server. This description assumes that the (MySQL) database is on a separate server, and therefore does not include instructions on installing MySQL on the web server. For all of the following, you need to be logged in to Window Server 2008 with an account that has administrative privileges.
(The instructions for the non-R2 version of Windows Server 2008 are essentially the same. For Windows Server 2003, you first need to install the FastCGI extension from Microsoft - http://www.microsoft.com/downloads/details.aspx?FamilyID=227219AA-6AEC-4B80-A9FA-76F811EE9E84 - and then install IIS in Control Panel, and then follow the intent of the remainder of the instructions; using Control Panel “Add/Remove Windows Components” instead of “Server Manager”, for example, to install IIS and SMTP.)
Installing IIS in Windows Server 2008
==========================
Run the Server manager application in Windows. If the "Web Server (IIS)" role is not already enabled, click the "Add Roles" link and add the "Web Server (IIS)" role. Ensure that all the appropriate services are installed in the "Web Server (IIS)" role, either while adding the role, or if the role is already added, check in the Server Manager application that the appropriate role services are added, and if not, click the "Add Services" link under "Web Server (IIS)" and add the necessary role services.
The services that are needed are: everything under "Common HTTP Features" except for "WebDAV Publishing", everything under "Application Development", only "HTTP Logging" and "Request Monitor" under "Health and Diagnostics", and everything under "Security"; do not install any of the "IIS 6" management tools (at least not in this step) or any of the "FTP Server" items.
SMTP email
========
PHP can send email directly via a remote SMTP server, or it can send emails to localhost where the IIS SMTP Server can forward the emails to a designated SMTP host. If you will be sending SMTP mail from PHP through IIS, you also need to install the SMTP Server feature. To do this, run the Server manager application. Select "Features" in the left-side tree and then click "Add Features". Scroll down and check "SMTP Server" and click "Next"; you will need to click "Add Required Role Services" on the dialog that tells you that IIS6 management tools and SMTP Server tools are also required for "SMTP Server"; proceed until you complete the installation of "SMTP Server" and the associated tools.
NOTE: After you install the SMTP Server, open the Services control panel application, find the "Simple Mail Transfer Protocol (SMTP)" service, and change its startup type to "Automatic" (for some reason, the installation of the feature sets the startup to "Manual" and SMTP thus won't start when the server reboots or IIS is restarted).
Install PHP5
=========
Download PHP from http://windows.php.net/download/
You can either download the "ZIP" version and install and configure everything manually, or (recommended) download the "Installer" version and run it to install and configure PHP5 for Windows.
It is recommended that you use a non-thread safe build of PHP with IIS FastCGI. A non-thread safe build of PHP provides significant performance gains over the standard build by not doing any thread-safety checks, which are not necessary, since IIS FastCGI ensures a single threaded execution environment.
Select the "VC9 x86 Non Thread Safe (msi) Installer PHP 5.3.x" version for download (as of early August 2010, I installed version 5.3.3). If you install a version prior to 5.3.0, you will need to make some additional configuration settings that are now performed by the installer for version 5.3. Run the installer and select "IIS FastCGI", and then select the items that you want to install; depending on the needs of the PHP web application that you want to use you may need to install PEAR under Extras, and some of the extensions under Extensions (such as Multi-byte string, and Oracle or PostgreSQL extensions if you are using those databases, imap, ldap, openssl, etc), and you should select "Register *.php files to open automatically with PHP". NOTE: It may be easier to simply select that all options are installed. When the install completes, the PHP files should be in either "C:\Program Files\PHP" or "C:\Program Files (x86)\PHP" (depending on whether it’s 32-bit or 64-bit Windows), and IIS should have a registered handler for PHP (named "PHP_via_FastCGI").
Installing PHP5 – updating PHP.INI
========================
There will be a PHP.INI file in the PHP installation folder, modified during the install process to have some Windows/IIS-specific settings. Edit this file (do this from a command prompt that you started with "run as administrator", or you may not have permissions to update the file) and check that the following settings have been made.
Note that, typically, these settings are not located close to where the individual settings are documented (in the php.ini file), but are grouped together later in the file. Search for "; Dynamic Extensions ;" in the php.ini file, and look for the settings several lines above that (around line 910 in the version 5.3.3 file).
The following values should already be set in the php.ini file by the installer:
cgi.force_redirect=0
fastcgi.impersonate=1
fastcgi.logging=1
extension_dir="C:\Program Files (x86)\PHP\ext"
The three cgi/fastcgi values shown here are important for use with IIS.
You need to make one more change in the php.ini file. Find the timezone line (that starts with ";date.timezone ="), uncomment this line (remove the leading ";") and set an appropriate timezone value such as "America/New_York" (from the list here: http://us3.php.net/manual/en/timezones.php ). PHP starting from version 5.3 may log or display an error if a valid timezone value is not set.
Also, set the SMTP values in php.ini. Find "[mail function]" in the file, and set a value for SMTP and smtp_port. You will probably also need to set "sendmail_from" to a valid email address in your organization (not necessarily an address that can receive emails, but at least an address within the same domain). I suggest setting SMTP to "localhost" and smtp_port to 25 - this will forward/relay emails via IIS/SMTP on the same server, and you will need to configure IIS to send SMTP emails to the appropriate server.
Alternatively, you can specify the direct SMTP server in the php.ini file, but you will then need to make sure that the remote SMTP server will accept SMTP connections directly from the PHP process. (In a corporate environment, it's usually easier to have the IIS SMTP connection allowed and then forward PHP emails via IIS.)
Configure IIS SMTP
=============
(If you are forwarding PHP emails via IIS SMTP on the same server) To set up the IIS SMTP server, start the "IIS 6.0 Manager" application. Expand the node name, right click on the "SMTP Virtual Server" entry and select "Properties". Select the "Access" tab. Click the "Connection" button and check that it's set to "All except the list below" with no entries in the list; click OK. Click the "Relay" button, select "Only the list below", then click the "Add..." button and add the IP address of the server; click the "Add..." button again and add the IP address "127.0.0.1" (for localhost). Click OK and OK again until you return to the IIS6 Manager screen. Close this screen.
Start the “IIS Manager” application (not the IIS 6.0 version). Select the server name in the left side tree. In the ASP.NET section, double-click the “SMTP E-mail” item. In the SMTP E-mail screen, enter a valid organizational email address in the “address” field, select “Deliver e-mail to SMTP server”, enter your organization’s SMTP server in the “SMTP Server” box, and click the “Apply” button. Depending on the setup at your organization, you may also need to change the port number and you may need to specify credentials under the “Authentication Settings”.
Test with PROBE.PHP
===============
Download the probe.php zip file from this site and use it to test the installation for use with activeCollab.
==========================
NOTE: The following information on PEAR and PEAR modules is not necessary for activeCollab (I believe). However, if you are installing other PHP-based web applications on the same web server, many applications will require PEAR and some PEAR modules; so I'm including this information for completeness.
PHP PEAR
=======
Open a command prompt (CMD) window with "run as administrator" selected. Change directory (CD) to the folder where PHP is installed, such as "C:\Program Files\PHP" or "C:\Program Files (x86)\PHP". Execute the batch file "go_pear.bat". At the prompts, press Enter to select the default "system", then Enter to accept the default "all", then Y and Enter to update the php.ini file, Enter again, and Enter again. This will create several new files in the PHP folder, including a "pear.bat" file.
You need to edit the pear.bat file, because it doesn't correctly handle install paths containing characters such as "(" in "Program Files (x86)" or perhaps space characters. At the line just before ":END" (the third line from the end of the file), change the section:
-d include_path="%PHP_PEAR_INSTALL_DIR%"
to:
-d "include_path='%PHP_PEAR_INSTALL_DIR%'"
Note the addition of the single quotes around %PHP_PEAR_INSTALL_DIR% and the movement of the first double quote to before include_path. The double quotes are for the CMD shell and the inside single quotes are used by PHP. (I found this fix on the web somewhere.)
Install additional PEAR modules
======================
After fixing pear.bat this way, you can then use it in this same command window (still running as administrator) to install any needed additional modules. For example, run each of the following commands in the command window to install the DB, MDB, and Auth modules if those modules are required for your application.
pear install DB-1.7.13
pear install MDB2-2.4.1
pear install pear/MDB2#mysql
pear install pear/MDB2#mysqli
pear install Auth-1.6.2
The commands shown above install the latest stable (non-beta) versions of each of these (as of early August 2010). You can install different versions or even the latest beta versions if you prefer.
You can find the download/install syntax at the web site of each of the modules, for example: http://pear.php.net/package/MDB2/download
Start here to find packages: http://pear.php.net/packages.php
Test with PHPINFO
=============
In the top-level IIS/web folder (normally “C:\Inetpub\wwwroot”), create a file named phpinfo.php containing the single line:
<?php phpinfo(); ?>
Open this file in the browser with the URL:
http://localhost/phpinfo.php
If PHP is installed correctly and configured in IIS, this page will display a detailed list of information about the installed version of PHP and its configuration and modules. This does not necessarily tell you whether all the add-on modules required for the application are installed.
You should probably delete this file after testing so that users cannot browse to this page and learn specific details about the PHP installation or configuration.
Install the application
===============
At this point, you should be able to install the desired PHP-based web application on the server and start using it.
HTTP 500 error for any missing modules
============================
If you attempt to run the PHP-based web application after installing it and you receive a generic HTTP 500 server error, the most likely cause is that you are still missing a necessary PHP or PEAR module.