abwilliams72's avatar

IIS7 Laravel 5

Hello everyone. I'm trying to get Laravel 5 working on IIS7. I have reviewed the following posts: https://laracasts.com/discuss/channels/general-discussion/does-anybody-use-iis-7-and-laravel-42

http://alvarotrigo.com/blog/installing-laravel-4-in-windows-7-with-iis7/

I know, call me crazy for using IIS, however in my work environment, we use "Windows Server" platform and I have another personal project that requires the use of IIS. For something small, it would be simple enough to use WAMP, but I can use that @ work...

I get a blank screen and nothing seems to happen... No error page or anything. Where there significant changes from 4 -> 5 that would cause this?

Laravel noob here, so please be gentle... ;)

0 likes
29 replies
bashy's avatar

Storage folder has write permissions for webserver user? Think it's USER in IIS.

1 like
suncoastkid's avatar

I run Laravel on IIS7... bashy is right except it's IUSR. Right click->properties->sharing on the storage folder and give IUSR read/write access.

abwilliams72's avatar

No joy...

I can confirm that IIS works with PHP and the appropriate ini settings have been completed.
Phpinfo(); page displays as expected. Installed composer, then laravel installer as per the laravel docs. Installed laravel at the root of the wwwroot folder via the following command: "laravel new laravel" Verified file structure. Set IIS_IUSRS to have full control on the "storage" folder @ C:\inetpub\wwwroot\laravel\storage. Imported the .htaccess file into URL Rewrite and saved the resulting web.config file at the root of the C:\inetpub\wwwroot\laravel\public folder per Alvaro's tutorial. I still get just a blank page when I visit http://localhost/laravel/public/index.php... No errors or anything. #frustrated

abwilliams72's avatar

Yeah, Laragon defeats the purpose of what I'm trying to accomplish, an IIS 7 install... Laravel on a Windows stack is the goal, not a WAMP stack either. As I said in my initial description, I don't want to use apache/WAMP...

Thanks for the input though!

#headscrathing

0nly_tom's avatar

Hello all,

Managed to get IIS 7.5 and Laravel 5 to boot up into the Welcome page (which is a start). Follow this tutorial until the install of Larvel, stop there : http://alvarotrigo.com/blog/installing-laravel-4-in-windows-7-with-iis7/

Locate php.ini or rename php.ini-development to php.ini, needless to say this is for a development. Uncomment the following lines:

extension=php_mbstring.dll
extension=php_exif.dll 
extension=php_openssl.dll
extension=php_pdo_mysql.dll <- for mysql
extension=php_mysql.dll <- for mysql
extension=php_mysqli.dll <- for mysql
extension=php_pdo_pgsql.dll <- for pgsql
extension=php_pgsql.dll <- for pgsql

open cmd and follow: restart IIS with: iisreset /restart goto your wwwroot folder and install laravel: composer create-project laravel/laravel --prefer-dist

Run: cacls laravel /t /g everyone:f This will help with the permissions problems I was having ie: blank screen. You could run it only on you storage folder

Download URL Rewite from http://www.iis.net/downloads/microsoft/url-rewrite

Go to the public folder and create a file Web.config. Insert

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
          <rules>
            <rule name="Rule 1" stopProcessing="true">
              <match url="^(.*)/$" ignoreCase="false" />
              <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
            </rule>
            <rule name="Rule 2" stopProcessing="true">
              <match url="^" ignoreCase="false" />
              <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php" />
            </rule>
          </rules>
        </rewrite>
    </system.webServer>
</configuration>        

I might have left something out. Let me know please

da_Mask's avatar

I'm trying to get one of these up and running. I had a 4.2 site running, but have not managed to get a Laravel 5.1 site to work with IIS. Just the blank white page.

0nly_tom's avatar

Set error_reporting = E_ALL in your php.ini file and post your error please.

da_Mask's avatar

That is already set on my php.ini file. Sorry, you've lost me already

0nly_tom's avatar

Once you've switch on error_reporting = E_ALL, you should get an error. Just remember that the index.php file is located in public folder. If you installed Laravel in you wwwroot directory then the URL will be http://localhost/laravel/public/

Edit: Try restarting IIS by iisreset /restart

da_Mask's avatar

Ok, I've just done a fresh install of Laravel 5.1.1, following your instructions mostly. I had to change the permissions on the storage folder (I used the properties dialog) and add Users, not just IIS_IUSRS for some reason. I now have "Simplicity is the essence of happiness." page, so its a start. Thanks. Is there a danger in having the Users having full permissions on the storage folder?

0nly_tom's avatar

If development no, production yes. I'm still trying to figure out why IIS_IUSRS isn't working. To be honest, I just sort it out today. Still playing around with it.

WayneLuke's avatar

What are you using for the redirects? I would suspect that you would need something like Microsoft's URL Rewrite and convert the .access to web.config.

Other than that, if you turn on display errors in PHP, is the page still blank? Are you using Fastcgi with the NTS version of PHP as is recommended for IIS 7?

abwilliams72's avatar

@0nly_tom and others...

So, I'm happy to hear I'm not the only one having these issues with IIS, but I'm sorry to hear my fellow coders are as frustrated as I am... >:)

As for my installation, still a no go... I threw in the towel and haven't been back until recently. PHP on IIs isn't an issue, nor are the extensions. This is where & why bulletproof instructions need to be made for Laravel / IIS / PHP.

abwilliams72's avatar

Success! I will be doing a complete write up on this. Thanks to Only_tom and others. Its not perfect but I was able to hack my way through it. I still don't like the "cacls storage /t /g everyone:f" but I will live with it for now.

Since I have to use IIS at work, this will come in very handy...

Thanks to you all and I will post a followup with complete instructions.

Cheers!

abwilliams72's avatar
abwilliams72
OP
Best Answer
Level 2

@Only_tom et al

So, with special thanks to Only_tom and Alvaro Trigo @ http://alvarotrigo.com/blog/installing-laravel-4-in-windows-7-with-iis7/. I have been able to get IIS / PHP / Laravel to jive together... Here is the full rundown:

Ensure PHP and IIS are working together before proceeding any further. You should be using FastCGI with IIS and the Non-Thread Safe (NTS) versions of PHP(http://php.net/manual/en/install.windows.iis7.php). Quick sanity check with your phpinfo() file:

    <?php
        phpinfo();
    ?>

Verify you have made the following changes to your php.ini:

extension_dir = "ext"
cgi.force_redirect = 0
cgi.fix_pathinfo = 1
fastcgi.impersonate = 1
fastcgi.logging = 0
extension=php_mbstring.dll
extension=php_exif.dll      ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_openssl.dll
extension=php_pdo_mysql.dll
date.timezone = "ENTER YOUR TIMEZONE HERE"
session.entropy_length = 32

Download and install composer for windows. (https://getcomposer.org/Composer-Setup.exe)

Open a command prompt with administrative access and restart IIS with the following command:

iisreset /restart 

CD to the "C:\inetpub\wwwroot" folder and install laravel: ***This will take a few minutes.

C:\inetpub\wwwroot>composer create-project laravel/laravel --prefer-dist  

Grant full control of the folder "C:\inetpub\wwwroot\laravel\storage" to IUSR ***This is very important!

Download URL Rewite from http://www.iis.net/downloads/microsoft/url-rewrite

Create the following file and save it as "Web.config" to the "C:\inetpub\wwwroot\laravel\public" folder. ***You will need administrative access to perform this task!

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
          <rules>
            <rule name="Rule 1" stopProcessing="true">
              <match url="^(.*)/$" ignoreCase="false" />
              <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
            </rule>
            <rule name="Rule 2" stopProcessing="true">
              <match url="^" ignoreCase="false" />
              <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php" />
            </rule>
          </rules>
        </rewrite>
    </system.webServer>
</configuration> 

For good measure, restart IIS again. Open a command prompt with administrative access and type:

iisreset /restart 

Visit http://localhost/laravel/public/index.php and hopefully you will see "Laravel 5"

I sure hope this helps anyone trying to install Laravel 5 on IIS.

Again, special thanks to Only_tom and Alvaro Trigo @ http://alvarotrigo.com/blog/installing-laravel-4-in-windows-7-with-iis7/ .

2 likes
tomasz-sita's avatar

RE setting write permissions on /storage folder... check what user actually tuns the PHP under your IIS setup - get_current_user() In my case it was "IUSR", so I added custom permissions for this user: /storage folder properties/security/Edit/Add/... find the user, set the permissions and you're done :)

jmrieger's avatar

In my case, I was trying to modify IIS to make the /laravel/public/ folder the base folder for any request for the site. I achieved it by following abwilliam's guide above, as well as this KB to help change the base folder returned for requests: https://kb.intermedia.net/article/1982

My Web.config file, as placed in the root directory of the IIS website (not /laravel/public, just /):

<rewrite>
    <rules>
        <rule name="Rewrite rule1 for laravel_rewrite">
            <match url=".*" />
            <conditions>
                <add input="{laravel_rewrite:{HTTP_HOST}}" pattern="(.+)" />
            </conditions>
            <action type="Rewrite" url="{C:1}{REQUEST_URI}" appendQueryString="false" />
        </rule>
        <rule name="Rule 2" stopProcessing="true">
            <match url="^" ignoreCase="false" />
            <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            </conditions>
            <action type="Rewrite" url="/laravel/public/index.php" />
        </rule>
    </rules>
    <rewriteMaps>
        <rewriteMap name="laravel_rewrite">
            <add key="mysite.com" value="/laravel/public" />
        </rewriteMap>
    </rewriteMaps>
</rewrite>

It would be nice to have the information here added to the Laravel installation docs.

1 like
kclark6595's avatar

Ok, at my wits end.

Have a Laravel 5 project I have been building offline, using the built in PHP server to test. Now I want to move to an IIS 7.5 server. Followed all the instructions above and all I get is a blank white screen.

I have verified all my PHP settings via phpinfo. I have added the IIS_IUSR account giving full control to the storage folder I have tried my root folder as c:\inetpub\wwwroot and c:\inetpub\wwwroot\public I have verified index.php is my default doc I even tried deleting my web.config and importing using url_rewrite of IIS, no luck.

The one place I differ from the instructions is the installation of Laravel. Instead of installing via composer, I am copying the main folder from my development location and altering the .env file accordingly.

I was able to get one error message and that was error in RouteCollection.php when I had the folder root set to my public folder and I tried to use v-webserver/public as my URL.

I wouldnt think it should be this hard to do, but then I remembered I am dealing with Microsoft.

Any suggestions of where to check of what I missed? Thanks!

leoyordi's avatar

Many thanks to all answers in this post!!!

About "Grant full control of the folder "C:\inetpub\wwwroot\laravel\storage" to IUSR ***This is very important!"

My case: Windows 10 Pro (1511) and IIS v.10.0.10586.0.

I have to grant full control of the folder "C:\inetpub\wwwroot\laravel" to Users too.

1 like
jpserame's avatar

Hello all!

I did the steps above and got to the laravel/public page on Laravel 5 IIS7.5.. The problem is that the other routes does not display.

Route::get('/something', function () {
    return view('welcome');
});

returns a 404 - File or directory not found server error. Anything I missed? Thank you!

webid's avatar

I have got the same problem as jpserame. But laravel works fine when index.php in the url. So myserver.com/index.php/login works fine, but myserver.com/login not.

Working @customer with iis8.5

Thanks in advance!

webid's avatar

Well after a long search, i found the solution. The rewrite module was not working properly on the iis server....

  1. The fix is in a complete reinstall of the urlrewrite2 module.

  2. Edit the next file with NOTEPAD!! C:\Windows\System32\inetsrv\Config\applicationHost.config

Insert into the section <globalModules>

<dd name="RewriteModule" image="%windir%\System32\inetsrv\rewrite.dll" />

Then restart the iis and

HAPPY LARAVEL

bscharf's avatar

Weird iis7 error, the laravel welcome page loads on initial request but after that I receive reflection exception class web does not exist. After about 10-15 minutes it will work again, but the error always returns after a refresh. Any ideas?

Jerlag_01's avatar

I'm running everything on windows now, but now i have found a webplatform to control my minecraft community punishments with but it's using composer as build. Anyone that can help me setting up composer, because the described steps are not working for me. I'm having issues with the install of composer itself.

Running Windows Server 2012 R2 PHP 7.0 (possible versions also installed: 5.6; 5.4) IIS 8

mbirir's avatar

@ABWILLIAMS72 - Hi had a question what can I do so that I don't have to navigate to localhost/laravel/public/index.php or localhost/laravel/public instead I just use localhost/laravel?

Please or to participate in this conversation.