If the Ubuntu/debian, using apt installed PHP, then in the session, there may be a small probability of encountering this hint.
Copy Code code as follows:
PHP Notice:session_start (): Ps_files_cleanup_dir:
Opendir (/VAR/LIB/PHP5) Failed:permission denied (13)
in/home/laruence/www/htdocs/index.php on line 22
This is because, in PHP, if you use File_handler as the session's save handler, then there is the probability of running the session's GC process every session_start.
Copy Code code as follows:
Have omitted
int nrdels =-1;
Nrand = (int) (float) PS (gc_divisor) * PHP_COMBINED_LCG (Tsrmls_c));
if (Nrand < PS (gc_probability)) {
PS (MoD)->s_gc (&ps (Mod_data), PS (gc_maxlifetime), &nrdels tsrmls_cc);
}
Have omitted
The reason for this warning is because in apt PHP, the default directory/VAR/LIB/PHP5 of the session is 733 with sticky bit, which is
Copy Code code as follows:
The general PHP worker is running in non-root status, so there is no permission to open the folder (but because it can write, so does not affect the normal session file read). So the following code in the S_GC triggers the beginning of the notice:
Copy Code code as follows:
For file handler, S_GC calls Ps_files_cleanup_dir indirectly:
dir = Opendir (dirname);
if (!dir) {
Php_error_docref (NULL tsrmls_cc, E_notice,
"Ps_files_cleanup_dir:opendir (%s) failed:%s (%d)",
DirName, Strerror (errno), errno);
return (0);
}
Of course, under Ubuntu/debian, there are GC recoveries, just external cron processes that are done by default in/ETC/CRON.D/PHP5:
Copy Code code as follows:
09,39 * * * * root [-x/usr/lib/php5/maxlifetime]
&& [-D/VAR/LIB/PHP5] && find/var/lib/php5/
-type f-cmin +$ (/usr/lib/php5/maxlifetime)-print0
| Xargs-n 200-r-0 RM
In addition, you can see that there are two key variables: PS (gc_divisor) and PS (gc_probability), which correspond to the two configuration items of the session's Run-time configuration entry, when the S_GC is judged to be running:
Session.gc_probability and Session.gc_divisor, respectively, default to 1 and 100.
The PHP_COMBINED_LCG is a random number generator that generates random numbers ranging from 0 to 1, so the above discriminant is equivalent to:
Copy Code code as follows:
Rand < Probability/gc_divisor
That is, by default, a GC process can be invoked almost 100 times. So that's a small probability to see this notice.
To turn off this notice, you only need to set:
session.gc_probability = 0, let the s_gc completely not run the possibility can.
Of course, you can also change the permissions of this folder ...