Drush on Windows IIS server as localhost

Drush on Windows IIS server as localhost

by admin Saturday, March 5, 2022 - 11:07 0 comments
Credits
Joshua Aragon - unsplash image

Drush on Windows - getting it working!

Key steps

  • MySQL, Php for IIS Windows, Php Manager for windows, phpmyadmin
  • Composer and Php for composer on C drive (as requirements different from Php for windows IIS)
  • Registering the $path for composer, composer php in 'System Environment'
  • Composer install for drupal and dependencies including drush
  • Set up drush, drush launcher
  • Register $path to drush.phar on 'Local environment variables', to be able to call drush from docroot in your site directory

Modifying Windows Environment

Installing Drupal in Windows IIS requires a number of steps to enable php run in this environment.

Modifying the Windows Environment is necessary.
Go to Control Panel => Program => Turn Windows features On or off:
- enable must web related features; .Net 3.5, 4.5 advanced services Active Directory LDS Hyper-V (optional) Internet Information services (IIS) , IIS hostable web core Media features MMQS .. Microsoft print to PDF Simple TCIP services SMB ...SMB direct Telnet client, Windows (Hypervisor platform, Identity foundation, Powershell, Process Activation service, sandbox, Subsystem for Linux, TIFF filter, folders client (The most important is probably .Net, IIS, Active directory LDS, TCIP, Telnet and Subsystem for linux (Git bash, vscode and linux functionality))
 
Set up IIS server environment:
MySQL install (Community version from Oracle) requires Microsoft Visual C++ 64 which can be downloaded by via WebPlatformInstaller (linked to IIS) installing Once Php for IIS, PhpManager for IIS all installed, Download and install Php to C\program files\PHP and copy production.ini to php.ini, update appropriate configuration for IIS. On IIS using the links provided by Php manager for IIS, set up php environment: enabling extentions, php-cgi.exe, file upload size, memory limit, max upload size, etc. Previously it was possible to download the URL Rewrite module from WebPlatformInstaller, but this seem to fail as at March 2022. The following web link URL Rewrite module for IIS at time of writing works. Find and instal URL Rewrite module for IIS. This is absolutely necessary to allow drupal links to work (otherwise links would yield error pages or not display correctly).
 
Set up permissions
This is a critical step that ensures IISUSR can access relevant folders. There are a number of ways to change/modify permissions on relevant folders usually inherited from "inetpub/wwwroot" in C drive which is the default (but not necessarily always the case), to serve as localhost environment for IIS. This enables the server read/write to files recursively.
 
Create alias and path on the server
Identify localhost folders on IIS and set up alias / physical path etc using virtual or application path. This is important for pages to display correctly.

Composer Instal

Hopefully having resolved the initial steps, the process would now require attention to the following setting up and installing composer

Composer install of drupal core files using your preferred cml or development environment(git bash, vscode, sublime or atom etc).
Composer install Drush:

  • Composer require drush/drush
  • download Drush Launcher ) and (in my case) install in project directory.
  • Download drush.phar and save in project root. The instruction on the github link states to rename drush.phar to drush on Osx or Linux and possibly windows. Doing this in windows appears to trigger the error message "$ drush [preflight] The YAML value does not appear to be valid UTF-8.". This took me a good while to figure out what the source of the problem. As with such instances, scouring the web finally yielded insight into the problem. Thanks to How to Fix ParseException: The YAML value does not appear to be valid UTF-8". The error arises due to alteration of the UTF-8 encoding type (collation code) when the .phar extension is renamed to drush. By saving the file to its original name, IIS server no longer threw this error and Bingo problem solved.!
  •  

Update Environment variable (system properties > environment variables > $path. Not sure if this was still necessary for single site install but for multiple sites this might be useful.

Once the foregoing have been achieved the final steps are essentially deploying the site by creating the database and running installation partly or entirely via your preferred browser entering the url as localhost/example.com

  • Phpmyadmin or cml or MySQL workbench - create a database for the new drupal install.
  • Drush Install using command 'drush si'
  • Go to new website on your browser to complete installation
Location

51.489137775993, -0.17703794874251

Top

We use cookies on our website to support technical features that enhance your user experience.

We also use analytics & advertising services. To opt-out click for more information.