php_screw安装和使用

php_screw 是一个 PHP 源代码加密扩展。

安装和编译

  • 下载

官网下载:phpscrew-1.5

  • 安装
1
2
3
4
5
6
wget https://sourceforge.net/projects/php-screw/files/php-screw/1.5/php_screw-1.5.tar.gz/download
tar -zxvf php_screw-1.5.tar.gz
cd php_screw-1.5
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

执行正常后
在./modules/和/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525下生成php_screw.so文件
执行make intall命令如果出现 :

1
2
3
4
5
6
/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/developer/php_screw-1.5/php_screw.c  -fPIC -DPIC -o .libs/php_screw.o
/home/developer/php_screw-1.5/php_screw.c: 在函数‘zm_startup_php_screw’中:
/home/developer/php_screw-1.5/php_screw.c:124: 错误:‘struct _zend_compiler_globals’没有名为‘extended_info’的成员
/home/developer/php_screw-1.5/php_screw.c: 在函数‘zm_shutdown_php_screw’中:
/home/developer/php_screw-1.5/php_screw.c:133: 错误:‘struct _zend_compiler_globals’没有名为‘extended_info’的成员
make: *** [php_screw.lo] 错误 1

这些信息时:需要修改/home/developer/php_screw-1.5/php_screw.c,下载文件路径因人而异
将 124行,133行 的 CG(extended_info) = 1;修改为:CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
再执行make && make install

  • 修改php.ini,加入扩展

php.ini:

1
extension=php_screw.so

重启php-fpm

  • 生成加密命令
1
2
3
4
5
6
7
8
9
cd /home/developer/php_screw-1.5/tools
#make后会生产 screw命令
make
#测试加密test.php
php_screw-1.5/tools/screw test.php
#执行后输出:
Success Crypting(test.php)
#添加到全局命令
cp screw /usr/bin/

使用

在上面生成了 screw全局命令后

1.整个目录下的文件加密需要用如下命令: 支持子目录

1
2
3
4
#加密当前目录下php文件
find ./ -name "*.php" -print|xargs -n1 screw
#删除加密生产备份文件
find ./ -name "*.screw" -print|xargs -n1 rm

2.单个文件

1
screw a.php
谢谢您请我喝咖啡!