如何在共享主机环境中为特定目录关闭 php safe_mode?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1982197/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to turn off php safe_mode off for a particular directory in a shared hosting environment?
提问by Sam
Hi I'm used shared hosting. I want to turn off php safe_mode off for my site. My provider gave me a php.ini file and asked me to put it with my settings in my public_html folder to override the settings, but it didn't work.
嗨,我使用共享主机。我想为我的网站关闭 php safe_mode。我的提供商给了我一个 php.ini 文件,并要求我将它与我的设置一起放在我的 public_html 文件夹中以覆盖设置,但它没有用。
回答by Meta Bergman
You can also try to create a file called php.ini in the root (public_html or other) folder, and putting the following in it:
您也可以尝试在根(public_html 或其他)文件夹中创建一个名为 php.ini 的文件,并将以下内容放入其中:
safe_mode = Off
Depending on server settings, this may or may not work.
根据服务器设置,这可能有效也可能无效。
回答by Marco Demaio
Your service provider might have forgot to tell you that you need to enable your user defined php.ini configuration by adding this line in the .htaccess file that you find in your public_html folder:
您的服务提供商可能忘记告诉您,您需要通过在 public_html 文件夹中找到的 .htaccess 文件中添加以下行来启用用户定义的 php.ini 配置:
#Activates php.ini config located in main folder to work also recursively for all subfolders
suPHP_ConfigPath /home/YOUR_CPANEL_USER_NAME/public_html
Obviously replace YOUR_CPANEL_USER_NAME with your cPanel user name.
显然,用您的 cPanel 用户名替换 YOUR_CPANEL_USER_NAME。
I'm supposing your server has got suPHP module(which is quite common in nowdays).
我假设你的服务器有 suPHP 模块(这在现在很常见)。
BTW: the php.ini file need to be in /home/YOUR_CPANEL_USER_NAME/public_html too and inside you should write this:
顺便说一句:php.ini 文件也需要在 /home/YOUR_CPANEL_USER_NAME/public_html 中,你应该在里面写:
safe_mode = Off
And remember that Safe Mode is deprecated in PHP 5.3.0 and is removed in PHP 6.0.0.
请记住,安全模式在 PHP 5.3.0 中已弃用,并在 PHP 6.0.0 中删除。
回答by Andy
TRY:
尝试:
You can turn it off by adding the following line to a .htaccess file in your root (public html) folder.
您可以通过将以下行添加到根(公共 html)文件夹中的 .htaccess 文件来关闭它。
If the .htaccess file doesn't exist, you can create it using a simple text editing program.
如果 .htaccess 文件不存在,您可以使用简单的文本编辑程序创建它。
php_flag safe_mode Off

