failed to nuiinitialize failed怎么解决

Fatal error: session_start(): Failed to initialize storage module: files问题解决方法
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了Fatal error: session_start(): Failed to initialize storage module: files问题解决方法,需要的朋友可以参考下
之前编译安装的LNMP环境+phpmyamdin4.02的版本,今天突然出现这个问题: 代码如下:Fatal error: session_start(): Failed to initialize storage module: files (path: ) in /data/www/phpmyadmin/libraries/session.inc.php on line 83大致意思是session会话初始化的时候储存路径有误!第一反应就是查看php.ini的配置文件中的: 代码如下:session.save_path = "/tmp"默认前面是加的分号,表示不启用,我之前配置的时候已经启用了。那为什么还会报错呢?,于是网上找了一些资料,感觉都千篇一律:1、检查error.log(Apache2.2\logs)文件,查看是否有错误报告。未发现。2、检查php.ini中的session.save_handler的值是否为files,如果不是改为files3、检查php.ini文件中session.save_path是否被注释了,如果有,则去掉前面的”;”。4、将save_path后面的路径改成已有的路径,比如”D:\php\temp”5、检查temp文件夹的属性是否可读可写。6、重启APACHE服务器。OK
不知道那些哥们转载的时候自己试过了没有(在这里喷一下,最讨厌那种自己都没有亲测,就一股脑的转来转去。一点都不负责!)根据上面的流程,排查了之后发现压根就没有解决,不过小编的服务器是nginx非apache。然后自己写了一个脚本test.php: 代码如下:$r = session_start(); var_dump($r);打印结果为: 代码如下:Warning: session_start(): SAFE MODE Restriction in effect. The script whose uid is 501 is not allowed to access /tmp owned by uid 0 in /data/www/test.php on line 3 Fatal error: session_start(): Failed to initialize storage module: files (path: ) in /data/www/test.php on line 3意思是 php5一个安全模式的bug,默认session的save_path是系统的临时目录,这样会要校验权限。而这个脚本不能通过/tmp拥有者uid为0来执行uid是501也是www用户组的权限解决这个有两种解决方法:
1.关闭安全模式;2.在命令行下chown改文件/目录的拥有者
当然两种方法都要求你有服务器的权限。下面是示例php.ini的配置文件:
代码如下:[Session]&; Handler used to store/retrieve data.&; http://php.net/session.save-handlersession.save_handler = Argument passed to save_handler.& In the case of files, this is the path&; where data files are stored. Note: Windows users have to change this&; variable in order to use PHP's session functions.&; The path can be defined as:&;&&&& session.save_path = "N;/path"&; where N is an integer.& Instead of storing all the session files in&; /path, what this will do is use subdirectories N-levels deep, and&; store the session data in those directories.& This is useful if you&; or your OS have problems with lots of files in one directory, and is&; a more efficient layout for servers that handle lots of sessions.&; NOTE 1: PHP will not create this directory structure automatically.&;&&&&&&&& You can use the script in the ext/session dir for that purpose.&; NOTE 2: See the section on garbage collection below if you choose to&;&&&&&&&& use subdirectories for session storage&; The file storage module creates files using mode 600 by default.&; You can change that by using&;&&&& session.save_path = "N;MODE;/path"&; where MODE is the octal representation of the mode. Note that this&; does not overwrite the process's umask.&; http://php.net/session.save-path&session.save_path = "/tmp"; Whether to use cookies.&; http://php.net/session.use-cookies&session.use_cookies = 1; http://php.net/session.cookie-secure&;session.cookie_secure =; This option forces PHP to fetch and use a cookie for storing and maintaining&; the session id. We encourage this operation as it's very helpful in combatting&; session hijacking when not specifying and managing your own session id. It is&; not the end all be all of session hijacking defense, but it's a good start.&; http://php.net/session.use-only-cookies&session.use_only_cookies = 1; Name of the session (used as cookie name).&; http://php.net/session.name&session.name = PHPSESSID; Initialize session on request startup.&; http://php.net/session.auto-start&session.auto_start = 0; Lifetime in seconds of cookie or, if 0, until browser is restarted.&; http://php.net/session.cookie-lifetime&session.cookie_lifetime = 0; The path for which the cookie is valid.&; http://php.net/session.cookie-path&session.cookie_path = /; The domain for which the cookie is valid.&; http://php.net/session.cookie-domain&session.cookie_domain =; Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript.&; http://php.net/session.cookie-httponly&session.cookie_httponly =; Handler used to serialize data.& php is the standard serializer of PHP.&; http://php.net/session.serialize-handler&session.serialize_handler = php; Defines the probability that the 'garbage collection' process is started&; on every session initialization. The probability is calculated by using&; gc_probability/gc_divisor. Where session.gc_probability is the numerator&; and gc_divisor is the denominator in the equation. Setting this value to 1&; when the session.gc_divisor value is 100 will give you approximately a 1% chance&; the gc will run on any give request.&; Default Value: 1&; Development Value: 1&; Production Value: 1&; http://php.net/session.gc-probability&session.gc_probability = 1; Defines the probability that the 'garbage collection' process is started on every&; session initialization. The probability is calculated by using the following equation:&; gc_probability/gc_divisor. Where session.gc_probability is the numerator and&; session.gc_divisor is the denominator in the equation. Setting this value to 1&; when the session.gc_divisor value is 100 will give you approximately a 1% chance&; the gc will run on any give request. Increasing this value to 1000 will give you&; a 0.1% chance the gc will run on any give request. For high volume production servers,&; this is a more efficient approach.&; Default Value: 100&; Development Value: 1000&; Production Value: 1000&; http://php.net/session.gc-divisor&session.gc_divisor = 1000; After this number of seconds, stored data will be seen as 'garbage' and&; cleaned up by the garbage collection process.&; http://php.net/session.gc-maxlifetime&session.gc_maxlifetime = 1440; NOTE: If you are using the subdirectory option for storing session files&;&&&&&& (see session.save_path above), then garbage collection does *not*&;&&&&&& happen automatically.& You will need to do your own garbage&;&&&&&& collection through a shell script, cron entry, or some other method.&;&&&&&& For example, the following script would is the equivalent of&;&&&&&& setting session.gc_maxlifetime to
seconds = 24 minutes):&;&&&&&&&&& find /path/to/sessions -cmin +24 | xargs rm; PHP 4.2 and less have an undocumented feature/bug that allows you to&; to initialize a session variable in the global scope, even when register_globals&; is disabled.& PHP 4.3 and later will warn you, if this feature is used.&; You can disable the feature and the warning separately. At this time,&; the warning is only displayed, if bug_compat_42 is enabled. This feature&; introduces some serious security problems if not handled correctly. It's&; recommended that you do not use this feature on production servers. But you&; should enable this on development servers and enable the warning as well. If you&; do not enable the feature on development servers, you won't be warned when it's&; used and debugging errors caused by this can be difficult to track down.&; Default Value: On&; Development Value: On&; Production Value: Off&; http://php.net/session.bug-compat-42&session.bug_compat_42 = Off; This setting controls whether or not you are warned by PHP when initializing a&; session value into the global space. session.bug_compat_42 must be enabled before&; these warnings can be issued by PHP. See the directive above for more information.&; Default Value: On&; Development Value: On&; Production Value: Off&; http://php.net/session.bug-compat-warn&session.bug_compat_warn = Off; Check HTTP Referer to invalidate externally stored URLs containing ids.&; HTTP_REFERER has to contain this substring for the session to be&; considered as valid.&; http://php.net/session.referer-check&session.referer_check =; How many bytes to read from the file.&; http://php.net/session.entropy-length&session.entropy_length = 0; Specified here to create the session id.&; http://php.net/session.entropy-file&; On systems that don't have /dev/urandom /dev/arandom can be used&; On windows, setting the entropy_length setting will activate the&; Windows random source (using the CryptoAPI)&;session.entropy_file = /dev/urandom; Set to {nocache,private,public,} to determine HTTP caching aspects&; or leave this empty to avoid sending anti-caching headers.&; http://php.net/session.cache-limiter&session.cache_limiter = nocache; Document expires after n minutes.&; http://php.net/session.cache-expire&session.cache_expire = 180; trans sid support is disabled by default.&; Use of trans sid may risk your users security.&; Use this option with caution.&; - User may send URL contains active session ID&;&& to other person via. email/irc/etc.&; - URL that contains active session ID may be stored&;&& in publically accessible computer.&; - User may access your site with the same session ID&;&& always using URL stored in browser's history or bookmarks.&; http://php.net/session.use-trans-sid&session.use_trans_sid = 0; Select a hash function for use in generating session ids.&; Possible Values&;&& 0& (MD5 128 bits)&;&& 1& (SHA-1 160 bits)&; This option may also be set to the name of any hash function supported by&; the hash extension. A list of available hashes is returned by the hash_algos()&; function.&; http://php.net/session.hash-function&session.hash_function = 0; Define how many bits are stored in each character when converting&; the binary hash data to something readable.&; Possible values:&;&& 4& (4 bits: 0-9, a-f)&;&& 5& (5 bits: 0-9, a-v)&;&& 6& (6 bits: 0-9, a-z, A-Z, "-", ",")&; Default Value: 4&; Development Value: 5&; Production Value: 5&; http://php.net/session.hash-bits-per-character&session.hash_bits_per_character = 5; The URL rewriter will look for URLs in a defined set of HTML tags.&; form/ if you include them here, the rewriter will&; add a hidden &input& field with the info which is otherwise appended&; to URLs.& If you want XHTML conformity, remove the form entry.&; Note that all valid entries require a "=", even if no value follows.&; Default Value: "a=href,area=href,frame=src,form=,fieldset="&; Development Value: "a=href,area=href,frame=src,input=src,form=fakeentry"&; Production Value: "a=href,area=href,frame=src,input=src,form=fakeentry"&; http://php.net/url-rewriter.tags&url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
因为这个是在一台VPS上面配置的,上面有多个项目,于是小编打开一个项目,发现此项目的验证码功能是OK的。于是查看代码如下: 代码如下:$sessSavePath = "/data/sessions/";&// Session保存路径&if(is_writeable($sessSavePath) && is_readable($sessSavePath)){ session_save_path($sessSavePath); }&if(!empty($cfg_domain_cookie)) session_set_cookie_params(0,'/',$cfg_domain_cookie);
上面这个代码是在session_start() 初始化之前来判断是否存在session会话的文件夹。于是就在phpmyadmin里面的保存的那个文件/phpmyadmin/libraries/session.inc.php做了下修改: 代码如下:if (! isset($_COOKIE[$session_name])) {&// on first start of session we check for errors&// f.e. session dir cannot be accessed - session file not created&$orig_error_count = $GLOBALS['error_handler']-&countErrors();&//session_save_path('./tmp');&session_save_path("/data/www/session");&$r = session_start();&if ($r !== true&|| $orig_error_count != $GLOBALS['error_handler']-&countErrors()&) {&setcookie($session_name, '', 1);&/*&* Session initialization is done before selecting language, so we&* can not use translations here.&*/&PMA_fatalError('Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly. Also ensure that cookies are enabled in your browser.');&}&unset($orig_error_count);&} else {&session_save_path("/data/www/session");&session_start();&}
在 session_start();& 前面添加了& session_save_path(“/data/www/session”); 就解决了这个问题。切记通过@ini_set(‘session.save_path', ”/data/www/session”);无效!这个问题困扰了我几个小时,终于解决了,所以就记录下来,对日后应该会有帮助。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具杀手5:赦免 提示Failed to initialize DirectX 11,怎么办?
解决办法:更新驱动驱动精灵(一键更新):
安装MSXML6.0: 安装DX:
大小:12.8G
请先输入你要提问的游戏名称:
问题标题(一句话简要说明):
问题标题只可以输入40个汉字
问题补充说明(可选):利尔达技术论坛 - 使用IAR出现了failed to initialize device是怎么会事?
(/index.php)
(/forumdisplay.php?f=54)
(/showthread.php?t=27823)
使用IAR出现了failed to initialize device是怎么会事?&
菜鸟请教各位:使用IAR Embedded Workbench IDE调试RELEASE时出现了failed to initialize device是怎么回事啊?有哪几种可能?
一般就是仿真器与单片机的连接有问题,建议检查你的jtag连接和复位电路,复杂一点的就是单片机熔丝已经烧断或单片机坏掉了,但是后者可能性不是很大
是你没选对仿真头&
作者: suchener
(帖子 125208)
菜鸟请教各位:使用IAR Embedded Workbench IDE调试RELEASE时出现了failed to initialize device是怎么回事啊?有哪几种可能?
我换了3.42板的iar后它默认是usb仿真的,要选回串口fet debbuger---&&TI
johnson207
我也刚遇到这个问题,忘了设置仿真器类型了,感谢大家
作者: suchener
(帖子 125208)
菜鸟请教各位:使用IAR Embedded Workbench IDE调试RELEASE时出现了failed to initialize device是怎么回事啊?有哪几种可能?
右键你的文件 ,在Options 里面的Device选择你所使用的芯片类型
检查板子看看
有没有装USB接口的驱动?
fufengshou
我也遇到了问题!:kuso2
所有时间均为北京时间。现在的时间是 。
Powered by vBulletin Version 3.6.8
版权所有 &2000 - 2016,Jelsoft Enterprises Ltd.
中文语言包:当前位置:
参考问题:《战地3》游戏运行时提示:failed to initialize display adapter怎么解决?
解决方法:建议您首先检查是否安装了最新版的direct9.0(下载地址:);
若已安装的话,那么请尝试更新显卡驱动(若不知道该如何更新,请下载驱动人生或驱动精灵更新);
若还是无法解决,那么可能您的电脑显卡硬件配置无法满足游戏所需要求,请更换更加强力的显卡硬件。
游戏大小: 14.36GB
游戏类型: 第一人称射击
游戏语言: 英文
发布时间:
操作系统: Vista,winXP,win7,win8
攻略排行周月
《黎明杀机》中怎么上段?今天小编要为大家带来玩家分享的《黎明杀机…
《火影忍者究极风暴4》很多玩家都通关了,但是回味整个故事模式还是…
本类一周热点
奇迹暖暖满天繁星活动自去年12月更新之后,截止到今日已经有半年多…
近日很多小伙伴,一直在寻找7月15日的半价英雄以及7月15日半价…
玩游戏网 Corporation, All Rights Reserved 湘ICP备号-3

我要回帖

更多关于 initialize failed 的文章

 

随机推荐