OCSInventory-NG / OCSInventory-Server

Communication server of OCS Inventory
http://www.ocsinventory-ng.org/
GNU General Public License v2.0
344 stars 139 forks source link

Post upgrade from OCS 2.3 to 2.8 getting error 500 #317

Closed TheFiZi closed 3 years ago

TheFiZi commented 3 years ago

It's hard to solve a problem when important details are missing, that why we added this template, to help you and us.

General informations

Operating system : CentOS Linux release 7.9.2009 (Core)

Server informations

Perl version : v5.16.3 Mysql / Mariadb / Percona version : 5.5.68-MariaDB

OCS Inventory informations

Ocs server version : 2.8

Problem's description

Just posting this to save someone else a bunch of time. Plus when I got the error under PHP 7.4 I couldn't find anything. Downgrading to PHP 5.6 provided me a different error where I found this page: https://ask.ocsinventory-ng.org/11927/ocs-version-2-7-update-problem-mysql-ssl-enable

After upgrading to OCS 2.8 I was getting "Error 500" when trying to access the OCS Inventory Admin Page. Checking my Apache logs I found these:

PHP 7.4

[Mon Apr 12 10:40:52.082743 2021] [php7:error] [pid 9201] [client 10.222.133.26:20631] PHP Fatal error:  Uncaught Error: Call to a member function select_db() on null in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php:188\nStack trace:\n#0 /usr/share/ocsinventory-reports/ocsreports/require/header.php(97): dbconnect()\n#1 /usr/share/ocsinventory-reports/ocsreports/index.php(44): require('/usr/share/ocsi...')\n#2 {main}\n  thrown in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 188

PHP 5.6

[Mon Apr 12 11:06:22.832058 2021] [:error] [pid 7213] [client 10.222.133.26:21133] PHP Warning:  mysqli_real_connect() expects parameter 6 to be long, string given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 177
expects parameter 6 to be long

The solution ended up being to edit /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php and add the following:

define("SSL_KEY","");
define("SSL_CERT","");
define("CA_CERT","");
define("SERVER_PORT","3306");
define("ENABLE_SSL","0");

After that I was able to access OCS Inventory again under PHP 5.6 and PHP 7.4.

Dj4ll commented 2 years ago

Dude i litterally created this account to THANK YOU ! Had the exact same issue upgrading from 2.6. to 2.9.2 tried your solution without much conviction and it actually worked. And i can definitly tell you, you saved someone a buch of time! So big thanks again and have a great day !

rubberduck3000 commented 2 years ago

Thank you so much. It did the trick after updating from 2.5 to 2.9.

laststav13 commented 2 years ago

Thank you for this post. OCS Team should have included this one when upgrading from earlier versions of OCS to 2.9.

devalloa commented 2 years ago

Nice Tx

roms2000 commented 1 year ago

Thanks you !