CSS not loading due to slash arguments

CSS not loading due to slash arguments

by Selene Posada -
Number of replies: 15

Title says it all, Long story short the slash arguments aren't being interpreted and used as arguments in PHP which causes the CSS to not load at all across the whole site.

The current workaround I have is to turn off slash arguments, which isn't ideal knowing slash arguments will be enforced in the future.


Moodle version 3.5 

CentOS 7.5

Apache/httpd 2.4.6

PHP 7.2.7 with php-fpm (compiled from source)


SELinux set to permissive while performing installation and configuration.

I followed the full installation instructions with Apache performance and configuration directions.


Here is an example error I receive in my httpd error_log whenever I open any page with slash arguments enabled.

[Tue Jul 17 11:53:14.959384 2018] [proxy_fcgi:error] [pid 70819:tid 140332897306368] [client 172.31.58.196:58110] AH01071: Got error 'Unable to open primary script: <PATH TO MOODLE>/lib/javascript.php/1531767835/lib/requirejs/require.js (No such file or directory)\n'

If there is any additional info needed please let me know.

Average of ratings: -
In reply to Selene Posada

Re: CSS not loading due to slash arguments

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The obvious conclusion is that 'AcceptPathInfo' isn't 'On' somehow/somewhere in your apache settings. 

I'm not very familiar with CentOS (Ken will be along in a minute) but Apache config is often spread over a whole bunch of files. It can even be overriden in an htaccess file (or similar).  Make sure you do an exhaustive search.

Average of ratings: Useful (1)
In reply to Howard Miller

Re: CSS not loading due to slash arguments

by Selene Posada -

Ill try adding it to HTaccess file to override Additionally the proxypass to PHP-FPM is located in its own block. Ill try moving it and see what happens.

Currently in the main .conf file I have AcceptPathInfo On located in the <VirtualHost *:80> block.

Thanks


In reply to Selene Posada

Re: CSS not loading due to slash arguments

by Ken Task -
Picture of Particularly helpful Moodlers

Well, Howard rattled my tree ... sooooo ...

AcceptPathInfo On is the correct setting ... if site is running virtualhost and https ... you have/had the directive in the *:80 ... not default for :443.

What's in the VirtualHost *.443?  If you have one of those.   You might not.

I run my sites as a mod ... old timer ... thus a little different ...

What version of CentOS?   and what version of Apache?

/usr/sbin/httpd -V
Server version: Apache/2.4.6 (CentOS)
Server built:   Jun 27 2018 13:48:59

https://httpd.apache.org/docs/2.4/mod/core.html#acceptpathinfo

Know that doesn't tell you specifically.   Sorry bout that!

'spirit of sharing', Ken

Average of ratings: Useful (2)
In reply to Howard Miller

Re: CSS not loading due to slash arguments

by Selene Posada -

After some experimentation it seems like setting cgi.fix_pathinfo to 1 in the php-fpm .ini file fixed it, though oddly it took a while for the effects to kick in. 

Is this a recommended solution or Ill-advised?

Average of ratings: Useful (2)
In reply to Selene Posada

Re: CSS not loading due to slash arguments

by Ken Task -
Picture of Particularly helpful Moodlers

Think that's right ... if you run php-fpm.

PHP in php-fpm is running as a cgi, right? smile

'spirit of sharing', Ken


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

Re: CSS not loading due to slash arguments

by Selene Posada -
Thanks for taking a look Ken.


Yes php-fpm is running as my cgi, in this case I'm using a ProxyPassMatch  to pass it to a TCP port. The Regex it matches for is ^/(.*\.php(/.*)?)$


I also set security.limit_extensions = .php to ensure only .php files run.


Would you still like me to answer the other info you asked of me in your previous post?

Average of ratings: Useful (1)
In reply to Selene Posada

Re: CSS not loading due to slash arguments

by Ken Task -
Picture of Particularly helpful Moodlers

The only reason I asked for output of that httpd command was to see if you were running 2.4.6 as it was a recent update in CentOS 7.   You might run it anyway to see what it says ... for your use.  Red-in-face ... didn't see the info shared in first posting about the problem ... just Howard saying I'd be along! /Red-in-face.

The AcceptPathInfo 'default' is to allow the handler ... in your case php-fmp so that setting in php-fmp was right on target. smile

'spirit of sharing', Ken


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

Re: CSS not loading due to slash arguments

by Selene Posada -

Thanks for verifying the made setting change was correct. I'd say this issue is totally resolved. 

big grin

Regards,


Tanner

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

Re: CSS not loading due to slash arguments

by Adam Jenkins -
Picture of Plugin developers

Hi Ken et al.

Same symptoms here. I'm a long time Ubuntu Server user, first time CentOS user.

So, as far as I can tell, cgi.fix_pathinfo is correctly set to 1 (see phpinfo linked below).  The server is using FPM/FastCGI which I am also relatively new to (new to it on CentOS anyway...).

AcceptPathInfo On is set in httpd.conf as well as in the virtualhost between the <Directory> tags for the webroot (overkill perhaps, but it still isn't working). 

Turning Slash Arguments off, fixes the problem in the 3.1 test instance (link below) but won't help for 3.5 and onwards.

I don't know what I'm missing. 

Any help greatly appreciated!

Adam


Server info: OS CentOS 7

Server version: Apache/2.4.6 (CentOS)

Server built:   Jun 27 2018 13:48:59


The phpinfo of the server I'm trying to setup is here https://ilearn.wisecat.net/phpinfo.php

The broken moodle https://ilearn.wisecat.net/moodle (installed from git -- 3.1 because without slash arguments working, this is as good a test moodle as I can run).

In reply to Adam Jenkins

Re: CSS not loading due to slash arguments

by Ken Task -
Picture of Particularly helpful Moodlers

@Adam ... et. el.

Run sites as a mod, not php-fpm sooooooo....

When changing config of either apache or php-fpm one has to restart both of those.  After making additions to php-fpm config did you restart that service?

PHP 7.0.27?
7.0.x is minimum and 7.1 is available via 3rd party repos.

Appears your PHP installed in a /var/opt/rh/ directory.
Error log:
/var/opt/rh/rh-php70/log/php-fpm/www-error.log

Anything in that error log when attempting a 3.5 install?

Also ...
include path shows a /root/usr/...  Huh?

And what happens when you attempt an install of a 3.5.x?

Additional info:

https://httpd.apache.org/docs/2.4/mod/core.html#acceptpathinfo

says that config variable can be used in an .htaccess flie.

Try this:

in your moodledata directory, manually remove ./localcache/theme/*contents* ... ie, leave localcache/theme/ and manually remove all folders/files in theme.

No need to restart any service ... that cache should rebuild as you click around.

'spirit of sharing', Ken


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

Re: CSS not loading due to slash arguments

by Adam Jenkins -
Picture of Plugin developers

Hi Ken, 

The error log is empty apart from messages much older and irrelevant. So no errors in the fpm log. 

I could try an htaccess file, but would also need to change the allowoverrides directive which is currently set to none. 


Restarting httpd and php-fpm has been done with every change I've tried this far. If only it were so simple. 

Likewise, file permissions are all good. So the simple stuff has already been eliminated. 

The reason for 7.0 is to mimic as closely as possible, the current server's configuration (Ubuntu server with php7.0). We're migrating to CentOS from Ubuntu to test another problem that exists on the Ubuntu server (which is a doozy, the server sends no SYN+ACKs in response to SYNs from certain networks-- weird, right? Not synflood nor TCP backlog problem, but I digress). 

The documentation I've read says CentOS prefers fpm, but I'd be just as happy with a modphp, if you have better suggestions closer to what you're using, I'm all ears. Especially if they are stable and simple to implement (yup, CentOS noob alert). Thus far, CentOS documentation has been less than accurate for my server (eg. Apparently firewalld is used over iptables in CentOS 7, but it's all iptables on the server I have). In short, I'm feeling quite like Alice in wonderland at the moment.

The yum install of rh-php as described in the wiki.centos.org how to would be the cause of the paths with root/usr in them. Coming from Ubuntu, the first thing I did was remove the root password and create a sudo capable standard account (which thereafter I learnt was a very Ubuntu thing to do).

Also, as I'm just testing the server at this point in time, I've been deleting the entire Moodle instance and reinstalling each time I try it. The moodledata dir is thus clean as is the MariaDB database. Local caches etc are also deleted in the process.

The problem with installing versions 3.2 and up is that during installation, when creating the admin account, the CSS isn't rendered along with some JavaScript files. The new password input requires that JavaScript and thus slash arguments to work in order to be usable. Newer versions don't crash or collapse, I simply can't complete the installation due to the fancy new password box.

Do you know a simple way I could get modphp in a CentOS server? I'm not hooked on fpm, t I tried it on Ubuntu a few times and noticed no performance benefits...

Thanks always,


Adam

In reply to Adam Jenkins

Re: CSS not loading due to slash arguments

by Ken Task -
Picture of Particularly helpful Moodlers

Well, before you give up with what you have ... install the moodle via command line.

You probably have sudo turned on ... so login with account then sudo -s

Provide password for the account you used to login. Prompt should change to 'root' and now you are root all the time.

One of the things folks get hung up on is seLinux, which in RHEL and CentOS is installed and running in the enforcing mode. What does: sestatus show?
If it says enforcing, seLinux will cause you problems installing Moodle - typically, the location of moodledata which, if running a mod, would be in /var/www/ ... that's Apache's 'home directory' already.

I always set seLinux to 'permissive' then watch logs to see what selinux is complaining
about and then using seLinux tools/commands, do the tweaks so no more complaints.
Then turn seLinux to enforcing.

Install nano text editor if it's not installed:
yum -y install nano

cd /etc/selinux/
nano config
File is commented so no need to tell ya what to do here.

selinux and kernel updates are the only two things that require reboot of server.
Reboot server after making changes to seLinux config.

Something that might help you ... webmin - a free open source cPanel that
runs under perl and has it's own web service ... doesn't use Apache.
Has modules for working with various services ... apache2, MySQL ... as well as config
of PHP.

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-webmin-on-centos-7

You are using the redhat software collections repo - slc
and that's why the, I'd say weird, locations.


DigtalOcean has some pretty good tutorials/how2's.  In my Google searches for things
CentOS 7 I always find a hit with DO.

https://www.google.com/search?&q=DigitalOcean+CentOS+7

Let's try to get moodle running using the CLI ONLY.

Copy the config-dist.php file to config.php

Edit the config.php file with nano and fill in only what you need to get started ... those variables are at the top of the config.php file.

Once editing config.php, then run the install.php file.

Basically we are avoiding (for the installation) apache.

Since this could get rather involved, I'll send you a PM with an email address we can use to communicate directly ... forum is delayed.

'spirit of sharing', Ken



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

Re: CSS not loading due to slash arguments

by Adam Jenkins -
Picture of Plugin developers

Hi Ken,

Thank you so much for your time and expertise. First and foremost I hope to let you know that your taking your time to help me and the community in general is very much appreciated.

Unfortunately, SELinux is one of the first things checked. I'll send you more details privately, but can guarantee that SELinux is not the problem.

I also have no reason to believe that 3.5 would fail, all dependencies save slash arguments/pathinfo have been met. More on this privately...

To the forum community: Apologies while we take this conversation away from the forums briefly. I promise to post again later with information on how it ultimately gets resolved. Any problem is solvable; one needs but find the solution(s).

Adam

In reply to Adam Jenkins

Re: CSS not loading due to slash arguments

by Adam Jenkins -
Picture of Plugin developers

As promised, here's an update.

The server I am using is a bit different to how the documentation for CentOS7 says it should be. For example, the firewall according to the documentation says it should be firewalld, however the reality is that it's using iptables...

Anyway, ultimately, the problem appears to have been within the specific php-fpm implementation I was using. Thanks to Ken, who really helped me get over the finish line on this one. Ken suggested replacing the php with one from another repository (Webtatic). I didn't fully follow Ken's recommendation here going with the IUS repository, which after reading up on it, appears a bit better suited for my particular situation. Also, I gave up on fpm for the moment, and instead went with mod_php for the handler making sure to include the "AcceptPathInfo On" directive in the virtualhost.

Finally, the server worked properly with Moodle 3.5.

MASSIVE THANKS to Ken Task, who really was fantastic in helping out so much! Moodler of the year type kudos is well deserved for such an effort. Without his help, I would definitely still be completely and helplessly stuck.

Now that the server is up and running, next step, migrating the Moodle including a change from MySQL to MariaDB. Once again, Ken is already my hero, as I found the following thread with some pointers on making the MySQL to MariaDB switch smoother: https://moodle.org/mod/forum/discuss.php?d=336398

Gotta love this Moodle Community!

OK, I'll get back to it now and try not to break the server...

Average of ratings: Useful (2)
In reply to Adam Jenkins

Re: CSS not loading due to slash arguments

by Ken Task -
Picture of Particularly helpful Moodlers

Thanks for your kind comments.

Now a little more background ... Op is learning Linux server admin ... and it's a journey.  Chosen OS for his test server is CentOS 7.    OP probably missed this somewhere in the sea of docs, the firewall default for 7 is now firewalld, but servers comes with IPTables (4/6).   On OP's server iptables was active.  The new FW does have some nice features ... like a 'reject zone' which is pretty easy to deny an IP or range of IP's *any* access to the server.

But here was the real problem ... me thinks ... Op using 'Software Selections Repo' and had installed php-fmp as well as Apache that way.   Even though I thought I had added the tweaks to php-fmp and apache, still couldn't get .css and .js files .... Moodle server wasn't reporting 503 errors even with debugging set to developer.  Finally saw them using FireFox's Web Tools.   Do know that 503 errors are hard to troubleshoot and everything I tried didn't work.

The 'Software Collections' repo is really for the purpose of running multiple things ... like PHP versions.   It's sorta like Bitnami ... a one off thang ... uses /opt/rh/blah...blah ... for apache and php-fmp and for Apache. Documentation comes from one source ... nothing that contained Moodle tips/tricks/quirks.   Apache for example has an '/opt/rh/httpd24/root/' ... which reminded me of running Bind DNS in a chroot jail.   That sort of thing great for DNS ... only way to run Bind really ... but not so good for Apache and Moodle IMHO!

After fighting it for about 4 hours (this is a test server), decided that going back to stock with repo for PHP + using mod_php would be the eaiest path forward.  To Op's credit, sent some brief instructions/thoughts about that and he took it from there.

Actually, there is another poster in these forums that has been having all sorts of issues and in re-reading some of those postings noticed a path ... /opt/rh/blah-blah.   Hmmmm ... another confused SLC box?  Hmmm .... is 1 and 1 = two?

Bottom lines ... if op chooses CentOS 7 (which is just as good as Ubuntu IMHO) one will have to use 3rd party repos ... period.   The choice of repo's appears to make a difference.

For myself ... I like 'keep it simple stupid' ... paraphrased it might say 'keep it Stock stupid'!!! ;)

Not that anyone beginning Linux server admin is 'stupid' ... but one sure does feel like that sometimes.

Server admin is a journey ... as is Moodle ... never ending.  Failure and changing directions might be in a noobie admin's experience in the beginning ... it's not really 'failure' ... it's more like learning what doesn't work best for them ... e.g. ways that don't work.   What is it that 'they' say ... 'you don't know what you don't know'! .... until you do! ;)

'spirit of sharing', Ken