Suhosin是朝鮮語“守護神”的音譯,是一個專門的安全小組開發(fā)的專門針對php進行安全加固的補丁程 序,已經(jīng)進入freebsd gentoo的ports系統(tǒng)。效果很好的。具體的介紹大家可以看看http://www.hardened- php.net/suhosin_096_released.131.html ,國內介紹它的人極少,根本找不到中文的編譯安裝方法。我耐著性子看完了英文。按照操作安裝成功了,F(xiàn)在特別將安裝方法共享。歡迎大家試用安裝,提高你的 服務器的安全水平。以php5.2.5為例,我的編譯目錄在/usr/local/src。注意紅字是安裝Suhosin的具體步驟。
Suhosin是php增強型安全補丁,可以編譯到靜態(tài)內核中,也可以編譯成php動態(tài)擴展。我個人強烈你建議靜態(tài)聯(lián)編。下面的以下先說靜態(tài)安裝步驟。當然你也可以在安裝php后將它編譯成php的動態(tài)擴展。
# 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 //一定要執(zhí)行這一步。
# 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信息,會出現(xiàn)
This server is protected with the Suhosin Patch 0.9.6.2
Copyright (c) 2006 Hardened-PHP Project
等許多Suhosin信息那么你就成功了。呵呵。
在這里也順便說一下將suhosin安裝成為php的動態(tài)擴展的方法。
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
suhosin.executor.disable_eval = on(轉過來時缺少這段,沒有這段是無效的對禁用eval函數(shù))
注:上邊是轉過來的。如果在gentoo上是沒有關系的,但是在centos上。
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/suhosin.so
是不管用的。會提示找到動態(tài)鏈接庫,而應該寫為:extension=suhosinso而且設置:suhosin.executor.disable_eval = on才可以
摘自 白襯衫 的BLOG