最近用 codeigniter 写一个小系统,引用了session 库,codeigniter默认的session存储方式为files。鉴于安全性,文件即肯定涉及到权限问题。

在类 UNIX 操作系统中,这可以通过在该目录上执行 chmod 命令,将权限设置为 0700 来实现, 这样就可以只允许目录的所有者执行读取和写入操作。但是要注意的是,脚本的执行者通常不是你自己, 而是类似于 'www-data' 这样的用户,所以只设置权限可能会破坏你的程序。

但用户买的是万网的虚拟主机,默认是没有开启 chmod 函数的设置。于是就碰到了这个问题:"chmod() has been disabled for security reasons"。解决方法有两个:

1.开启设置

登录万网虚拟主机控制面板:点击左侧【高级环境设置】->【php.ini设置】,将【chmod函数】设置为开启。

2.更换session存储方式为数据库驱动

在config.php文件里设置

$config['sess_driver'] = 'database';
$config['sess_save_path'] = 'ci_sessions';

要求在数据库中建表:ci_sessions,如MySql:

CREATE TABLE IF NOT EXISTS `ci_sessions` (
`id` varchar(40) NOT NULL,
`ip_address` varchar(45) NOT NULL,
`timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
`data` blob NOT NULL,
KEY `ci_sessions_timestamp` (`timestamp`)
);

参考资料

http://codeigniter.org.cn/user_guide/libraries/sessions.html

https://help.aliyun.com/knowledge_detail/36434.html

chmod() has been disabled for security reasons的更多相关文章

  1. wordpress编辑主题时报错Warning: scandir() has been disabled for security reasons in

    在ubuntu下面安装了一个wordpress程序,在后台什么都没干,编辑主题时,发现页面中报下面的错误. notice: /home/wwwroot/test.localhost/wordpress ...

  2. shell_exec() has been disabled for security reasons错误怎么解决?

    ytkah在用composer安装插件时出现了shell_exec() has been disabled for security reasons错误提示,这个是php配置的问题,shell_exe ...

  3. [think\exception\ErrorException] glob() has been disabled for security reasons

    今天同事开发 出现了这个错误 [think\exception\ErrorException] glob() has been disabled for security reasons 打开php. ...

  4. FastAdmin 在 CRUD 时出现 exec() has been disabled for security reasons 怎么办?

    FastAdmin 在 CRUD 时出现 exec() has been disabled for security reasons 怎么办? 有小伙伴提问 FastAdmin 在 CRUD 时出现 ...

  5. Warning: popen() has been disabled for security reasons in OS/Guess.php on line 241

    今天使用pecl install swoole命令编译安装swoole的时候提示:Warning: popen() has been disabled for security reasons in ...

  6. Workman启动失败的解决方法 stream_socket_server() has been disabled for security reasons

    1.报如下错误,问题是php版本太低 php -ini 看下你的版本 http://doc2.workerman.net/how-distributed.html 参考: https://blog.c ...

  7. 解决报错:scandir() has been disabled for security reasons

    服务器环境: LNMP 在服务器部署代码时候.遇到了这个问题. 蛋疼啊! 2 解决办法:  打开phpinfo.php , 搜索: scandir 找到disabled_function,确认此函数未 ...

  8. lnmp -- 解决Warning: scandir() has been disabled for security reasons in…的问题

    原因:LNMP 0.9禁用了部分存在危险的PHP函数 LNMP0.9禁用的PHP函数包括:passthru, exec, system, chroot, scandir, chgrp, chown, ...

  9. PHP Warning exec() has been disabled for security reasons怎么办

    如果是PHPNOW,还是找到php-apache2handler.ini这个文件,把禁用的函数去掉即可. 注意是这个文件夹

随机推荐

  1. jquery笔记(效果)

    显示/隐藏: $(selector).hide(speed, function()):隐藏 $(selector).show(speed, function()):隐藏 $(selector).tog ...

  2. C#生成PDF总结

    (一)C#生成PDF总结 (1)iTextSharp控件对iTextSharp研究还可以表格.文字.各种GDI对象,图片,水印,文字旋转(2)aspose的控件(3)PDF Library这个类库(只 ...

  3. 向Web开发人员推荐12款优秀的 Twitter Bootstrap 组件和工具

    http://www.cnblogs.com/lhb25/archive/2012/09/11/resources-that-complement-twitter-bootstrap.html

  4. ccc animation

    cc.Class({ extends: cc.Component, properties: { sheepAnim: { default: null, type: cc.Animation } }, ...

  5. BZOJ4504 : K个串

    从左往右枚举右端点,用一棵线段树维护每个左端点的去重后的区间和. 那么对于$a[r]$,需要在$[pre[a[r]]+1,r]$里区间加上$a[r]$. 将线段树可持久化,并维护区间最大值,就可以在线 ...

  6. 【转】推荐UML插件AmaterasUML

    基于Green UML在使用过程中的问题(对于大工程,点击生成类图后不响应),自己只能再次寻找其他的插件.在无意中,发现AmaterasUML. 官方网站:http://amateras.source ...

  7. Codeforces Round #246 (Div. 2) B. Football Kit

    题目的意思是求出每个队穿主场衣服和客场衣服的次数 每个队作为主场的次数是n-1,作为客场的次数是n-1 当每个队打主场的时候肯定穿的主场衣服 当每个队打客场时,如果客场与主场的衣服不同,则穿客场衣服 ...

  8. 转载:移动前端开发之viewport的深入理解

    原文作者:无双 原文链接:http://www.cnblogs.com/2050/p/3877280.html 在移动设备上进行网页的重构或开发,首先得搞明白的就是移动设备上的viewport了,只有 ...

  9. 《深入理解Windows Phone 8.1 UI控件编程》基于最新的Runtime框架

    <深入理解Windows Phone 8.1 UI控件编程>本书基于最新的Windows Phone 8.1 Runtime SDK编写,全面深入地论述了最酷的UI编程技术:实现复杂炫酷的 ...

  10. 【BZOJ】1406: [AHOI2007]密码箱

    http://www.lydsy.com/JudgeOnline/problem.php?id=1406 题意:求$0<=x<n, 1<=n<=2,000,000,000, 且 ...