Installing Suhosin
Things to do before getting started and questions you probably have.
1) First off you need to create a phpinfo page on your web server, this is so you can see if Suhosin is installed and working or not.
EG:
http://mysite.com/phpinfo.php
phpinfo();
That�s all it should contain. You should bring it up to make sure it works.
2) Check to make sure that PHP is NOT compiled with --enable-versioning
You will see this in the Configure Command section at the top, make sure you do not see
If it is, the extension will not work. Versioning breaks extensions. You will need to recompile PHP and make sure versioning is turned OFF.
3) This only applies if you are using Zend Optimizer. Make sure you are using at least version 3.2.1 or above of Zend Optimizer. If you are using anything below that there is a known bug in Zend Optimizer that gets caught up in Suhosin while reading zend encoded pages. So be sure to upgrade Optimizer to a more recent release before you install Suhosin to avoid issues.
You can check your version while in shell by doing:
php �v
If you have it installed you�ll see something like:
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
with Zend Extension Manager v1.0.10, Copyright (c) 2003-2006, by Zend Technologies
with Zend Optimizer v3.0.1, Copyright (c) 1998-2006, by Zend Technologies
So this version is old and needs to be upgraded. See
http://www.webhostgear.com/184.html our Zend Optimizer install guide for more details.
Suhosin works fine on cPanel/WHM servers, DirectAdmin, Plesk and any others. As long as the above mentioned items are met then you should be fine.
Installing Suhosin Extension
Download the source file for the Suhosin extension
کد:
cd /usr/local/
wget http://www.hardened-php.net/suhosin/_media/suhosin-0.9.18.tgz
tar -zxvf suhosin-0.9.18.tgz
cd suhosin-0.9.18
phpize
OUTPUT will be something like this:
# phpize
Configuring for:
PHP Api Version: 20020918
Zend Module Api No: 20020429
Zend Extension Api No: 20050606
OUTPUT will be something like this:
Libraries have been installed in:
/usr/local/suhosin-0.9.18/modules
OUTPUT will be something like this:
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20020429/
Make a note of the directory location and confirm it exists and has suhosin.so in it:
ls �lah /usr/local/lib/php/extensions/no-debug-non-zts-20020429/
-rwxr-xr-x 1 root root 334K Mar 19 09:17 suhosin.so*
Now copy suhosin.so to /usr/lib/php/extensions since our php.ini points to that directory and not the one the make install used
cp /usr/local/lib/php/extensions/no-debug-non-zts-20020429/suhosin.so /usr/lib/php/extensions/no-debug-non-zts-20020429
Checking PHP
Now we need to check PHP to ensure suhosin will be added in.
Find where your current PHP.ini is:
Configuration File (php.ini) Path => /usr/local/Zend/etc/php.ini
Edit the php.ini
کد:
nano /usr/local/Zend/etc/php.ini
Step 1) Ensure the include path/extension is set properly.
Search for: extension_dir
You should see something like this:
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
include_path = ".:/usr/lib/php:/usr/local/lib/php:/usr/lib/php/extensions:/usr/lib/php/extensions/no-debug-non-zts-20020429:" ;
extension_dir = /usr/lib/php/extensions/no-debug-non-zts-20020429/ ; directory in which the loadable extensions (modules) reside
Note the exact path is the same as what we wrote down when we did �make install�
If not, you will need to add it or COPY the file to the new location as mentioned above.
Step 2) Add the suhosin.so extension to php.ini
While still in php.ini search for Dynamic Extensions
/Dynamic Extensions
EG you should see:
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
Add this below: