How to modify PHP.ini? (register_globals problem)

Bahrian

Registered
Aug 21, 2006
1
0
151
Hello,

I installed oscommerce on a hosting account on my server (I do have access to WHM & Cpanel of that account). After complete installation, it gives following error when I open the oscommerce URL on that account:

Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.
Can anybody help me in editing this PHP.ini file?

I read on some website that you should write the following line: register_globals = On into a file and name it php.ini and upload it to public_html or the directory in which script is located. I tried this too, but it doesn't help.

When I opened htaccess file, it has the following stuff written into it:

<IfModule mod_setenvif.c>
<IfDefine SSL>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</IfDefine>
</IfModule>

# If Search Engine Friendly URLs do not work, try enabling the
# following Apache configuration parameter
#
# AcceptPathInfo On

# Fix certain PHP values
# (commented out by default to prevent errors occuring on certain
# servers)
#
<IfModule mod_php4.c>
php_value session.use_trans_sid 0
php_value register_globals 1
</IfModule>
Can anybody help me? How can I get rid of this register_globals problem?
 

anka

Member
Mar 26, 2004
15
0
151
cPanel Access Level
Root Administrator
PHP.ini => Register_globals Problem

Hi,

you cann edit the httpd.conf file:

/usr/local/apache/conf/httpd.conf:

look for the Section Virtual-Host of the Domain and add the Bold line - save the File and restart Apache

<VirtualHost your IP>
ServerAlias www.domain.tld domain.tld
ServerAdmin [email protected]
DocumentRoot /home/username/public_html
BytesLog domlogs/domain.tld-bytes_log
User username
Group usergroup

<IfModule mod_php4.c>
php_admin_value register_globals 1
</IfModule>

<IfModule mod_php5.c>
php_admin_value register_globals 1
</IfModule>

<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled username
</IfModule>
ServerName www.domain.tld
ScriptAlias /cgi-bin/ /home/username/public_html/cgi-bin/
User reiki
Group reiki
CustomLog domlogs/domain.tld combined
</VirtualHost>

Regards

G. Barbez
 

cix

Well-Known Member
Nov 6, 2003
74
0
156
anka said:
Hi,

you cann edit the httpd.conf file:

/usr/local/apache/conf/httpd.conf:

look for the Section Virtual-Host of the Domain and add the Bold line - save the File and restart Apache

<VirtualHost your IP>
ServerAlias www.domain.tld domain.tld
ServerAdmin [email protected]
DocumentRoot /home/username/public_html
BytesLog domlogs/domain.tld-bytes_log
User username
Group usergroup

<IfModule mod_php4.c>
php_admin_value register_globals 1
</IfModule>

<IfModule mod_php5.c>
php_admin_value register_globals 1
</IfModule>

<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled username
</IfModule>
ServerName www.domain.tld
ScriptAlias /cgi-bin/ /home/username/public_html/cgi-bin/
User reiki
Group reiki
CustomLog domlogs/domain.tld combined
</VirtualHost>

Regards

G. Barbez
This works on php CGI(cpanel default) and phpsuexec enabled?
 

hekri

Well-Known Member
Oct 14, 2003
147
2
168
Maybe help someone:

If you have php4 and php5 both as PDO and you want example enable register_globals with .htaccess put

php5_flag register_globals On (Off)
php4_flag register_globals On (Off)

Normaly php_flag register_globals Off will work only for one version of PHP not for both.
 

acenetryan

Well-Known Member
PartnerNOC
Aug 21, 2005
197
1
168
If you're running PHP as an Apache module, you can set the php_flags as previously noted in this thread.

If you're running PHP as CGI, you will need to remove the directives from your .htaccess or httpd.conf and instead place them within a php.ini file within the script's executing directory.

If you have root access and want to make the change server-wide, you would edit the server's default php.ini.

You would remove the php_flag directive and instead use only the variable you want to change. For example:

Code:
register_globals = On
 

chae

Well-Known Member
Apr 19, 2003
145
0
166
Auckland, New Zealand
We've just finished upgrading servers to Apache2.2, PHP5 & MySQL 5. Lots of sites on the servers were having the same RG problem. PHP was running with SuPHP & SuHosin.

We got round the problem by creating the php.ini file & placing one in the public_html, catalog (whatever they named the oscommerce folder) and the admin folder. All sites started working no problem. You'll also find that the includes/configure.php will need it permissions changed & depending on which version of oscommerce you have or they have you'll need to tweak some of the code, not much but oscommerce's forum is well documented.

Ideally if it's an older version you would upgrade to the latest & most secure
 

kran

Well-Known Member
Jul 5, 2003
75
0
156
Colombia
cPanel Access Level
Root Administrator
This is what I do.

I just create a php.ini with the following:

register_globals = On
allow_url_fopen = On
safe_mode = Off

Place it in the main oscommerce directory and chown it as the site user.
 

hekri

Well-Known Member
Oct 14, 2003
147
2
168
I run php5 dso and php4 cgi. PHP4 cgi have register_globals set Off i put php.ini to public_html with register_globals = On and run phpinfo.php4 and still see register_globals Off - why?
 

ahlul_b4n9_s

Member
Nov 28, 2006
6
0
151
I have read it but i still get problem :( i have 3 server n i got same problem. my user can't modify php conf with their own php.ini.

I tried all ways for compiling Apache+PHP4+PHP5 with Easy Apache but i still get wrong.

And everything that sent by $_POST[] the PHP page can't display the value.

Please some body help me. I had work for 1 week but i get nothing. :( Same problem again.


I hope my user can modify their own php.ini
 

acenetryan

Well-Known Member
PartnerNOC
Aug 21, 2005
197
1
168
Ahlul,

The easiest way to see whether the settings you are changing are actually taking effect is to create a phpinfo file within the same directory as the php.ini you are using to change settings. Simply create a file named 'phpinfo.php' and put this code in it:

Code:
<?php phpinfo(); ?>
Then visit the page in a browser. You can search the page for the particular setting, say register_globals, and see if it is being set.
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,607
80
458
cPanel Access Level
Root Administrator
The last time I tested this, one needed to use mod_suphp to get the behavior you want.