用Suhosin给你的php打上内核级安全补丁!

用Suhosin给你的php打上内核级安全补丁!

上一篇 / 下一篇  2008-02-25 10:36:47 / 个人分类:IT Work

Suhosin是朝鲜语“守护神”的音译,是一个专门的安全小组开发的专门针对php进行安全加固的补丁程 序,已经进入freebsd gentoo的ports系统。效果很好的。具体的介绍大家可以看看http://www.hardened- php.net/suhosin_096_released.131.html ,国内介绍它的人极少,根本找不到中文的编译安装方法。我耐着性子看完了英文。按照操作安装成功了。现在特别将安装方法共享。欢迎大家试用安装,提高你的 服务器的安全水平。以php5.2.5为例,我的编译目录在/usr/local/src。注意红字是安装Suhosin的具体步骤。

Suhosin是php增强型安全补丁,可以编译到静态内核中,也可以编译成php动态扩展。我个人强烈你建议静态联编。下面的以下先说静态安装步骤。当然你也可以在安装php后将它编译成php的动态扩展。

# cd /usr/local/src
# wget http://cn.php.net/get/php-5.2.5.tar.gz/from/this/mirror
wget http://www.hardened-php.net/suhosin/_media/suhosin-patch-5.2.5-0.9.6.2.patch.gz //从官方下载补丁
# tar zxvf php-5.2.5.tar.gz
# gunzip suhosin-patch-5.2.5-0.9.6.2.patch.gz // 解压补丁
# cd php-5.2.5
# patch -p 1 -i ../suhosin-patch-5.2.5-0.9.6.2.patch // 给php打上补丁
# ./buildconf --force //一定要执行这一步。

# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib-dir --with-bz2 --with-tiff-dir --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2 --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/etc --with-iconv --disable-ipv6 --enable-static --enable-maintainer-zts --enable-memory-limit --enable-zend-multibyte --enable-sockets --enable-soap --enable-suhosin // 配置选项

# make

# make install

重启 apachectl,查看phpinfo信息,会出现
This server is protected with the Suhosin Patch 0.9.6.2
Copyright (c) 2006 Hardened-PHP Project

等许多Suhosin信息那么你就成功了。呵呵。

在这里也顺便说一下将suhosin安装成为php的动态扩展的方法。

wget http://download.suhosin.org/suhosin-0.9.23.tgz
tar zxvfsuhosin-0.9.23.tgz
cd suhosin-0.9.23
/usr/local/php/bin/phpize    //这一步不能省
./configure --with-php-config=/usr/local/php/bin/php-config //必须在这儿注明php-config所在的绝对路径。
make
make install

会提示编译的模块存在的目录,记住它。
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

然后在php.ini中增加一行下列语句。
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/suhosin.so

猜你喜欢

转载自icarusli.iteye.com/blog/648654
今日推荐