Php_screw is really good, but it can only play the role of encryption, and does not accelerate and optimize the role.
Let's take a look at the following:
Turck MMCache
Its role is through the compilation of PHP code to accelerate, optimize the PHP code, if we publish the PHP code is compiled, how many can play a number of protection of the Code.
Below we compile the compute.php to see before and after the code difference, the following is the compute.php source code
? ============ compute.php file used for cyclic computation ================//$a = 0; $t =time (); For ($i =0 $i <6000000; $i + +) {$a = $a * $i;} $t 1=time (); echo "<p>"; echo "It used:"; echo $t 1-$t; echo "seconds";?>
The following is a compiled compute.php file
Copy Code code as follows:
<?php if (!is_callable ("Mmcache_load") &&! @dl (php_os== "WINNT" | | php_os== "WIN32")? " TurckLoader.dll ":" turckloader.so)) {die ("This PHP script has been encoded with Turck MMCache, to run it for you must install <a href= "http://turck-mmcache.sourceforge.net/" >turck MMCache or Turck loader</a>); Return Mmcache_load (' Ejzz9xv2dpzwzwbiygbgzabrzawgom0aaakggoodixgozqxuwjdiqmbiymdiicy Zbqvtgmcmmdkzaomsznzudhtdjyxqtiwmliwyxmyigrvacbcubqplzgzojybbpsvmxcarhtcmbnsjxqotrdiahn CXJNHOLQGS7MXC5V5QKJQYAT3FWMDCBNOQWCGMC icbajskeq4gy7neobq4ncuk7himujezgjazmgkwmsbpyqeyilot8/ Nsipfeqeov7bghwqaeam45h7y= ');? >
It is not difficult to find that by releasing the compiled program, you should be able to effectively prevent the program from being tampered with.
website
http://turck-mmcache.sourceforge.net/
How to get Turck-mmcache
1 can be obtained through its website
2 download from the URL below
Http://prdownloads.sourceforge.net/turck-mmcache/turck-mmcache-2.4.6.tar.gz?download
Installation
1. Put the downloaded turck-mmcache-2.4.6.tar.gz under/usr/local to decompress
Tar zxvf turck-mmcache-2.4.6.tar.gz
2. Enter the turck-mmcache-2.4.6 directory, configure
CD turck-mmcache-2.4.6 export php_prefix= "/usr" $PHP _prefix/bin/phpize./configure--enable-mmcache=shared- with-php-config= $PHP _prefix/bin/php-config
3. Compile, install
Make make Install
4. Modify the php.ini file in the/etc/apache/directory, in order to be able to use Turck-mmcache.
Add the following in the php.ini file:
Copy Code code as follows:
extension= "mmcache.so" mmcache.shm_size= "mmcache.cache_dir="/tmp/mmcache "mmcache.enable=" "1" mmcache.optimizer = "1" mmcache.check_mtime= "1" mmcache.debug= "0" mmcache.filter= "" mmcache.shm_max= "0" mmcache.shm_ttl= "0" Mmcache.shm _prune_period= "0" mmcache.shm_only= "0" mmcache.compress= "1"
5. Restart Apache
/ETC/RC.D/RC.HTTPD restart
Through the above 5 steps, Turck-mmcache already can use, below we to the acceleration, the optimization effect carries on the simple test.
Test
1. Write a compute.php file, to carry out a large number of cyclic calculations, before and after the operation of the system to take the time, and finally two times to subtract, to get the time used. (Just a rough estimate)
The contents of the compute.php file are as follows
? ============ compute.php file used for cyclic computation ================//$a = 0; $t =time (); For ($i =0 $i <6000000; $i + +) {$a = $a * $i;} $t 1=time (); echo "<p>"; echo "It used:"; echo $t 1-$t; echo "seconds";?>
2. Calculate the time spent in the compilation time, that is, in the browser call I have just written compute.php file. Need to be patient for a moment, about 30 seconds (P3 500 CPU)
3. In order to compile PHP files conveniently, we write a shell called Encoder to compile the php file.
<1> first copy the encoder.php file under the/usr/local/turck-mmcache-2.4.6 directory to the/usr/bin directory
cp/usr/local/turck-mmcache-2.4.6/encoder.php/usr/bin/
<2> use VI Encoder to establish encoder documents as follows:
#!/bin/sh Clear src=$1; Echo $src; Src2= $src ". en"; echo $SRC 2; cp/usr/bin/encoder.php./encoder.php php encoder.php $src-o $src 2; RM encoder.php mv $src $src. bak; MV $src. En $src;
<3> give executable permission to the shell just written and move to the/usr/bin directory
chmod +x encoder MV encoder/usr/bin/
<4> compile compute.php file through encoder, compile compute.php file after compiling, source file is named Compute.php.bak save
Encode compute.php
<5> call the compiled compute.php file in the browser to see if the speed is improved?
I am here, the original to use 27 seconds, compiled with 22 seconds
The difference between Php_screw and Turck-mmcache
Php_screw is just a simple encryption of PHP code, and there is no acceleration and optimization of the effect.
Turck-mmcache is a compilation of PHP code that enables PHP code to interpret the speed at which the execution can be close to the binary code. Can play a role in accelerating and optimizing PHP code. But Turck-mmcache compiled code, only to the source code through a certain rule into the binary code, and there is no real encryption.
So if you want to ensure the absolute safety of the code with Php_screw, if you take into account the speed and other factors, is the use of Turck-mmcache