Page 1 of 1

How do I turn on safe mode for php?

PostPosted: 09. January 2009 18:38
by jsherk
I thought there might be a post somewhere in the forum about this already, but I couldn't find one!

How do turn on safe mode in php?
Is it as simple as setting it to safe mode = on in the php.ini file?

Should I change these?
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH


There is both a php.ini file and a php5.ini file, so do I need to edit both of these?

Thanks

Re: How do I turn on safe mode for php?

PostPosted: 09. January 2009 20:19
by dmphotography
To turn safe mode on, yes, just change it to on in php.ini.

You do not have to change any of the other values you asked about.
They simply set perimeters for safe_mode and should work fine as is. If you encounter a problem with safe-mode on, you can set them to exclude directories that need safe-mode off.

You probably shouldn't mess with the php5.ini. I haven't seen an instance yet where I needed to do so and not even sure what it's for. PHP.ini is your main PHP configuration file and the one you will make any necessary changes in.

Also, there are two php.ini files. The one in the php directory I believe doesn't do anything because it's replaced by the other one in XAMPP. You can find the one you need in /xampp/apache/bin/php.ini. Just simply search for the safe mode line and change to on.

Re: How do I turn on safe mode for php?

PostPosted: 09. January 2009 20:37
by jsherk
dmphotography wrote:Also, there are two php.ini files. The one in the php directory I believe doesn't do anything because it's replaced by the other one in XAMPP. You can find the one you need in /xampp/apache/bin/php.ini. Just simply search for the safe mode line and change to on.


Thanks for that... I had made the change in the one on the php directory and did not do anything, so I'll try the other one and see what happens!!

Re: How do I turn on safe mode for php?

PostPosted: 09. January 2009 21:27
by jsherk
Yep, that did it! Thanks

Re: How do I turn on safe mode for php?

PostPosted: 09. January 2009 23:45
by dmphotography
No problem, glad to help. I'm not sure what the purpose of the other one is and why it isn't removed during the install. It's a little confusing, because if you install PHP by itself, this is where the php.ini file is located and there isn't one in the Apache folder like the one XAMPP adds.

Re: How do I turn on safe mode for php?

PostPosted: 10. January 2009 00:34
by Izzy
In XAMPP Apache runs PHP as a module and needs the php.ini file in the bin folder and is how Apache is compiled.

To find which php.ini file is being used by Apache in XAMPP always go to
http://localhost /xampp/phpinfo.php
(or to the phpinfo() menu item in the Welcome Page (Admin))
and look for the line
Loaded Configuration File
which in a default installation should be in
C:\xampp\apache\bin\php.ini

When switching php versions (.\xampp\php-switch.bat) the php.ini file is copied over from the .\xampp\php folder to the .\xampp\apache\bin folder which further indicates the hard coded location during the apache compile and also indicates the php.ini file in the php folder is never used in that location.
(Switching PHP versions is not available in XAMPP 1.7.0 as php4 has not been included - but is available in versions prior to this release)

Re: How do I turn on safe mode for php?

PostPosted: 10. January 2009 04:49
by dmphotography
Thank you very much for the explanation. I kinda figured they didn't leave it in there by accident. At first, I was making my changes to both php.ini files just to make sure it took, but later learned it's only grabbing it's info from the one in the apache directory. Needless to say, that was a relief on editing the php.ini file.

Re: How do I turn on safe mode for php?

PostPosted: 10. January 2009 05:21
by Izzy
@dmphotography

I notice in another topic you mention installing another instance of PHP.

If the system variables have been edited by the PHP install process...
(usually carried out by apps that contain their own instance of PHP like Eclipse etc.)
...and a php.ini file has been located in the Windows folder then you may have the potential for a conflict and the use of the above mentioned phpinfo() method will determine any conflicts with the Loaded Configuration File been used.

PHP installed separately from XAMPP will use the default C:\WINDOWS folder to store and load the php.ini file and it is possible that PHP in XAMPP will try and use the same Windows located php.ini file with unexplained and frustrating results.