Problem installing on Windows

Problem installing on Windows

by Joseph Craig -
Number of replies: 19

I am trying to install Moodle 3.8.1 on a Windows 2016 server with IIS 10.  PHP is working.

I have installed all of the prerequisites, and have copied the Moodle files to my directory, and browse to the website to install.  

Error Message


I have set the permissions for the IIS user for the app pool running the website to have "full control" over the moodle, moodle\moodle, and moodle\moodledata directories.

I need some advice on what to do now ...

Average of ratings: -
In reply to Joseph Craig

Re: Problem installing on Windows

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Not a Windows person but it is still obviously having trouble writing to that folder. Try creating the moodledata folder and make sure that your permissions and ownership are applied recursively.
In reply to Emma Richardson

Re: Problem installing on Windows

by Joseph Craig -
Thanks.

I followed your suggestion and the error message turned into: Data directory (E:\moodle\moodledata) cannot be created by the installer.

Any other ideas?

(And I do understand that Windows/IIS puts me in the lunatic fringe, but this is a for an organization that requires it. Maybe I should try a Windows/Apache approach?)
In reply to Joseph Craig

Re: Problem installing on Windows

by Ken Task -
Picture of Particularly helpful Moodlers

I don't do windows either, but ... I made a new year's resolution 1st year of retirement to: a) never use Windows again.  b) never work for a 'lunatic' ... for any amount less than 1 Mil. (that ought to put me out of any running for the job!) smile

Error screen shared does show conditions of data directory.
They have not been met - does say '... will attempt to create ..'.

So how about, before you begin the install:
1. get a cert for the server/domain.
2. manually create E:\moodle\moodle and grant ownerships/permissions to read/write to the user of web service.
3. **Strongly consider** E:\moodledata\data for moodledata ... ie, don't put moodle's data directory in moodle code directory and grant the globe read/write.

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Problem installing on Windows

by Joseph Craig -
Ken,

Thanks for your reply.

1. Do you mean an SSL Certificate? I'm doing this work in a dev environment and the server is not connected directly to the internet. We'll certainly do that on the production side when it's needed.

2. E:\moodle is the home for both the moodle and the data directory. All directories have been granted read/write permissions to the IIS user account.

3. E:\ moodle is home to E:\moodle\moodle which is the directory for the moodle code, and E:\moodle\moodledata is the data directory.

The IIS User account should have the correct permissions, but it's not working. The only thing that makes sense to me is that I've specified the wrong account, but that doesn't make sense. As this is an IIS website, shouldn't the IIS user be active? Is there somewhere that Moodle specifies another user? Is there a configuration file for that?

As for the never use Windows again, that's a nice position to be able to take if it suits you. In this case, though, the "client" is a more than decent sized government organization ... but we don't need to go there.
In reply to Joseph Craig

Re: Problem installing on Windows

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Here is also a non-windows person

FYI, I take this position not because it is "nice", no, I had to go through walls, but "it suits" me, you are right there.

About the installation did you read https://docs.moodle.org/en/Installing_Moodle ?
In reply to Visvanath Ratnaweera

Re: Problem installing on Windows

by Joseph Craig -
Yes, I have read and continue to refer to that document. Thanks.
In reply to Joseph Craig

Re: Problem installing on Windows

by Ken Task -
Picture of Particularly helpful Moodlers

Can't resist ... so government IT decisions are 'infoulable'? :|

Ok ... moving forward ...

"Is there somewhere that Moodle specifies another user? Is there a configuration file for that?"

None of which am aware ... not in Moodle.   It's nothing more than an application running under web service.  How the web service is configured sits atop of apps.

Internal only ... ok, no cert ... but consider site to be development only.  Moving content from dev to production I would imagine needs to be backups of courses.

https://docs.moodle.org/38/en/Windows_installation

https://docs.moodle.org/38/en/Internet_Information_Services

Best of luck!

'SoS', Ken

Average of ratings: Useful (1)
In reply to Joseph Craig

Re: Problem installing on Windows

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The IIS site user account needs modify permissions to the Moodledata directory: here are some steps to do this.

From what others said:

  • I agree you should make the site HTTPS, a self-signed certificate is fine if it's just a test site.
  • I agree that the Moodle source code shouldn't contain the Moodledata directory: it's a writeable location within the site's source code and also a readable location with no security. I normally have a directory for the site containing a subdirectory for the Moodle source code and separate subdirectory for Moodledata, e.g. E:\moo.dnndev.me\moodle and E:\moo.dnndev.me\moodledata.
  • IIS is the best web server option for Microsoft Windows and strongly recommended over Apache on Windows, the latter having a lot of stability issues in my experience.
In reply to Leon Stringer

Re: Problem installing on Windows

by Joseph Craig -
Leon,

Thanks.

I have give full permissions for the IIS User to the moodle directory and also to moodle/moodle (the code directory) and moodle/moodledata.

Is there perhaps something in the IIS setup that I may have missed?
In reply to Joseph Craig

Re: Problem installing on Windows

by Usman Asar -
Picture of Plugin developers Picture of Testers

Joseph, please refer to the video HERE, you'll get sorted

In reply to Usman Asar

Re: Problem installing on Windows

by Mohamed Mourad Baouba -
Thank you, I will see and get you back.



Le lun. 20 janv. 2020 à 05:12, Usman Asar (via moodle.org) <
In reply to Usman Asar

Re: Problem installing on Windows

by Joseph Craig -
Thanks. Nice instructions, but they don't fix my problem.

I also tried installing on a second computer.

I installed PHP7.4.1. PHPManager is working in IIS, and clicking the phpinfo link works.

Moodle is returning the exact same error on the second maching - that it can't create the moodledata directory because of permissions.

I have the IIS User set for full control of moodle, moodle\moodle, and moodle\moodledata.

Something, somewhere is not working and I can't figure it out.
In reply to Joseph Craig

Re: Problem installing on Windows

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

You don't want the IIS user to have full permission to the source directory for security reasons. This is the reason for the suggestion that Moodledata should be a separate location to the source code directory and not within it.

Are you still having trouble or did the walkthrough that Usman posted get the site running?

I've just realised that the original error you posted said "Data directory (E:\moodle\moodledata) cannot be created by the installer". But you've presumably created the Moodledata directory now so presumably you're at least getting a different error because the installer should no longer be trying to create the directory if it already exists.

In reply to Leon Stringer

Re: Problem installing on Windows

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

An update to the instructions I posted on granting permission to write to the Moodledata directory: this is a little different if the IIS website's Anonymous Authentication has been set to use the application pool identity.

Determine if a specific user is being used for the Moodle website (where "Moodle site" is the name of the website in the left hand pane of the IIS Manager manager console:

C:\inetpub>%windir%\system32\inetsrv\appcmd.exe list config "Moodle site" ^
More? /section:anonymousAuthentication

      <anonymousAuthentication enabled="true" userName="IUSR" />

If userName is not empty then this is the user that should have modify permissions to the Moodledata directory, e.g.:

C:\inetpub>icacls C:\inetpub\moodledata /grant IUSR:(OI)(CI)(M)

The above is the default setting for IIS. However, if userName is empty, i.e.:

      <anonymousAuthentication enabled="true" userName="" />

Then you need to grant modify permissions to the application pool identity for that website. The application pool is shown under Basic Settings... for the site in the IIS Manager console – by default the identity has the same name as the website but you may need to check the application pool settings to confirm this. E.g. for a website called Moodle site using an application pool identity also called Moodle site:

C:\inetpub>icacls C:\inetpub\moodledata /grant "Moodle site":(OI)(CI)(M)
You may find that the application pool identity isn't created until the website is first accessed. If the above command fails, try again after starting the Moodle install process.
Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Problem installing on Windows

by Joseph Craig -
Leon,

THANK YOU, THANK YOU, THANK YOU!!!!!!!!!!

I mentioned earlier that I just gave full privileges because I'm doing this on a dev server that is not connected to the internet. I certainly will be much more restrictive on the production server.

It looks like if I edit Anonymous Authentication in the IIS settings and change the user from a specific user (IUSR) to the Application Identity user, then this works! Is this the correct way to do it, or should I go back to the specific IUSR and change file permissions?

Again ... many, many thanks for pointing me to the solution!

Joe
In reply to Joseph Craig

Re: Problem installing on Windows

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

There's no correct way as such, it's just a case of determining which user account/identity IIS will use to access files and thus which account/identity you need to grant modify access to on the Moodledata directory.

That said application pool identities allow more granular access controls: if all websites on an IIS server were using IUSR then one website could access the files of another website, but with the application pool identities you can have one identity per website and grant file access only for the corresponding website. So this latter approach sounds better to me.

In reply to Leon Stringer

Re: Problem installing on Windows

by Joseph Craig -
I'm accustomed to setting up websites to use the App Pool Identity for websites, and also separate app pools for each website. The Anonymous Authentication is a new one for me. It looks like the default setting is IUSR, but I've never had trouble with that on some more "standard" ASP.NET websites.

It seems a lot easier to leave the Anonymous Authentication set to the default IUSR and give file permissions to that user.  That would be just one less thing to worry about.

It also seems like it would be a good idea to update the Moodle/Windows documentation to include that.  What I see is "The default IIS account is IIS_IUSRS, make sure it has appropriate access right to Moodle dirroot (read only) and dataroot (read/write) directories." The choice to use the IIS_IUSRS group rather than IUSR doesent work for me, even if I give the right file permissions to it.

Is there a place where I should report this or ask that the instructions be clarified?
Average of ratings: Useful (1)
In reply to Joseph Craig

Re: Problem installing on Windows

by Luis de Vasconcelos -
You can edit the info on https://docs.moodle.org/ yourself. It is a wiki which anybody can edit and contribue to.
See https://docs.moodle.org/38/en/MoodleDocs:Guidelines_for_contributors