PHP Session implementation of multi-level directory storage implementation code, Phpsession
When there are many files in a directory, the server processing performance will be lower, PHP default session is only stored in the/tmp directory, not graded, when there is a certain amount of traffic, there is a performance problem.
First, modify the Session.save_path option for PHP.ini as follows:
Session.save_path = "2;/tmp/session" (remove the front semicolon)
Indicates that the session is stored in the "/tmp/session" directory and is divided into 2 levels of subdirectories
In general, the level 2 directory is enough to handle a significant amount of traffic.
———————–
Other Notes
session.hash_function = 0
; Generates a hash algorithm for the SID. SHA-1 's security is a bit higher.
; 0:MD5 (BITS)
; 1:sha-1 (BITS)
; It is recommended to use SHA-1.
Session.hash_bits_per_character = 4
; Specifies how many bits characters each word in the SID string,
; These binary numbers are the result of the hash function's operation.
; 4:0-9, A-f
; 5:0-9, A-v
; 6:0-9, A-Z, a-Z, "-", ","
; Recommended value is 5
————————–
PHP source files in the ext/session/mod_files.sh file, can assist the generation of directories, you do not have to write a script
#! /bin/sh if test "$" = ""; Thenecho "Usage: $ basedir Depth" exit 1fi if test "$" = "0"; Thenexit 0fi hash_chars= "0 1 2 3 4 5 6 7 8 9 a B c D E F" if test "$"-a "$"-ge "5"; thenhash_chars= "$hash _chars G h i j k l m n o p q R S t u V" if test "$"-eq "6"; Thenhash_chars= "$hash _chars w x y z A B C D E F G H I J K L M N O P Q R S T U V w x y z-," Fifi for I in $hash _chars; Donewpath= "$1/$i" mkdir $newpath | | Exit 1sh $newpath ' expr $2-1 ' $3done
Once set to executable, run the following command to create the hash directory:
#cd/root/soft_install/php-5.3.5/ext/session
#./mod_files.sh/tmp/session 2 5
Three parameters in order, storage path, number of directories, how many directories are generated per directory (refer to Session.hash_bits_per_character)
Also need to pay attention to modify the/tmp/session permissions to ensure that the account running PHP has permission to read and write
http://www.bkjia.com/PHPjc/1098970.html www.bkjia.com true http://www.bkjia.com/PHPjc/1098970.html techarticle PHP Session Implementation of multi-level directory storage implementation code, phpsession when there are many files in a directory, the server processing performance will be lower, PHP default session is only stored in the/tmp directory ...