Nov
23
国内主机,遇到php里面safe mode(安全模式)的修改,一般要找主机供应商修改了,而且,一般找了也不过给你修改,因为理由都是怕影响同个主机上的其他用户,前不久换了美国的justhost主机,安装一个程序时遇到了麻烦,google了一下,看到一篇不错的文章,safe mode改成off的问题迎刃而解。特意想来博客这里记录下,方便其他遇到同样难题的人。
问题说明:
justhost主机的safe mode(安全模式)默认为是开启的on,所以有的程序安装时,就会遇到php报错,告诉你set_time_limit出了问题,但是,这个程序运行时间限制,只有在safe mode是off时设置才会生效,所以我们解决这个时间限制问题的根本就是要把安全模式关闭。那么怎么修改呢,翻了很多文章,最后还是Aj's Blog的文章帮助最大,简言之,可以直接自己写一个php.ini,然后放在你报错程序的目录下。
php.ini中的内容:
safe_mode = Off
延展阅读:
Aj's Blog的文章
引用
支持CPanel的空间如何使用自定义PHP.INI
1、问题描述
一直用的JUSTHOST的空间没出什么问题,今天一看网站报错了
程序用到curl库中curl_setopt()函数需要safe_mode=off,open_basedir为空
官方参考: http://php.net/manual/en/function.curl-setopt.php
2、解决办法
联系空间商提交ticket一问果然今天才开启的safe_mode
想起之前用hostmonster空间的时候也是Cpanel的面板而且支持用户自定php.ini
先Google了一下相关资料,找到CP官方讨论的thread,说是放在/home/***/public_html/即可,新php配置将覆盖全局配置,但是限定了一些参数 比如memory相关的
于是果断的写了一个php.ini内容就一句:safe_mode = Off
上传到/home/***/public_html/发现问题并未解决,开始以为是加载时间的问题,过了几分钟还是未生效,然后才开始读说明文档
以下说明文档系JUSTHOST提供,其他空间商情况会有不同
当时我就震惊了!给所有需要safe_mode=Off的网站根目录都传一个php.ini,OK了。
如果你用的其他空间商也是CP面板,可以参考但最好还是看下HELP文档。
3、据说
在CP官方论坛看到有人提到现在全面支持用户自定义PHP.ini 而且已经有了在线编辑器。有需要的同学自己去考证下。
1、问题描述
一直用的JUSTHOST的空间没出什么问题,今天一看网站报错了
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set
程序用到curl库中curl_setopt()函数需要safe_mode=off,open_basedir为空
官方参考: http://php.net/manual/en/function.curl-setopt.php
2、解决办法
联系空间商提交ticket一问果然今天才开启的safe_mode
想起之前用hostmonster空间的时候也是Cpanel的面板而且支持用户自定php.ini
先Google了一下相关资料,找到CP官方讨论的thread,说是放在/home/***/public_html/即可,新php配置将覆盖全局配置,但是限定了一些参数 比如memory相关的
于是果断的写了一个php.ini内容就一句:safe_mode = Off
上传到/home/***/public_html/发现问题并未解决,开始以为是加载时间的问题,过了几分钟还是未生效,然后才开始读说明文档
以下说明文档系JUSTHOST提供,其他空间商情况会有不同
Most notably, users are not able to have php flags in their .htaccess file. Having php flags in .htaccess files is a common cause of internal server errors on servers with phpSuExec enabled. One way around this is to create a custom php.ini file with the php values you need. You need to place this in every directory that needs to use this as the custom php configuration values you set in your php.ini are not recursive. This file should have the following permissions: 644 permissions with the owner cpanelusername:cpanelusername. If we take your cpanel username to be bobbob1, your php.ini file should look like this in your file manager or ftp client: -rw-r--r-- 1 bobbob1 bobbob1 21 Nov 20 18:57 php.ini.
Once your php.ini file has been created you can populate with the php configuration values you need to override on the server. The syntax generally follows this format: phpconfigValueToOverride = value. The most common php value you need to set for many of the scripts that we offer via Fantastico is register_globals. To enable register_globals you simply place this in your php.ini file: register_globals = On. Conversely, you can turn off register globals: register_globals = Off. Other common configuration changes include: upload_tmp_dir, display_errors, session.save_path.
Note: we do not allow our shared hosting customers to change their memory limit to anything past 32 M to protect the quality of service for our shared hosting environment. If you require more then 32 M then please contact our support team on: support@justhost.com.
You can check your current PHP settings by using the phpinfo() function. Simply place phpinfo(); in a new file with a .php extension. Again, it is important to note that any changes you make in the php.ini are not recursive meaning they do not carry over to other directories in your account. You must have a php.ini in every directory needing your custom php.ini.
“You must have a php.ini in every directory needing your custom php.ini”
Once your php.ini file has been created you can populate with the php configuration values you need to override on the server. The syntax generally follows this format: phpconfigValueToOverride = value. The most common php value you need to set for many of the scripts that we offer via Fantastico is register_globals. To enable register_globals you simply place this in your php.ini file: register_globals = On. Conversely, you can turn off register globals: register_globals = Off. Other common configuration changes include: upload_tmp_dir, display_errors, session.save_path.
Note: we do not allow our shared hosting customers to change their memory limit to anything past 32 M to protect the quality of service for our shared hosting environment. If you require more then 32 M then please contact our support team on: support@justhost.com.
You can check your current PHP settings by using the phpinfo() function. Simply place phpinfo(); in a new file with a .php extension. Again, it is important to note that any changes you make in the php.ini are not recursive meaning they do not carry over to other directories in your account. You must have a php.ini in every directory needing your custom php.ini.
“You must have a php.ini in every directory needing your custom php.ini”
当时我就震惊了!给所有需要safe_mode=Off的网站根目录都传一个php.ini,OK了。
如果你用的其他空间商也是CP面板,可以参考但最好还是看下HELP文档。
3、据说
在CP官方论坛看到有人提到现在全面支持用户自定义PHP.ini 而且已经有了在线编辑器。有需要的同学自己去考证下。

[2011修正版] 万网和新网域dns名解析
一统飞鸿 快递 单号查询网址


对《关于justhost的安全模式safe mode的修改方法》有 0 条评论