yumで入れたcactiをPHP7に対応させる

php7に入れ替えた後、yumでcacti入れたら動かなかったので
以下を編集して動くようにしました。

修正が必要な部分を探す

grep -rnw /usr/share/cacti/ -e “=& new”
/usr/share/cacti/lib/adodb/adodb-csvlib.inc.php:72: $rs =& new ADORecordSet_array();
/usr/share/cacti/lib/adodb/adodb-csvlib.inc.php:129: $rs =& new ADORecordSet($val=true);
/usr/share/cacti/lib/adodb/adodb-csvlib.inc.php:222: $fld =& new ADOFieldObject();
/usr/share/cacti/lib/adodb/adodb-csvlib.inc.php:250: $rs =& new ADORecordSet_array();
/usr/share/cacti/lib/adodb/adodb-lib.inc.php:537: $recordSet =& new $rsclass(-1,$zthis->fetchMode);
/usr/share/cacti/lib/adodb/adodb-pear.inc.php:111: if (!is_object($obj)) $obj =& new PEAR_Error(‘Unknown Database Driver: ‘.$dsninfo[‘phptype’],-1);
/usr/share/cacti/lib/adodb/adodb-pear.inc.php:157: $obj =& new PEAR_Error(‘Unknown Database Driver: ‘.$dsninfo[‘phptype’],-1);
/usr/share/cacti/lib/adodb/adodb-xmlschema.inc.php:353: $this->indexes[$name] =& new dbIndex( $this, $attributes );
/usr/share/cacti/lib/adodb/adodb-xmlschema.inc.php:365: $this->data =& new dbData( $this, $attributes );
/usr/share/cacti/lib/adodb/adodb.inc.php:866: $rs =& new ADORecordSet_empty();
/usr/share/cacti/lib/adodb/adodb.inc.php:872: $rs =& new $rsclass($this->_queryID,$this->fetchMode);
/usr/share/cacti/lib/adodb/adodb.inc.php:1183: $rs2 =& new $arrayClass();
/usr/share/cacti/lib/adodb/adodb.inc.php:1961: $fld =& new ADOFieldObject();
/usr/share/cacti/lib/adodb/adodb.inc.php:3027: $this->_obj =& new ADOFetchObj();
/usr/share/cacti/lib/adodb/adodb.inc.php:3592: $obj =& new $cls();
/usr/share/cacti/lib/adodb/adodb.inc.php:3667: $perf =& new $class($conn);
/usr/share/cacti/lib/adodb/adodb.inc.php:3687: $dict =& new $class();
/usr/share/cacti/lib/adodb/drivers/adodb-odbc.inc.php:425: $rs =& new ADORecordSet_odbc($qid);

上記ファイルの対象箇所をphp7用に書き換える

find /usr/share/cacti/ -type f | xargs sed -i “s/=& new/= new/g”

とかで一括置換する

その他

  • 困ったらapacheのエラーログとかを見てみよう!

コメント