How do I turn on safe mode for php?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How do I turn on safe mode for php?

Postby jsherk » 09. January 2009 18:38

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
jsherk
 
Posts: 7
Joined: 08. January 2009 22:19

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

Postby dmphotography » 09. January 2009 20:19

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.
For great video and written tutorials and guides on creating your own web server and installing things such as forums, blogs, etc., visit http://myownhomeserver.com
dmphotography
 
Posts: 191
Joined: 15. December 2008 14:25
Location: Columbus, MS
Operating System: Windows 7

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

Postby jsherk » 09. January 2009 20:37

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!!
jsherk
 
Posts: 7
Joined: 08. January 2009 22:19

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

Postby jsherk » 09. January 2009 21:27

Yep, that did it! Thanks
jsherk
 
Posts: 7
Joined: 08. January 2009 22:19

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

Postby dmphotography » 09. January 2009 23:45

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.
For great video and written tutorials and guides on creating your own web server and installing things such as forums, blogs, etc., visit http://myownhomeserver.com
dmphotography
 
Posts: 191
Joined: 15. December 2008 14:25
Location: Columbus, MS
Operating System: Windows 7

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

Postby Izzy » 10. January 2009 00:34

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)
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

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

Postby dmphotography » 10. January 2009 04:49

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.
For great video and written tutorials and guides on creating your own web server and installing things such as forums, blogs, etc., visit http://myownhomeserver.com
dmphotography
 
Posts: 191
Joined: 15. December 2008 14:25
Location: Columbus, MS
Operating System: Windows 7

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

Postby Izzy » 10. January 2009 05:21

@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.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 182 guests