Jump to content

My very first PHP question: register_globals


robbbert

Recommended Posts

Hi, welcome to my thread, and, right-on: I did do a search (reading a bunch of answers asking for that).  ;)

Now, I've installed Apache 2.0 and PHP5 on Ubuntu Linux, and would like to install OSCommerce web shop, which requires register_globals to be turned on (for the installation, at least).

I've created a directory /var/www/test, and put there two files:
test.php:
[code]<?php
echo ini_get("register_globals");
?>[/code] and .htaccess:
[code]<IfModule mod_php5.c>
php_flag register_globals on
php_flag register_long_arrays on
php_value default_charset UTF-8
</IfModule>[/code]
If it makes a difference, I've copied the .htaccess file to the /var/www directory, too.

In both /etc/php5/cgi/php.ini and /usr/share/php5/php.ini-dist, I've changed [i]the line[/i] to
[code]register_globals = On[/code]

I've restarted the Apache.

To no avail: echo ini_get("register_globals") still returns 0.

Any tips, or letters of sympathy, at last?

Thanks
Robert
Link to comment
Share on other sites

doing it in the PHP.INI file would affect every site built on the server. applying register_globals as ON is highly unrecommended, so best to keep it to as few sites as possible...

it'd be worth having a check for other php.ini files on your server. most of the hosts i've been with tend to have it tucked in /etc/php.ini

[b]edit:[/b] failing that, in your test file, put: phpinfo() , which should reveal the path of the php.ini file that's currently being used.
Link to comment
Share on other sites

Thanks.

[quote author=redbullmarky link=topic=122128.msg503279#msg503279 date=1168623690]
phpinfo() , which should reveal the path of the php.ini file that's currently being used.
[/quote]

Good idea! - That's /etc/php5/apache2/php.ini, and I've set [i]register_globals = On[/i] there, too, and restarted Apache. Of course, I've also made sure the browser doesn't cache the page.

After all, ini_get("register_globals") still returns 0...
Link to comment
Share on other sites

If OSCommerce requires register_globals to be on thne enable it for that script only. Don't enable it site wide. If I remember correctly OSCommerce should have an .htaccess file in the OSCommerce folder. Just edit that and add the following to it:
[code]php_flag register_globals On[/code]

OSCommerce should now work.

Also php_flag or php_value will only work if PHP is loaded as an Apache module. They will not work if PHP is running in CGI mode.
Link to comment
Share on other sites

[quote]OSCommerce should now work.[/quote]
I've added that line (but anything else) to <wwwroot>.htaccess, and put there a php file that only contains [i]echo ini_get("register_globals");[/i].
Unfortunately, the problem persists.
[quote]Also php_flag or php_value will only work if PHP is loaded as an Apache module.[/quote]
That's explaining why there is a //cgi/php.ini as well as a //apache2/php.ini (in both, register_globals is turned [i]on[/i]).
Moreover, PHP is loaded as Apache module: When I add [code]LoadModule php5_module /usr/lib/apache2/modules/libphp5.so[/code] to httpd.conf, Apache warns "[i]module php5_module is already loaded, skipping[/i]" when being started.
Link to comment
Share on other sites

[quote author=robbbert link=topic=122128.msg503922#msg503922 date=1168687805]
... while I'm still wondering why the .htaccess file doesn't work ... ???
[/quote]
Have you configured Apache to allow configuration overriding through .htaccess files?

Look for the following in your httpd.conf:
[code]# AllowOverride controls what directives may be placed in .htaccess files.[/code]
After that it should have the [tt]AllowOverride[/tt] directive. Post what it is currently set to here. In order for .htaccess files to override the servers configuration the [tt]AllowOverride[/tt] directive must have atleast [tt]fileInfo[/tt] listed. Otherwise Apache will ignore .htaccess files. I usually set this directive to [tt]All[/tt], eg:
[tt]    AllowOverride All[/tt]
Link to comment
Share on other sites

Thank you wildteen88.
I'd played with AllowOverride in apache2.conf (not httpd.conf, BTW), I'd read the Apache docs, too -- nevertheless, it's not working, yet, but good to know where to proceed.

Currently, I'm in an evaluation phase, only, (and really tired) so I'm just letting it be for now.

Thanks again
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.