OpenConcept Drupal WET Installation Guide
Διαφήμιση
Διαφήμιση
Drupal WET on Windows Server 2008 R2 with IIS
7.5
Installation Guide
By: OpenConcept Consulting Inc.
http://openconcept.ca
for Parks Canada
Author: Mike Gifford <[email protected]>
Contributors: Rob Johnston (Action Plan), Mike Mallett
<[email protected]>, Denis Fung (Parks Canada),
Editor: Lee Hunter
http://streamoflight.com
Abstract
This document describes setting up the Drupal WET Variant within a Windows Server environment. Security, configuration and performance issues are addressed.
Copyright
This document is licensed under the Open Government Licence as specified in http://www.data.gc.ca/eng/opengovernmentlicencecanada
This is a Living Document. Please contribute enhancements
1
Table of Contents
Introduction
Hardware and Software Requirements
Software Summary
Steps for Configuration
Step 1: Install PHP/IIS/MSSQL
Step 2: Set Up the Drupal Environment
Step 3: Install Acquia Drupal 7
Step 4: Preparing WET
Step 5: Add a Web Site
Step 6: Configure settings.php
Step 7: Set up the MSSQL Database
Create a blank database
Create a new login and map it to the database
Note there are a few known issues with MSSQL:
Step 8: Installing WET
Additional Notes
Migrating an Existing WET Instance
Other Server Configs: Cron
Install Drush (Strongly recommended)
Git, Memcache (Optional)
Other Configuration
Disabling execution of PHP in useruploaded files https://groups.drupal.org/node/226059
Install PHP APC (optional)
Check SMTP settings
Install WinCache
Drupal Modules for Windows environments
Videos and Presentations
Related Links
Related Books
Troubleshooting
Fatal error: Undefined class constant 'SQLSRV_ATTR_DIRECT_QUERY'
Troubleshooting File Permissions
This is a Living Document. Please contribute enhancements
2
Introduction
Drupal is a leading content management system, widely used by governments around the world, including the Government of Canada, who are looking to meet increasing citizen demands for webbased services, to address challenges with accessibility and mobile computing, and to do so with ever smaller budgets.
Drupal requires PHP but can be run with a variety of database servers (MySQL, SQLite,
PostgreSQL or MSSQL), web servers (Apache, Nginx & IIS) and operating systems (Linux,
UNIX, Windows and MacOS). This guide is designed to help a Windows System Administrator set up Drupal in their environment.
At the moment, the best practice for installing Drupal on a Windows server is to target IIS and
MSSQL.
As with the majority of Internet tools, Drupal primarily targets the open source LAMP stack, which means that there is relatively less community support and documentation for a Windowsbased stack. This means that installing Drupal on Windows is not considered a best practice. However, if there is no alternative for your department, Drupal can be deployed successfully on Windows.
Please note that testing for this document was done on an Amazon EC2 Web Server. There may be substantial differences between an EC2 Windows 2008 instance and other virtualized server environments. This document should also apply to physical servers with no virtualization.
Hardware and Software Requirements
If you do not have physical access to the server, you will need a remote desktop tool in order to be able to administer the server.
Windows Server 2008 RC2
8G RAM (recommended)
100G+ HD (10k RPM recommended)
This is a Living Document. Please contribute enhancements
3
Software Summary
● Microsoft’s Web Platform Installer version 4.6 or greater
○ IIS
○ IIS Manager
○ SQL Server
○ PHP
○ Acquia Drupal (Recommended)
○ WinCache
○ URL Rewrite module
● GNUwin32 (Recommended)
● Unzipping tool
● Text editor
● Drupal WxTDrupal Distribution
● Git (recommended)
● Drush (recommended)
● Couchbase (or memcache)
This is a Living Document. Please contribute enhancements
4
Steps for Configuration
Step 1: Install PHP/IIS/MSSQL
The following procedure installs the IIS server in a configuration recommended for Drupal
(including the URLRewrite module and PHP SQL Server Driver 2.0
).
Before you begin, ensure that your Windows server installation is up to date and that you can download files from the Internet. You also may need to enable downloads .
1. From the web server, install the Web Platform Installer by navigating in IE to this
Windows webpage and clicking on the Launch Web Platform Installer link.
2. This will download a program that you will need to run as the administrator to complete the installation process.
3. Choose Windows Azure SDK for PHP, PowerShell & Crossplatform Command Line
Tools and then Finish IIS, PHP, MSSQL Installation.
More information on installing Drupal with the Windows Platform Installer is available from https://drupal.org/node/1130898
It is beneficial to install the GNUwin32 tools so that you can have additional control at the command line.
This is a Living Document. Please contribute enhancements
5
Step 2: Set Up the Drupal Environment
With PHP / MSSQL installed you can now set up the Acquia Drupal 7 environment with the Web
Platform Installer to ensure that Drupalspecific elements are applied. Drupal 7 now ships with an IIS web.config file, making this easier.
1. In your browser, visit http://www.microsoft.com/web/drupal , choose Acquia Drupal and follow the online instructions.
The Acquia installer provides you with a database user/password that is displayed at the bottom of the final screen.
2. Record the paths and the login credentials
3. Finish the installation and launch the site.
This profile uses MSSQL, but you may also decide to deviate from this later and install Drupal on either MySQL or PostgreSQL. This script modifies your php.ini file to ensure that each page is given sufficient memory to load.
This is a Living Document. Please contribute enhancements
6
Step 3: Install Acquia Drupal 7
Your Drupal code & database is now in place, but you will need to go through the process of installing Acquia’s Drupal 7. Ultimately this is a test environment to verify that your server is properly configured for Drupal core. This will also generate some files and folders that you can copy later into your Drupal WET installation. First let’s complete the installation process to verify that Drupal core is working properly.
The installer above should load IE with http://localhost/acquiadrupal/install.php
which will then walk through a standard Drupal 7 installation:
There are a number of useful videos from MSDN where you can learn more about using PHP within Windows. One steps through how to deploy Drupal with the Web Platform Installer.
http://channel9.msdn.com/Series/PHPatScaleontheMicrosoftPlatform
This should give you a fully operational Drupal install. Check http://localhost/acquiadrupal/admin/reports/status for configuration errors.
This is a Living Document. Please contribute enhancements
7
If there aren’t errors, you will be able to leverage these two directories for your new WETkit install and in Step 4:
C:/inetpub/wwwroot/acquiadrupal/includes/database/sqlsrv/
C:/inetpub/wwwroot/acquiadrupal/sites/default/
At this point you should verify that “clean URLs” (i.e. URLs that do not contain PHP syntax such as ?q=) are generated for your site. If not, consult the Clean URL documentation on Drupal.org
or Chris Larson’s blog .
This is a Living Document. Please contribute enhancements
8
Step 4: Preparing WET
Download the Web Experience Toolkit from Drupal.org
, decompress the file, and move the
resulting folder to
C:\inetpub\wwwroot\wetkit
Copy the sqlsrv directory found inside the Acquia installation from
C:\inetpub\wwwroot\acquiadrupal\includes\databases\sqlsrv to the Wetkit equivalent at
C:\inetpub\wwwroot\wetkit\includes\databases\sqlsrv
Copy over the default sites folder from:
C:/inetpub/wwwroot/acquiadrupal/sites/default/ to the Wetkit equivalent at:
C:/inetpub/wwwroot/wetkit/sites/default/
You will need to edit the settings.php folder in this directory in Step 6.
A tool such as 7Zip or WinZip may be required to decompress the WETkit Drupal distribution.
This is a Living Document. Please contribute enhancements
9
Step 5: Add a Web Site
1. Open IIS Manager
2. Right click on Sites, select Add Web Site and follow the prompts.
Alternatively, you can add a site from the command prompt:
%systemroot%\system32\inetsrv\APPCMD add site /name:MyNewSite
/bindings:"http/*:81:" /physicalPath:"C:\MyNewSite"
More information on Appcmd.exe is available from: http://technet.microsoft.com/enus/library/cc772200(v=ws.10).aspx
There is more information on configuring IIS using the IIS Manager here: http://www.trainsignal.com/blog/windowsserver2008iis7
This is a Living Document. Please contribute enhancements
10
Step 6: Configure settings.php
Edit the default settings directory provided by Acquia in the new wetkit directory:
C:\inetpub\wwwroot\wetkit\sites\default\settings.php
Edit the settings.php file to specify the database configuration, the following is based on the
Acquia Drupal 7 settings.php file:
$databases = array( 'default' => array( 'default' => array ('database' =>
'acquiadrupal7665', 'username' => 'ad7user665', 'password' => 'K#|!]ctdV5aj', 'host' =>
'.\SQLExpress', 'driver' => 'sqlsrv', 'prefix' => '' ) ) );
Note that you will want to have a unique database, username & password for each Drupal site.
In the settings.php file uncomment this line:
$conf['allow_authorize_operations'] = FALSE;
To specify the temp directory, add this line:
$conf['file_temporary_path'] = 'C:\inetpub\temp';
Give IIS_User write permissions to C:\inetpub\temp. Drupal often needs access to a temporary folder like this to store uploaded files or session information.
It is a best practice to set a salt outside of the document root for security reasons. Drupal will function if you leave it blank, but adding a line like this (with a random string in the salt.txt file) will be more secure:
$drupal_hash_salt = file_get_contents('C:\inetpub\salt.txt');
This is a Living Document. Please contribute enhancements
11
Step 7: Set up the MSSQL Database
You will want to set up an empty MSSQL database for each instance of Drupal.
The database must use a unicode caseinsensitive collation (e.g.
SQL_Latin1_General_CP1_CI_AI).
Create a blank database
1. Open Microsoft SQL Management Studio.
2. Connect to the database engine using database administrator credentials.
3. Expand the server node.
4. Right click Databases and select New Database.
5. Enter a database name and click OK..
Create a new login and map it to the database
1. In Object Explorer, expand the folder of the server instance in which you want to create the new login.
2. Rightclick the Security folder, point to New, and select Login.
3. In the Login – New dialog box, on the General page, enter the name of a user in the Login name box.
4. Select SQL Server authentication.
5. In the Password box, enter a password for the new user. Enter that password again into the Confirm Password box. Do not enforce password reset.
6. Select User Mapping on the left, then select the database created in the previous step.
Select db_owner at the bottom.
Note there are a few known issues with MSSQL:
● https://github.com/wetboew/wetboewdrupal/issues/946
● https://github.com/wetboew/wetboewdrupal/issues/379#issuecomment870503
0
Step 8: Installing WET
This is a Living Document. Please contribute enhancements
12
In a web browser navigate to http://locahost/wetkit/install.php
Once you are sure that your vanilla instance of WET is running properly on your server environment then you should be confident that your server will be able to run your department’s live web server. You can develop your WET site locally and then transfer your content from your development site to your production Windows server.
If you have an external IP address pointed at this server, you can also navigate to it directly and verify that it is working at this time. If you want to compare the install with a generic installation, you can quickly launch a sandbox to compare online: http://www.simplytest.me/project/wetkit
Note: You may need to increase your PHP memory_limit to 512M and the max_execution_time
to 300 for the installation.
This is a Living Document. Please contribute enhancements
13
Additional Notes
Migrating an Existing WET Instance
If you are migrating an existing installation of WET you can simply copy over the Drupal root filesystem and database. Make sure to clear cache after doing so.
drush @sites cc all
Login and ensure that your site is behaving as expected. Check the logs & Status report pages to verify that all is behaving properly.
Other Server Configs: Cron
Cron is a general purpose Linux program to run regularly occurring events. It’s just a daemon to execute scheduled commands.
There are a number of options documented here for setting up cron in Windows
( https://drupal.org/node/31506 ), but this worked well for me:
Run cmd.exe as Administrator, then enter the command:
C:\Windows\system32>schtasks /create /sc HOURLY /tn DevCron /tr "cmd.exe 'curl silent
compressed http://[[hostname]]/cron.php?cron_key=EXAMPLE_RANDOM_KEY'" /ru SYSTEM
Install Drush (Strongly recommended)
Use the Drush installer to set up Drush 6.x.
http://www.drush.org/drush_windows_installer
This is a Living Document. Please contribute enhancements
14
Navigate to the Drupal root directory and test to see that Drush works and which version you are running by running drush version.
Run C:\Program Files (x86)\Drush\DrushEnv.bat after installation to add drush.exe
to the PATH
You may need to set the system PATHS by going to
Control Panel > System > Advanced System
Settings > Environment Variables
Git, Memcache (Optional)
Most Drupal developers use Git for version control. You can install Git from: http://gitscm.com/download/win
You can keep the defaults except the installation path and select "Run Git from the Windows
Command Prompt"
Drupal can cache database queries and other chunks in Memcache or Couchbase . Both can be installed, but Couchbase seems to be better supported for Windows:
This is a Living Document. Please contribute enhancements
15
Agree to increasing the number of ephemeral ports (MaxUserPort). Full installation instructions are available .
If you’re using Windows and can’t move to Git then you’re probably using Team Foundation
Server for source control. There's a TFS plugin available from Microsoft for Eclipse but if one wishes to use another IDE then it must go through a subversion bridge .
This is a Living Document. Please contribute enhancements
16
Other Configuration
Disabling execution of PHP in user-uploaded files https://groups.drupal.org/node/226059
Web.config content to be put in the "files" directory:
<configuration>
<system.webServer>
<handlers>
<clear />
<add name="StaticFile" path="* " verb="* " modules="StaticFileModule" resourceType="Either" requireAccess="Read"
/>
</handlers>
</system.webServer>
</configuration>
Install PHP APC (optional)
The Alternative PHP Cache (APC) provides a free, open, and robust framework for caching and optimizing PHP intermediate code.
http://docs.moodle.org/22/en/Installing_APC_in_Windows
Check SMTP settings
https://groups.drupal.org/node/241213#comment781593
Install WinCache
http://ruslany.net/2011/04/wincacheandwordpresspluginupgradeproblem/
Drupal Modules for Windows environments
● LDAP
● Driver for SQL Server
Videos and Presentations
● Australian Gov http://www.youtube.com/watch?v=XeNke3KI9mc&feature=youtu.be
● Install PHP, MySQL & Drupal on Windows Server 2008
This is a Living Document. Please contribute enhancements
17
http://www.youtube.com/watch?v=tSRV87ivUg
● Windows Loves Drupal http://www.slideshare.net/AcquiaInc/windowslovesdrupal
Related Links
● Drupal.org Wiki on Installing Drupal on Windows
● Drupal Groups Discussion on Drupal on Windows
● IISAID: Your Authoritative and Independent IIS Resource
● Install Drupal on IIS from IIS.net
● CSE COTS Security Guidance for Windows
● CSE Windows Server 2003 Recommended Baseline Security
● Brian Swan’s Blog on Deploying Drupal at Scale on the Microsoft Platform
● Micah Webner’s Blog on Drupal 7 on Microsoft Windows Server
● Bill Speers’ blog on Installing Drupal on IIS7 / Server 2008 R2
● Amazon EC2 Running Microsoft Windows Server & SQL Server
● Stack Exchange Question on Applying a Security Baseline for Windows 2008
Related Books
● Integrating PHP With Windows
● Windows Server 2008: Security Resource Kit
Troubleshooting
Fatal error: Undefined class constant 'SQLSRV_ATTR_DIRECT_QUERY'
Run a PHP file that contains the code <?php phpinfo(); ?> and check the location of the Loaded
Configuration File. Make sure you are working on the right version of PHP. Next check to see if the SQLSRV PDO driver is installed
C:\Program Files (x86)\PHP\v5.3\ext
Check that Microsoft Drivers 3.0 for PHP for SQL Server are downloaded and installed properly to the right directory. You may have PHP installed in more than one place and if so you need to specify the right directory.
Look to see if the PHP PDO modules are available by typing at the command prompt: php m
The PHP directive "extension_dir" should contain an absolute file path.
The 3.x version of the PHP drivers can be downloaded from: https://www.microsoft.com/enca/download/details.aspx?id=20098
Install and restart PHP from the IIS Manager.
Troubleshooting File Permissions
A common point of difficulties is ensuring that you have proper file permissions. With icacls you
This is a Living Document. Please contribute enhancements
18
can grant access to Drupal’s settings.php and the files directory.
Set permissions using something like: cd C:\inetpub\wwwroot icacls sites\default\settings.php /grant BUILTIN\IIS_IUSRS:(W) icacls sites\default\files /grant BUILTIN\IIS_IUSRS:(W) icacls sites\default /grant IIS_IUSRS:(OI)(CI)(RX,W) or icacls sites\default\settings.php /grant BUILTIN\IIS_IUSRS:(M) icacls sites\default\settings.php /reset md sites\default\files icacls sites\default\files /grant BUILTIN\IIS_IUSRS:(OI)(CI)(M)
Notice that in the file properties for the sites/default directory, that the IUSR user has write permissions.
Ensure that write permission on settings.php is removed after the installation is complete. If write permission was not removed automatically by the installer, execute the following: icacls sites\default\settings.php /reset
This is a Living Document. Please contribute enhancements
19
Λήψη
Διαφήμιση