一次dede5.7远程图片本地化失败的原因分析!

admin 2012 年 7 月 22 日 留言评论 点击:1937

前几天自己找空间商换了个VPS。换了之后,自己还是跟以前一样搭建lnmp环境。用的还是军哥的lnmp一键安装包。军哥的lnmp包目前是0.9版本的。

在装了之后,装了个dede,后来发现了一个问题,就是远程图片无法下载。在检查了系统设置没有错误之后,自己就很肯定是服务器的环境问题。

于是好好看了看lnmp0.9的相关说明,发现军哥在官网上说明了。lnmp0.9禁止很很多php的危险函数。
后来在网上搜了下相关dede远程图片所需要的php函数。说明php是需要支持fsockopen函数的,于是终于知道原因了。

php.ini配置文件的目录位置:/usr/local/php/etc/php.ini(这个很多朋友会很熟悉)

另外在这里说明一下,DZX在lnmp0.9默认的环境下UC通信是不成功的,因为没有开放pfsockopen、fsockopen这个两个函数。

于是自己动手在php.ini中查找disable_functions。后面有很多函数被禁止了,如果你需要开通的就直接去除相关的选项。然后/etc/init.d/php-fpm restart

就行了。

 

下面是军哥给出的解决办法:

目前LNMP 0.9禁用了部分危险函数:passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,fsockopen

由于禁用了pfsockopen、fsockopen 会造成 Discuzx Discuz X通行失败,通过Socket连接SMTP无法发送邮件 或wordrpess的Akismet 无法工作:
引用:
您的主机似乎禁用了 PHP 的 fsockopen 或 gethostbynamel 函数。在此问题修复之前,Akismet 无法工作。请联系您的主机服务管理员或防火墙管理员,并向他们提供 Akismet 的运行环境要求。
解决方法:
目前最常可能用到的就是pfsockopen、fsockopen,如果将这2个函数从禁用列表里删除可以执行:
复制内容到剪贴板
代码:


sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket/g' /usr/local/php/etc/php.ini
然后执行:/etc/init.d/php-fpm restart 重启生效

如果想完全删掉禁用列表里的函数可以执行:

sed -i 's/disable_functions =.*/disable_functions =/g' /usr/local/php/etc/php.ini
再执行:/etc/init.d/php-fpm restart 重启生效

wordpress3.4后主题管理不显示其他的主题?
解决方法:将scandir 函数从禁用列表里删掉就行了。

代码:
sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket/g' /usr/local/php/etc/php.ini
然后执行:/etc/init.d/php-fpm restart 重启生效

安装好ImageMagick,在后台设置好路径,但是无法预览缩略图效果?
解决方法:将exec 函数从禁用列表里删掉就行了。
代码:
sed -i 's/disable_functions =.*/disable_functions = passthru,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket/g' /usr/local/php/etc/php.ini
然后执行:/etc/init.d/php-fpm restart 重启生效

留言评论

必填

Required, 保密

WordPress › Error