支持CPanel的空间如何使用自定义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: [email protected] 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 而且已经有了在线编辑器。
有需要的同学自己去考证下。
—EOF—
上一篇: 这是一个充满奇迹的国度
这篇文章的帮助真的太大了,真的是可以,不过确实要把php.ini上传到每个目录,转一下您的文章了,谢谢帮助!
有用就好