Problem with moodle docs for nginx install

Problem with moodle docs for nginx install

by Walter Byrd -
Number of replies: 7

Much of the instructions in the moodle docs

https://docs.moodle.org/39/en/Nginx

depend on putting a "location" directive in the nginx.conf file. But when I tried that I got:

"location" directive is not allowed here in /etc/nginx/nginx.conf:87


I am using nginx-1.14.2. My system tells me that is the latest version. But, in the docs, I think they are using nginx-1.15. I don't know if that would have anything to do with it.

Average of ratings: -
In reply to Walter Byrd

Re: Problem with moodle docs for nginx install

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
There are loads of answers to this if you Google the error message. For example...

https://stackoverflow.com/questions/20392741/nginx-errorlocation-directive-is-not-allowed-here-in-etc-nginx-nginx-conf76
In reply to Howard Miller

Re: Problem with moodle docs for nginx install

by Walter Byrd -
That thread is nearly seven years old. I don't think nginx works the same today as it did then. For example, nginx does allow me to put a "location" directive in the nginx file.
In reply to Walter Byrd

Re: Problem with moodle docs for nginx install

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
It allowed me, just seven days ago! big grin

Did you read the StackOverflow link Howard provided?
In reply to Visvanath Ratnaweera

Re: Problem with moodle docs for nginx install

by Walter Byrd -
From yesterday:

# cat /var/log/nginx/error.log
2020/08/23 17:01:32 [emerg] 27985#27985: "location" directive is not allowed here in /etc/nginx/nginx.conf:87

It looks to me like, with my setup, "server" and "location" is in the "sites-enabled/default file" and/or the "sites-available/default" file.
In reply to Walter Byrd

Re: Problem with moodle docs for nginx install

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ok - but it's an nginx issue rather than a Moodle one. If you're still stuck you might get more help in an nginx forum. However, you need to get that 'slasharguments' code working.
In reply to Howard Miller

Re: Problem with moodle docs for nginx install

by Walter Byrd -
These are the first four lines of my nginx.conf file:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

Notice that include statement?

I am guessing that I need to create a /etc/nginx/modules-enabled/moodle.conf; file.

I am further guessing that I need to put the "server" and "location" directives there.

I am posting in the nginx forums. If I find a solution, I will post here.
In reply to Walter Byrd

Re: Problem with moodle docs for nginx install

by Walter Byrd -
Update.
I created a sites-enabled/moodle.conf file. I included the "location" directive from moodle docs.
Nginx seems to run. Nginx will work with php, but not javascript.
When I try to install Moodle. I get the following in my error log:

2020/08/24 12:43:12 [error] 20154#20154: *7 open() "/var/www/html/moodle/theme/styles.php/boost/1598217947_1/all" failed (20: Not a directory), client: 127.0.0.1, server: _, request: "GET /moodle/theme/styles.php/boost/1598217947_1/all HTTP/1.1", host: "myserver", referrer: "http://myserver/moodle/user/editadvanced.php?id=2"

2020/08/24 12:43:12 [error] 20154#20154: *7 open() "/var/www/html/moodle/lib/javascript.php/1598217947/lib/mdn-polyfills/polyfill.js" failed (20: Not a directory), client: 127.0.0.1, server: _, request: "GET /moodle/lib/javascript.php/1598217947/lib/mdn-polyfills/polyfill.js HTTP/1.1", host: "myserver", referrer: "http://myserver/moodle/user/editadvanced.php?id=2"