Search code examples
windowslaraveliisjobs

Permission Issue for laravel APP QUEUE in windows server 2012


We have a laravel app (Version 5.5*) deployed in WIndows Server 2012 R2. But our development stack is LEMP. Same codebase works fine in development STACK but fails in WINDOWS SERVER.

Problem:

In our App, there is a REPORT DOWNLOAD queueable job which reads data from database table and generates an excel file using box/spout package(version 2.7) depending on user input date range (daily,weekly,monthly, etc) .

When running the queue:work command from cmd as administrator, $writer->openToFile(‘path/to/file’) throws an error : failed to open stream : no such file or directory.

See this image for code snippet throwing error

Solutions I tried:

  • Setting right permissions(full control Read & write) for Storage folder of my project (For Users, IIS_IUSRS,IUSR)
  • Setting right permissions(full control Read & write) for C:windows\Temp folder (For Users, IIS_IUSRS,IUSR)
  • Created symlink for storage folder inside public

FYI:

  • OS: windows server 2012 r2
  • PHP: 7.2*
  • Laravel: 5.5.*
  • box/Spout package: 2.7.*

Solution

  • ** AT LAST GOT THE SOLUTION AFTER GOING THROUGH ANSWERS OF OTHER QUESTIONS RELATED TO THIS PROBLEM **

    You can follow the following procedure:

    • Go to IIS Manager
    • Select your desired project (For example: myexampledomain.com) listed under Sites

    • Go to Security tab and you'll see the users listed with their permissions on the folder.

    • Now, click Edit button to go to a new window and click Add. In the text box,type IIS AppPool\MyApplicationPoolName.In our example it should be IIS AppPool\myexampledomain.com.

    • Click Check Name and you'll see the test change with underline.

    • Click Ok. Add the appropriate permission(Modify,read,write) to the newly created user.

    That's it!!!

    Thanks to all for responding.