{"id":174,"date":"2016-02-08T20:46:22","date_gmt":"2016-02-08T18:46:22","guid":{"rendered":"http:\/\/www.gadjev.com\/?p=174"},"modified":"2017-04-23T01:37:23","modified_gmt":"2017-04-22T23:37:23","slug":"installing-magento-ce-2-0-on-windows-server-2012-r2-iis-8-5","status":"publish","type":"post","link":"https:\/\/www.gadjev.com\/2016\/02\/08\/installing-magento-ce-2-0-on-windows-server-2012-r2-iis-8-5\/","title":{"rendered":"Installing Magento CE 2.0 on Windows Server 2012 R2 IIS 8.5"},"content":{"rendered":"

Magento (https:\/\/magento.com\/<\/a>) is one of the top 3 Open Source ecommerce platforms. Designed to run on Linux & Apache it could be a challenge to get it running on Windows IIS right from the first time since officially Magento is not supported on IIS.<\/p>\n

Where to start from:
\n1. Deploy IIS 8.5<\/strong> using Server Manager and add the SMTP server feature(or use an external SMTP server). It will be required later to send order emails from Magento
\nInstall URL-rewrite IIS add on from
http:\/\/www.iis.net\/downloads\/microsoft\/url-rewrite<\/a>
\n2. Install a MySQL server<\/strong> (or have a remote one)
\n3. Install php<\/strong> (5.5.x, 5.6.x or 7.0.2)
http:\/\/devdocs.magento.com\/guides\/v2.0\/install-gde\/system-requirements.html<\/a> and enable the required PHP modules as per the official magento documentation.
\n4. Download Magento<\/strong>
https:\/\/www.magentocommerce.com\/download<\/a> , extract it in C:\\inetpub\\wwwroot<\/strong> (or a custom one ex. C:\\Websites\\Magento<\/strong> – something I recommend in general )
\n5. Configure php settings<\/strong> required by magento (in this example php 5.6.x was used)
\nThe magento requirement says you have to configure these as a minimum
http:\/\/devdocs.magento.com\/guides\/v2.0\/install-gde\/prereq\/php-ubuntu.html#instgde-prereq-timezone<\/a>
\nThey are safe to be configured in you global php.ini<\/strong> file”<\/p>\n

memory_limit = 768M
\nalways_populate_raw_post_data = -1
\nasp_tags = Off
\ndate.timezone = Europe\/Sofia http:\/\/php.net\/manual\/en\/timezones.php<\/strong><\/p><\/blockquote>\n

Magento however customize some php settings using the .htaccess file. Since we’ll be using IIS these have to be converted in IIS aware setup (web.config<\/strong>). A good article how to configure php settings per IIS website can be found here http:\/\/www.iis.net\/learn\/application-frameworks\/install-and-configure-php-on-iis\/enable-per-site-php-configuration-on-iis-60-and-iis-7-and-above<\/a>
\nThen you can find the cutomized PHP settings in the .htaccess file in the root magento directory
\nEdit your global php.ini<\/strong> file and add
\nuser_ini.filename = “.user.ini”<\/strong><\/p>\n

Then create an .user.ini<\/strong> file in the root magento directory<\/strong> and copy the .htaccess php settings content for your PHP version. In our case the content for php 5.6 is:<\/p>\n

memory_limit = 768M
\nmax_execution_time = 18000
\nsession.auto_start = Off
\nzlib.output_compression = On
\nsuhosin.session.cryptua = Off<\/em><\/strong><\/p><\/blockquote>\n

Create another .user.ini<\/strong> file inside pub directory<\/strong> and take the settings from pub\\.htaccess:<\/p>\n

memory_limit = 256M
\nmax_execution_time = 18000
\nsession.auto_start = Off
\nzlib.output_compression = Off
\nsuhosin.session.cryptua = Off<\/em><\/strong><\/p><\/blockquote>\n

6.Converting Magento Apache based .htaccess into IIS web.config<\/strong>
\n6.1 URL Rewrite Rules<\/strong>
\nYou can use the URL-rewrite IIS settings to import .htaccess URL rewrite rules (URL Rewrite–>Import Rules–>Browse the file and select Import–>remove the non-convertable settings and click apply.
\nAlternatively place this in web.config into the magento root directory<\/strong><\/p>\n

<?xml version=”1.0″ encoding=”UTF-8″?>
\n<configuration>
\n<system.webServer>
\n<rewrite>
\n<rules>
\n<rule name=”Imported Rule 1″ stopProcessing=”true”>
\n<match url=”.*” ignoreCase=”false” \/>
\n<conditions logicalGrouping=”MatchAll”>
\n<add input=”{REQUEST_METHOD}” pattern=”^TRAC[EK]” ignoreCase=”false” \/>
\n<\/conditions>
\n<action type=”Redirect” url=”{R:0}” redirectType=”Temporary” \/>
\n<\/rule>
\n<rule name=”Imported Rule 2″ stopProcessing=”true”>
\n<match url=”^(.*)$” ignoreCase=”false” \/>
\n<conditions logicalGrouping=”MatchAll”>
\n<add input=”{URL}” pattern=”^\/mobiledirectoryhere\/.*$” ignoreCase=”false” negate=”true” \/>
\n<add input=”{HTTP_USER_AGENT}” pattern=”&quot;android|blackberry|ipad|iphone|ipod|iemobile|opera” ignoreCase=”false” \/>
\n<\/conditions>
\n<action type=”Redirect” url=”\/mobiledirectoryhere\/” redirectType=”Found” \/>
\n<\/rule>
\n<rule name=”Imported Rule 3″ stopProcessing=”true”>
\n<match url=”.*” ignoreCase=”false” \/>
\n<conditions logicalGrouping=”MatchAll”>
\n<add input=”{REQUEST_FILENAME}” matchType=”IsFile” ignoreCase=”false” negate=”true” \/>
\n<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” ignoreCase=”false” negate=”true” \/>
\n<\/conditions>
\n<action type=”Rewrite” url=”index.php” \/>
\n<\/rule>
\n<\/rules>
\n<\/rewrite>
\n<\/system.webServer>
\n<\/configuration><\/p><\/blockquote>\n

<\/p><\/blockquote>\n

Place this inside pub\\media\\web.config<\/strong><\/p>\n

<?xml version=”1.0″ encoding=”UTF-8″?>
\n<configuration>
\n<system.webServer>
\n<rewrite>
\n<rules>
\n<rule name=”Imported Rule 4″ stopProcessing=”true”>
\n<match url=”.*” ignoreCase=”false” \/>
\n<conditions logicalGrouping=”MatchAll”>
\n<add input=”{REQUEST_FILENAME}” matchType=”IsFile” ignoreCase=”false” negate=”true” \/>
\n<\/conditions>
\n<action type=”Rewrite” url=”..\/get.php” \/>
\n<\/rule>
\n<\/rules>
\n<\/rewrite>
\n<\/system.webServer>
\n<\/configuration><\/p><\/blockquote>\n

<\/p><\/blockquote>\n

Place this inside pub\\static\\web.config<\/strong>
\n<\/p>\n

<?xml version=”1.0″ encoding=”UTF-8″?>
\n<configuration>
\n<system.webServer>
\n<rewrite>
\n<rules>
\n<rule name=”Imported Rule 5″ stopProcessing=”true”>
\n<match url=”^version.+?\/(.+)$” ignoreCase=”false” \/>
\n<action type=”Rewrite” url=”{R:1}” \/>
\n<\/rule>
\n<rule name=”Imported Rule 6″ stopProcessing=”true”>
\n<match url=”.*” ignoreCase=”false” \/>
\n<conditions logicalGrouping=”MatchAll”>
\n<add input=”{REQUEST_FILENAME}” matchType=”IsFile” ignoreCase=”false” negate=”true” \/>
\n<\/conditions>
\n<action type=”Rewrite” url=”..\/static.php?resource={R:0}” appendQueryString=”false” \/>
\n<\/rule>
\n<\/rules>
\n<\/rewrite>
\n<\/system.webServer>
\n<\/configuration><\/p><\/blockquote>\n

Place this inside pub\\web.config<\/strong><\/p>\n

<?xml version=”1.0″ encoding=”UTF-8″?>
\n<configuration>
\n<system.webServer>
\n<rewrite>
\n<rules>
\n<rule name=”Imported Rule 7″ stopProcessing=”true”>
\n<match url=”.*” ignoreCase=”false” \/>
\n<conditions logicalGrouping=”MatchAll”>
\n<add input=”{REQUEST_METHOD}” pattern=”^TRAC[EK]” ignoreCase=”false” \/>
\n<\/conditions>
\n<action type=”Redirect” url=”{R:0}” redirectType=”Temporary” \/>
\n<\/rule>
\n<rule name=”Imported Rule 8″ stopProcessing=”true”>
\n<match url=”.*” ignoreCase=”false” \/>
\n<conditions logicalGrouping=”MatchAll”>
\n<add input=”{REQUEST_FILENAME}” matchType=”IsFile” ignoreCase=”false” negate=”true” \/>
\n<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” ignoreCase=”false” negate=”true” \/>
\n<\/conditions>
\n<action type=”Rewrite” url=”index.php” \/>
\n<\/rule>
\n<\/rules>
\n<\/rewrite>
\n<\/system.webServer>
\n<\/configuration><\/p>\n

<\/p><\/blockquote>\n

Make sure the rule name are unique in the deployment ! Otherwise you might get HTTP Error 500.52 – URL Rewrite Module Error<\/strong><\/p>\n


\n<\/strong> 6.2 Convert the Mime Types<\/strong><\/p>\n

[Update Needed]<\/em><\/p><\/blockquote>\n

6.3 Convert all Remaining Settings<\/strong><\/p>\n

[Update Needed]<\/em><\/p><\/blockquote>\n

7. NTFS permissions<\/strong>
\n“IIS APPPOOL\\ApplicationPoolIdentity<\/strong>” (ex. “IIS APPPOOL\\MagentoLive”) need to have :
\nREAD&EXECUTE<\/strong> access on the magento<\/strong> directory (C:\\Websites\\Magento)
\nMODIFY<\/strong> access on magento \\app\\etc<\/strong> directory (for security purposes this should be removed after the installation is complete
\nMODIFY<\/strong> access on magento \\var<\/strong> directory
\nMODIFY<\/strong> access on magento \\pub\\media<\/strong> directory
\nMODIFY<\/strong> access on magento \\pub\\static<\/strong> directory
\nMODIFY<\/strong> access on the PHP Temp directory<\/strong>\u00a0 (otherwise it throws an errors like “We’re sorry, an error has occurred while generating this email<\/strong>” on the Storefront or “Could not determine temp directory, please specify a cache_dir manually<\/strong>” in the Admin panel
\nIn case PHP Temp directory is not specified in php.ini then PHP takes the folder in the TEMP Environment variable (C:\\Windows\\Temp<\/strong> by default).<\/p>\n

The Default ACL on C:\\Windows\\Temp on Windows 2012 R2 is (icacls output)
\nC:\\Windows\\Temp CREATOR OWNER:(OI)(CI)(IO)(F)
\nNT AUTHORITY\\SYSTEM:(OI)(CI)(F)
\nBUILTIN\\Administrators:(OI)(CI)(F)
\nBUILTIN\\Users:(CI)(S,WD,AD,X)
\nBUILTIN\\IIS_IUSRS:(OI)(CI)(S,RD)
\nIn case magento is the single website on your IIS server you can directly grant the IIS_IUSERS MODIFY permissions
\nImportant Security Notice<\/strong>: for all magento directories where you grant write access make sure you remove scripts execution in IIS (go to each folder–>Handled-Mappings–>Edit Feature Permissions–> uncheck Script)
\n8. Setup PHP OpCache<\/strong> (don’t miss this step! – it’s a great performance boost<\/em>)<\/p>\n

Edit you global php.ini<\/strong> and insert:<\/p>\n

inside [php] section<\/strong>
\n zend_extension=php_opcache.dll (the DLL file must be present in your php extensions directory)<\/em>
\n inside [opcache] section<\/strong>
\nopcache.enable=1<\/em>
\n opcache.enable_cli=1<\/em>
\n opcache.memory_consumption=128<\/em>
\n opcache.interned_strings_buffer=8<\/em>
\n opcache.max_accelerated_files=4000<\/em>
\n opcache.use_cwd=1<\/em>
\n opcache.revalidate_freq=60<\/em>
\n opcache.fast_shutdown=1<\/em><\/p><\/blockquote>\n

9. Setup SSL on you IIS website<\/strong> – a lot of content exist on Internet how to do this. It doesn’t matter if you do this before or after the Magento Installation. It’s important to avoid using self-signed certificate.<\/p>\n

10. Magento Installation<\/strong>
\nThere are two ways to do this:
\nA) using the http:\/\/yoursite.com\/setup <\/strong>web based wizard<\/p>\n

or<\/p>\n

B) using command line<\/p>\n

\n

cd magentorootdirectory\u00a0<\/strong><\/p>\n<\/blockquote>\n

\n

php magento setup:install –admin-firstname John –admin-lastname Doe –admin-email user@example.com –admin-user admin –admin-password yourpassword –base-url http:\/\/yoursite.com –db-host=localhost –db-name DB –db-user DBuser –db-password yourDBpassword –use-rewrites 1 –use-secure-admin 1 –session-save db<\/strong><\/p>\n<\/blockquote>\n

List of support command line parameters can be found here http:\/\/devdocs.magento.com\/guides\/v2.0\/install-gde\/install\/cli\/install-cli-install.html<\/a><\/p>\n

When you install from the website the Magento installation may hang on<\/strong> (freeze on) Installing schema..<\/strong> or Upgrading schema..<\/strong> usually around 4% or 5%.
\nThis happens due to IIS FastCGI “Activity timeout” settings (by default 30 seconds)<\/strong><\/p>\n

Adjust the settings to a higher enough value to allow the setup to finish. ex. 3600<\/strong> (1h)<\/p>\n

Then retry the installation<\/strong> by :
\n– deleting magentorootdirectory\\app\\etc\\config.php and magentorootdirectory\\app\\etc\\env.php<\/em>
\n– dropping the MySQL DB tables<\/em>
\n– re-running the setup from http:\/\/yoursite.com\/setup<\/em>
\nUntil you retry the installation Magento website will return HTTP error 500 Internal Server Error<\/p>\n

The installation might fail to deploy the static content making Storefront and the Admin page looking badly formatted(missing pictures, CSS styles, js, etc).<\/strong> To resolve this run:<\/p>\n

“php bin\\magento setup:static-content:deploy en_US”<\/p><\/blockquote>\n

http:\/\/devdocs.magento.com\/guides\/v2.0\/install-gde\/trouble\/tshoot_no-styles.html<\/a>
\n
https:\/\/github.com\/magento\/magento2\/issues\/1312<\/a>
\nWhen using non en-US Locale<\/strong> (Admin–>Stores–>Configuration–>General–>Locale Options) even after deploying static content, the StoreFront will still be badly formatted (Admin will be now OK). Two ways to solve this:
\nA) Set en-US locale in the Admin panel
\nB) Deploy static content for your locale<\/p>\n

“php bin\\magento setup:static-content:deploy bg_BG”<\/p><\/blockquote>\n

http:\/\/devdocs.magento.com\/guides\/v2.0\/config-guide\/cli\/config-cli-subcommands-static-view.html<\/a><\/p>\n

11. Magento Store Configuration<\/strong><\/p>\n

[More updates will follow]<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"

Magento (https:\/\/magento.com\/) is one of the top 3 Open Source ecommerce platforms. Designed to run on Linux & Apache it could be a challenge to get it running on Windows IIS right from the first time since officially Magento is… <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,9],"tags":[],"class_list":["post-174","post","type-post","status-publish","format-standard","hentry","category-articles","category-it"],"_links":{"self":[{"href":"https:\/\/www.gadjev.com\/wp-json\/wp\/v2\/posts\/174"}],"collection":[{"href":"https:\/\/www.gadjev.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gadjev.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gadjev.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gadjev.com\/wp-json\/wp\/v2\/comments?post=174"}],"version-history":[{"count":13,"href":"https:\/\/www.gadjev.com\/wp-json\/wp\/v2\/posts\/174\/revisions"}],"predecessor-version":[{"id":187,"href":"https:\/\/www.gadjev.com\/wp-json\/wp\/v2\/posts\/174\/revisions\/187"}],"wp:attachment":[{"href":"https:\/\/www.gadjev.com\/wp-json\/wp\/v2\/media?parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gadjev.com\/wp-json\/wp\/v2\/categories?post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gadjev.com\/wp-json\/wp\/v2\/tags?post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}