由于安全原因,已禁用proc_open()
我现在免费托管(Hostinger)-制作一个仅供我使用的个人网站和其他一些网站。
我知道我应该从php.ini中删除proc_open
,但由于我的共享托管计划,我无法访问它。
我的代码中围绕proc_open
的代码如下-如果您需要完整的代码,请告诉我。我试过把部分注释掉,但它会返回错误。
我只想删除它并允许代码正常运行。
<?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;
}
您可以尝试覆盖默认的php.ini。在过去,我曾成功地使用另一个共享主机,请遵循以下步骤
-
您可以在web文件夹中创建自己的php.ini。不需要在php.ini中具有所有值,只需要覆盖一些内容即可。例如,您的php.ini可能只有一行类似于以下
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
记住从禁用功能中删除proc_open
-
创建.htaccess并添加此
<IfModule mod_suphp.c> suPHP_ConfigPath /home/user/public_html </IfModule>
记住使用路径更改/home/user/public_html
我通过编辑这个文件解决了问题供应商->门面->点火->配置->flare.php第29行
'collect_git_information' => true, <---- Change this value to false
Laravel 6
PHP 7.3