测试

创建一个名为test.php的文件:

sudo vi /var/www/test.php

代码如下:

<?php
     phpinfo();
?>

使用浏览器打开

http://服务器ip/test.php

配置suhosin

编辑文件/etc/php5/mods-available/suhosin.ini:

# vi /etc/php5/mods-available/suhosin.ini

其中定义了不允许被调用的函数的黑名单和白名单,使用逗号分隔。

suhosin.executor.func.blacklist = assert,unserialize,exec,popen,proc_open,passthru,shell_exec,system,hail,parse_str,mt_srand
suhosin.executor.eval.whitelist = assert,unserialize,exec,popen,proc_open,passthru,shell_exec,system,hail,parse_str,mt_srand

需要重启php5-fpm使配置生效。

在Debian 8和Ubuntu 14.04 LTS中使用Suhosin保护PHP网站

如何保护PHP网站?
如何在Debian v8.x或Ubuntu Linux 14.04 LTS服务器上安装suhosin扩展程序?

Suhosin是一个PHP扩展程序。用于保护PHP Web应用程序(如WordPress等)的安全。

如何在Debian和Ubuntu上安装Suhosin

在Ubuntu Linux 14.04 LTS服务器上执行以下命令:

sudo -s
echo 'deb http://repo.suhosin.org/ ubuntu-trusty main' >> /etc/apt/sources.list
apt-get update

Debian Linux 8.x用户执行以下命令:

sudo -s
echo 'deb http://repo.suhosin.org/ debian-jessie main' >> /etc/apt/sources.list
apt-get update

使用wget命令安装密钥签名

## Run as root user ##
wget https://sektioneins.de/files/repository.asc
sudo apt-key add repository.asc

然后使用以下apt-get命令, 安装php5-suhosin-extension软件包:

sudo apt-get install php5-suhosin-extension

启用php5-suhosin-extension

sudo php5enmod php5-suhosin

在Ubuntu LTS 14.04上重启php5-fpm

sudo /sbin/restart php5-fpm

在Debian Linux 8.0上重启php5-fpm

sudo systemctl restart php5-fpm
日期:2019-11-20 08:52:01 来源:oir作者:oir