SuHosin Logo

SuHosin + WordPress + CPanel

I recently did some tweaks and ran across a very interesting issue when hardening PHP using SuHosin. All the WordPress sites stopped working. It seems WordPress needs 256MB in order to work, and by default SuHosin does not specify an upper memory limit.

To resolve this issue you will need to edit one file, and change a setting at the root level in CPanel.

Logon via SSH to your server and edit php.ini. Any changes made will stay in place if you upgrade or rebuild Apache. The php.ini is located in /usr/local/lib

nano -w /usr/local/lib/php.ini

Add the following at the end of the file
[SuHosin]
; Logging Configuration
suhosin.log.syslog.facility = 9
suhosin.log.use-x-forwarded-for = Off

; Executor Options
suhosin.executor.max_depth = 0
suhosin.executor.include.max_traversal = 4
suhosin.executor.disable_emodifier = Off
suhosin.executor.allow_symlink = Off

; Misc Options
suhosin.simulation = Off
suhosin.apc_bug_workaround = Off
suhosin.sql.bailout_on_error = Off
suhosin.multiheader = Off
suhosin.mail.protect = 1
suhosin.memory_limit = 256M

; Transparent Encryption Options
suhosin.session.encrypt = On
suhosin.session.cryptua = On
suhosin.session.cryptdocroot = On
suhosin.session.cryptraddr = 0
suhosin.cookie.encrypt = On
suhosin.cookie.cryptua = On
suhosin.cookie.cryptraddr = 0

; Filtering Options
suhosin.filter.action = 406
suhosin.cookie.max_array_depth = 100
suhosin.cookie.max_array_index_length = 64
suhosin.cookie.max_name_length = 64
suhosin.cookie.max_totalname_length = 256
suhosin.cookie.max_value_length = 10000
suhosin.cookie.max_vars = 100
suhosin.cookie.disallow_nul = On
suhosin.get.max_array_depth = 50
suhosin.get.max_array_index_length = 64
suhosin.get.max_name_length = 64
suhosin.get.max_totalname_length = 256
suhosin.get.max_value_length = 512
suhosin.get.max_vars = 100
suhosin.get.disallow_nul = On
suhosin.post.max_array_depth = 100
suhosin.post.max_array_index_length = 64
suhosin.post.max_totalname_length = 256
suhosin.post.max_value_length = 65000
suhosin.post.max_vars = 200
suhosin.post.disallow_nul = On
suhosin.request.max_array_depth = 100
suhosin.request.max_array_index_length = 64
suhosin.request.max_totalname_length = 256
suhosin.request.max_value_length = 65000
suhosin.request.max_vars = 200
suhosin.request.max_varname_length = 64
suhosin.request.disallow_nul = On
suhosin.upload.max_uploads = 25
suhosin.upload.disallow_elf = On
suhosin.upload.disallow_binary = Off
suhosin.upload.remove_binary = Off
suhosin.session.max_id_length = 128

The important line is suhosin.memory_limit = 256M. WordPress is a bit of a hog for memory. For more information on the remaining variables, visit Hardened-PHP

The second part is adjusting the memory variable for the regular PHP settings. This is done through WHM. Go to Service Configuration -> PHP Configuration Editor and near the middle you will see a memory_limit setting, put in 256M. Scroll to bottom and save your settings.

Restart HTTP, your site should now be showing


Posted

in

,

by