PHP install diseval extension to disable eval()

Why install?
eval is a language constructor, not a function, and cannot be disabled by disable_functions

Disabling methods
Installing this extension will disable the following dangerous methods:
eval(), create_function(), mb_ereg_replace(), assert()

Steps:
1. Install php-dev

if it is ubuntu/debian system, use: (note the PHP version)

# PHP5
sudo apt-get install php-dev
# PHP7
sudo apt-get install php7.0-dev

If it is a redhat/centos/fedora system, use:

yum install php-devel

2. Download PHP_diseval_extension

github address: https://github.com/mk-j/PHP_diseval_extension

terminal:

cd /tmp
git clone https://github.com/mk-j/PHP_diseval_extension.git

cd /tmp/PHP_diseval_extension/source

//使用PHP安装路径的phpize
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

After the compilation is successful, the return is as follows:

Installing shared extensions:     /usr/lib/php/20151012/

3. Turn on the extension

Edit php.ini directly to add a line:

extension=diseval.so

Guess you like

Origin blog.csdn.net/qq_39004843/article/details/109186525