Home > Cpanel Server, Dedicated Server, PHP, MySQL, Apache > How to Enable PHP function for a one account ?

How to Enable PHP function for a one account ?

IF you disable PHP function in php.ini file and if you want to enable any particular function only one account .Then You can however use suhosin to enable a function for one domain only.

How can you do that ?

After installing suhosin, remove all functions from disable_functions in php.ini and add in php.ini suhosin.executor.func.blacklist = “exec,passthru,shell_exec” and all the functions that you want to disable globally.

After that for each domain in the virtual host section you can add suhosin.executor.func.blacklist again but without the function that you need to enable. And so you will enable that function only for one domain.

Example:

<VirtualHost 127.0.0.1>
………..
………..
<IfModule mod_php4.c>
php_admin_value open_basedir “/usr/lib/php”
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir “/usr/lib/php”
php_admin_value suhosin.executor.func.blacklist = “passthru,shell_exec”
</IfModule>
…….
……
</VirtualHost>

In this example exec has been enabled for the VirtualHost. This way it will be better as you do not neet to modify all the virtual hosts only the ones that you need to enable one or more functions.

Regard’s

Alex P

  1. OE
    June 7th, 2010 at 14:54 | #1

    This wont work if you have suphp as you cant use php_admin_value

    is there a solution to that?

  2. August 3rd, 2010 at 04:27 | #2

    Nice fill someone in on and this fill someone in on helped me alot in my college assignement. Say thank you you on your information.

  3. September 15th, 2010 at 21:22 | #3

    This sounds good if someone can figure out how to make it work with SuPHP. Did anyone figure that out yet?

  4. October 31st, 2010 at 22:54 | #4

    @Jerry
    Hello Jerry,

    In PHP suphp environment you will have to create copy the system php.in under that particular client document root. then search disable_functions option in php.ini file and add php function which you want to disable it for particular account.

    here example

    disable_functions =”shell_exec,system,passthru,exec,popen,proc_close,proc_get_status,proc_nice,
    proc_open,proc_terminate,highlight_file,escapeshellcmd,define_syslog_variables,
    posix_uname,posix_getpwuid,apache_child_terminate,posix_kill,
    posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,escapeshellarg,posix_uname,
    ftp_exec,ftp_connect,ftp_login,ftp_get,ftp_put,ftp_nb_fput,ftp_raw,
    tp_rawlist,ini_alter,ini_restore,inject_code,syslog,openlog,
    define_syslog_variables,apache_setenv,mysql_pconnect “

  5. Newbie_vietnam
    January 19th, 2011 at 10:10 | #5

    Alex P :
    @Jerry
    Hello Jerry,
    In PHP suphp environment you will have to create copy the system php.in under that particular client document root. then search disable_functions option in php.ini file and add php function which you want to disable it for particular account.
    here example

    disable_functions =”shell_exec,system,passthru,exec,popen,proc_close,proc_get_status,proc_nice,
    proc_open,proc_terminate,highlight_file,escapeshellcmd,define_syslog_variables,
    posix_uname,posix_getpwuid,apache_child_terminate,posix_kill,
    posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,escapeshellarg,posix_uname,
    ftp_exec,ftp_connect,ftp_login,ftp_get,ftp_put,ftp_nb_fput,ftp_raw,
    tp_rawlist,ini_alter,ini_restore,inject_code,syslog,openlog,
    define_syslog_variables,apache_setenv,mysql_pconnect “

    but i want to prevent custom php.ini in suphp ( add line suPHP_ConfigPath /usr/local/lib/php.ini in /usr/local/apache/conf/php.conf )
    so use php.ini in client document root to enable function is not imposible

    any solution in suphp ?

  6. August 11th, 2011 at 16:26 | #6

    If you don’t mind verify that you have introduced suhosin in your server. To empower the php method for a lone record suhosin should be commissioned on the server.

  1. September 14th, 2009 at 13:52 | #1
  2. March 6th, 2010 at 22:35 | #2
  3. September 15th, 2010 at 21:40 | #3
  4. October 21st, 2010 at 23:57 | #4
  5. November 4th, 2010 at 03:35 | #5