Installing Moodle: "register_globals=off"

Installing Moodle: "register_globals=off"

by C S -
Number of replies: 17

Hello,

I'm trying very hard to install Moodle onto a web server.  The problem arises when I go to http://mydomainname.net/moodle/install.php  I get the following error:

Insecure Handling of Globals

Fail

SECURITY WARNING!

To operate properly, Moodle requires
that you make certain changes to your current PHP settings.

You must set register_globals=off.

This setting is controlled by editing your php.ini, Apache/IIS
configuration or .htaccess file.

I created a php.ini file (according to the thousands of websites I went to of people with similar problems.  Here is what I put in the file and saved it to the root (moodle) directory:


magic_quotes_gpc='on'
magic_quotes_runtime='off'
file_uploads='on'
short_open_tag='on'
session.auto_start='off'
session.bug_compat_warn='off'
register_globals='off'

still, no dice.

I went into the lib directory, took the htaccess file and followed the directions there, which was to copy it to the root (moodle) directory, rename it to ".htaccess" and try installing it.  Now, I get an Internal Server Error. 

This did not happen with older versions of Moodle.  I tried doing this with both 1.8 and 1.9.5+ and The same error happens!!!!

HELP PLEASE!! sad((((

Average of ratings: -
In reply to C S

Re: Installing Moodle: "register_globals=off"

by C S -
Nevermind, I called the webhosting company and they fixed the issues. It's usually on their end.
In reply to C S

Re: Installing Moodle: "register_globals=off"

by Martin Lewis -

Hi Carol,

Just had the same problem.

Copy your php.ini file into /moodledata, /admin, /course and /file directories as well as wwwroot.

You might need display_errors=off as well

Good luck.

Martin

In reply to Martin Lewis

Re: Installing Moodle: "register_globals=off"

by dor bar -
My 5 cents

Usually ther is a cgi-bin folder in your hosting environment. Something like:

root/
  • backup
  • cgi-bin
  • htdocs

You must put the php.ini file (if not jet there) in a cgi-bin folder. So, open the php.ini file and add a line:
register_globals=off

That's it. Do not put this in the .htaccess files around your site. It will just provoke an 500 internal server error.
In reply to dor bar

Re: Installing Moodle: "register_globals=off"

by Karim Jaffer -
Thansk got it.  Now I am stuck on this page.  There does not appear to be a scroll button to continue and i go nowhere 5 hrs so far
Attachment setup_page.jpg
In reply to Karim Jaffer

Re: Installing Moodle: "register_globals=off"

by dor bar -
Welcome in the club!!! The same problem here. I will no longer use Moodle since it's the most user HOSTILE script I ever encountered.
In reply to dor bar

Re: Installing Moodle: "register_globals=off"

by muhamad faiz -
i'm very new with this moodle this.. and i've been having the same problem regarding with the register_globals=off things.. and i read that most of the suggested answer is by editing the php.ini file. the problem is, i dont know where this "php.ini" is situated. anybody care to enlighten me? very appreciate it.
In reply to muhamad faiz

Re: Installing Moodle: "register_globals=off"

by E. L. Cooper -
Ask your webhost about the issue. Not all hosts allow custom ini's
In reply to E. L. Cooper

Re: Installing Moodle: "register_globals=off"

by Richard Enison -
ELC (& Moodlers having problems with php.ini),

Your post is the first really sensible one in this thread, which is full of advice that applies to a particular environment only and makes it seem like it is the thing to do in all environments (like where to copy php.ini to). Here is a list of links on the subject of the location of php.ini, including the use of custom ini's, for future reference:

http://moodle.org/mod/forum/discuss.php?d=90435#p414812
http://moodle.org/mod/forum/discuss.php?d=94601#p417895
http://moodle.org/mod/forum/discuss.php?d=97251#p429865
http://moodle.org/mod/forum/discuss.php?d=97357#p430159
http://moodle.org/mod/forum/discuss.php?d=95924#p423662
http://moodle.org/mod/forum/discuss.php?d=99364#p439236
http://www.askapache.com/php/custom-phpini-tips-and-tricks.html

RLE
In reply to dor bar

Re: Installing Moodle: "register_globals=off"

by Camilo Salazar Ocampo -

Dor bar, thanks a lot, your solution works for me, I only copy php.ini in root, moodledata and admin. smile

In reply to Martin Lewis

Re: Installing Moodle: "register_globals=off"

by Miss Moeller -

I'm a school teacher trying to install Moodle for my class website.

Website: http://missmoeller.com/school/

When I just tried to install Moodle, I ran into the same initial error:

"You must set register_globals=off"

So I created a php.ini file with the following:

magic_quotes_gpc='on'
magic_quotes_runtime='off'
file_uploads='on'
short_open_tag='on'
session.auto_start='off'
session.bug_compat_warn='off'
register_globals='off'


(Exactly as written above.)

And I saved this php.ini file to my main directory, /moodledata, /cgi-bin, /admin, /course, /files as suggested here.


(I am using PHP 5.2.17, so I don't think I even needed to do this.)

According to my PHP info, the Loaded Configuration File is in my main directory, and the Configuration File (php.ini) Path is in something called user/lib, although I can't seem to find this directory. Is this where the php.ini that I'm supposed to edit is?

Unfortunately, what I have done so far hasn't removed the error from the main page, and now I am getting an additional error on the install.php page:

http://missmoeller.com/school/install.php

" The PHP server variable 'file_uploads' is not turned On - Installation docs"

"Coding error detected, it must be fixed by a programmer: block_manager has not yet loaded the blocks, to it is too soon to request the information you asked for."

I have file_uploads set to 'on' in the php.ini file, and register_globals set to 'off.'

Perhaps I made the php.ini file wrong. I ONLY put the information listed above in the file. Is there more data I should put in the file? Or should I add the file to additional locations?

Any other idea what might be causing this?

Thank you so much for any help you can offer me.

In reply to Martin Lewis

Re: Installing Moodle: "register_globals=off"

by Miss Moeller -

Never mind. I contacted my host and they directed me to the php.ini file I needed. Thank you! smile

In reply to Miss Moeller

Re: Installing Moodle: "register_globals=off"

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi you need to go back to your hosting company and ask them to upgrade you to a higher version of PHP because Register_Globals is now considered to be a security threat if left on. In newer versions of PHP this is OFF by default. The fact your host company is sending you on a wild goose chase is because they know this already, but can't switch it off 'globally' as too many of their clients are on old server settings.

Wide goose chase? Becasue you can't change Register_Globals=off from a copy of php.ini in your root directory, I and countless others have tried this too, with no success.

By the way, my host company upgraded me for nothing.

HTH

Mary

In reply to C S

Re: Installing Moodle: "register_globals=off"

by Rui Suzano -

I had the same problem and I fixed with this. I dont know if it works in all servers...

Copy the following code and paste it in Notepad:

Code:
<?php
$parm[] = "register_globals = Off";
$defaultPath = php_ini_loaded_file();
// full unix path - location where you want your custom php.ini file
//$customPath = "/path/php.ini";
$customPath = "php.ini";
// nothing should change below this line.
if (file_exists($defaultPath)) {
  $contents =  file_get_contents($defaultPath);
  $contents .= "\n\n; MODIFIED THE FOLLOWING USER PARAMETERS:\n\n";
  foreach ($parm as $value) $contents .= $value . " \n";
  if (file_put_contents($customPath,$contents)) {
    if (chmod($customPath,0600)) $message = "<b>PHP.INI File modified and copied.</b>";
      else $message = "PROCCESS ERROR - Failed to upadate php.ini.";
  } else {
    $message = "PROCCESS ERROR - Failed to write php.ini file.";
  }
} else {
  $message = "PROCCESS ERROR - php.ini file not found.";
}
echo $message;
?>


Click on File, Save As, select File Type "All Files" and save it As "modify_phpini.php"

Upload it with FTP in the Moodle root folder, and run it through your browser: http://yourdomain.com/moodle/ modify_phpini.php (check if this is the correct root for you)

It will turn the Register Globals to OFF. If it works you will get a message saying that the file was modified

Rui

In reply to Rui Suzano

Re: Installing Moodle: "register_globals=off"

by Hoa Nguyen -
You should put an .htaccess file within the moodle directory with the line:

php_flag register_globals off
In reply to Hoa Nguyen

Re: Installing Moodle: "register_globals=off"

by Aykut Gueven -
Hoa, yes. You are on the right way ;o)

I had the same probs as described above and I couldt solve this by:

look at your .htaccess file, which should be located under /moodle and add following lines:
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

This will change from php4 to php5, which solved my probs with the "scroll button" - see screenshot above.

Now, I' m online with my moodle and feel great after 2 days of hard search ...

Aykut, happy
In reply to Rui Suzano

Re: Installing Moodle: "register_globals=off"

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

That script is a rather complicated way to add 'register_globals=Off' onto the end of a php.ini file. You still need to know where the file is and (more to the point) if editing it is the right thing to do on your host.

The above advice still applies... ask your hosting company (or read their docs/faq) how to turn off register_globals. I know everybody is trying to help but posting information that only applies to *your* host just causes further confusion.