"proc_open () is disabled for security reasons" - PHP error

proc_open () is disabled for security reasons

Now I have free hosting (Hostinger) - creating a personal site for my use and several others.

I know that I have to remove proc_open from php.ini , but I cannot access it due to my shared hosting plan.

The code surrounding proc_open in my code is as follows. If you need the full code, please let me know. I tried to comment on the details, but it returns errors.

All I want to do is delete it and allow code execution.

 <?php // Initializing if (!isset($ACCOUNTS)) $ACCOUNTS = array(); if (isset($USER) && isset($PASSWORD) && $USER && $PASSWORD) $ACCOUNTS[$USER] = $PASSWORD; if (!isset($HOME_DIRECTORY)) $HOME_DIRECTORY = ''; $IS_CONFIGURED = count($ACCOUNTS) >= 1 ? true : false; // Command execution function execute_command($command) { $descriptors = array( 0 => array('pipe', 'r'), // STDIN 1 => array('pipe', 'w'), // STDOUT 2 => array('pipe', 'w') // STDERR ); $process = proc_open($command . ' 2>&1', $descriptors, $pipes); if (!is_resource($process)) die("Can't execute command."); // Nothing to push to STDIN fclose($pipes[0]); $output = stream_get_contents($pipes[1]); fclose($pipes[1]); $error = stream_get_contents($pipes[2]); fclose($pipes[2]); // All pipes must be closed before "proc_close" $code = proc_close($process); return $output; } 
+4
source share
2 answers

You can try to overwrite default php.ini. I used to work successfully with another host following this step.

  • You create your own php.ini in your web folder. You don't have to have all the value in php.ini, just something you want to rewrite. For example, your php.ini can only have one line like this

     disable_functions = exec,execl,system,passthru,shell_exec,set_time_limit,escapeshellarg,escapeshellcmd,proc_close,ini_alter,proc_open,dl,popen,show_source,posix_getpwuid,getpwuid,posix_geteuid,posix_getegid,posix_getgrgid,open_basedir,safe_mode_include_dir,pcntl_exec,pcntl_fork,putenv,proc_get_status,proc_nice,proc_terminate,pclose,virtual,openlog,popen,pclose,virtual,openlog,escapeshellcmd,escapeshellarg,dl,show_source,symlink,eval,mail 

Remember to remove proc_open from the disable function

  1. Create .htaccess and add this

     <IfModule mod_suphp.c> suPHP_ConfigPath /home/user/public_html </IfModule> 

Remember to change / home / user / public _html in your own way

+1
source

I solved my problem by editing this file vendor-> facade β†’ ignition-> config-> flare.php line 29

 'collect_git_information' => true, <---- Change this value to false 

Laravel 6

PHP 7.3

0
source

Source: https://habr.com/ru/post/1234742/


All Articles