Fatal Error:session_start (): Failed to initialize storage module:files Problem Resolution _php Tutorial

Source: Internet
Author: User
Before compiling the installed version of the LNMP environment +phpmyamdin4.02, this problem suddenly occurs today:
Copy CodeThe code is as follows: Fatal Error:session_start (): Failed to initialize Storage module:files (path:) in/data/www/phpmyadmin/libraries/s Ession.inc.php on line 83
This means that the memory path is incorrect when the session is initialized! The first reaction is to look in the php.ini configuration file:
Copy CodeThe code is as follows: Session.save_path = "/tmp"
The default is preceded by a semicolon, which means it is not enabled, and I have already enabled it when I configured it. Then why do you get an error? , so I found some information on the Internet, feeling all the same:

1. Check the Error.log (apache2.2\logs) file to see if there are any error reports. Not found.
2, check whether the value of Session.save_handler in php.ini is files, if it is not changed to files
3, check whether the Session.save_path in php.ini file is commented, if there is, then remove the front ";".
4. Change the path behind Save_path to an existing path, such as "D:\php\temp"
5. Check that the Temp folder's properties are readable and writable.
6. Restart the Apache server. Ok

I do not know those friends reproduced when they have tried to do not (spray here, the most hated that they did not test, on a brain of the wandering. No responsibility at all!)
According to the above process, the investigation found that there is no solution, but the small part of the server is Nginx non-Apache.
Then I wrote a script test.php:
Copy the Code code as follows:
$r = Session_Start ();
Var_dump ($R);
Printing results are:
Copy the Code code as follows:
Warning:session_start (): SAFE MODE restriction in effect. The script whose UID is 501 are not allowed to access/tmp owned by UID 0 in/data/www/test.php on line 3 Fatal error:sess Ion_start (): Failed to initialize Storage module:files (path:) in/data/www/test.php on line 3

PHP5 a security mode bug, the default session of the Save_path is the system's temporary directory, which will verify the permissions. This script cannot execute UID with/TMP owner UID is 501 and WWW user group permissions
There are two ways to solve this problem:

1. Turn off safe mode;
2. Chown the owner of the file/directory under the command line

Of course both of these methods require you to have the server permissions.
The following is the configuration file for example php.ini:

Copy CodeThe code is as follows:
[Session]
; Handler used to store/retrieve data.
; Http://php.net/session.save-handler
Session.save_handler = files; Argument passed to Save_handler. In the case of files, the the path
; Where data files are stored. Note:windows users has the
; 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's this would do are use subdirectories n-levels deep, and
; Store the session data in those directories. This is useful if you
; Or your OS has problems with lots of the files in one directory, and is
; A more efficient layout for servers that handle lots of sessions.

; NOTE 1:php won't create this directory structure automatically.
; You can use the script with the Ext/session dir for that purpose.
; NOTE 2:see the garbage collection below if you choose to
; Use subdirectories for session storage

; The file storage module creates files using mode by default.
; You can change the 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
; The end all is all of the 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 cookies 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, 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 are the denominator in the equation. Setting this value to 1
; When the Session.gc_divisor value was give you approximately a 1% chance
; The GC would 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, 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 was give you approximately a 1% chance
; The GC would run on any give request. Increasing this value to the give you
; A 0.1% chance the GC would run on any give request. For high volume production servers,
; This was 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 would 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 is using the subdirectory option for storing session files
; (see session.save_path above), then garbage collection does *not*
; happen automatically. You'll 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 1440 (1440 seconds = minutes):
; Find/path/to/sessions-cmin +24 | Xargs RM
; PHP 4.2 and less has an undocumented feature/bug that allows
; To initialize a session variable in the global scope, even when register_globals
; is disabled. PHP 4.3 and later would 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 this feature on production servers. But you
; Should enable the development servers and enable the warning as well. If You
; Do not enable the feature in development servers, you won ' t is warned when it ' s
; Used and debugging errors caused by this can is 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 is 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 have to contain this substring for the session
; 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 used
; On Windows, setting the Entropy_length setting would 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 the trans Sid may risk your users security.
; Use the This option with caution.
; -User may send URL contains active session ID
; To and the person via. Email/irc/etc.
; -URL that contains active session ID may stored
; In publically accessible computer.
; -User may access your site with the same session ID
; Always using URLs 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-bits)
; 1 (SHA-1 bits)
; This option may also is 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 is 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 would look for URLs in a defined set of HTML tags.
; Form/fieldset is special; If you include them here, the Rewriter would
; Add a hiddenfield 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"

Because this is configured on a VPS above, there are several items, so the small series Open a project, found that the verification code of this project function is OK.
So look at the code as follows:
Copy the Code code as follows:
$sessSavePath = "/data/sessions/";
Session Save Path
if (is_writeable ($sessSavePath) && is_readable ($sessSavePath)) {Session_save_path ($sessSavePath);}
if (!empty ($cfg _domain_cookie)) session_set_cookie_params (0, '/', $cfg _domain_cookie);

The above code is a folder before Session_Start () is initialized to determine if a session is present.
So in the phpmyadmin inside of the saved file/phpmyadmin/libraries/session.inc.php made the following changes:
Copy CodeThe code is as follows:
if (! isset ($_cookie[$session _name])) {
On first start of session we check for errors
F.E. Session dir cannot is 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 do before selecting language, so we
* Can not use the translations here.
*/
Pma_fatalerror (' cannot start session without errors, please check errors given in your PHP and/or webserver log file and C Onfigure your PHP installation properly. Also Ensure that cookie is enabled in your browser. ');
}
unset ($orig _error_count);
} else {
Session_save_path ("/data/www/session");
Session_Start ();
}

In Session_Start (); Session_save_path ("/data/www/session") was added earlier; Solved the problem.
Remember to pass @ini_set (' Session.save_path ', "/data/www/session");
This problem bothered me for a few hours, finally solved, so the record, it should be helpful in the future.

http://www.bkjia.com/PHPjc/764624.html www.bkjia.com true http://www.bkjia.com/PHPjc/764624.html techarticle before compiling the installation of the LNMP environment +phpmyamdin4.02 version, this problem suddenly occurs today: the copy Code code is as follows: Fatal Error:session_start (): Failed to initialize storage Mo ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.