opennetadmin / ona

OpenNetAdmin IP Address Management (IPAM) system
opennetadmin.com
GNU General Public License v2.0
136 stars 35 forks source link

Opennetadmin and PHP7.0 #118

Closed tuXitbe closed 6 years ago

tuXitbe commented 6 years ago

Hi,

Is there any way to get Opennetadmin to work under HP 7.0? I recently upgraded my debian to stretch and this contains only php 7.0.

Thanks in advance, Erland.

mattpascoe commented 6 years ago

Yes the latest version should work fine with php 7.x.. I just finalized the latest v17.12.22 release which should work fine on the latest debian systems (it was tested on ubuntu 16.04).

Is this the version you are running?

Thanks

tuXitbe commented 6 years ago

Hi Matt,

Thanks for the speedy answer.

I was running version 13.03.01 under debian jessie. After upgrade of the server Opennetadmin threw the white screen of death. Errors included the mysql_pconnect error. After downloading version 17.12.22 and following your upgrade procedure i still got the white screen.

After changing db_type from mysqlt to mysqli in /opt/ona/local/config/database_settings.inc.php i was able to start the upgrade procedure "/?runinstaller=y" but i get errors both on screen and in the error-log of apache. On screen:

[DEFAULT/localhost] Failed to select DB 'ona_ons'.
Access denied for user 'ona_sys'@'localhost' (using password: NO)
 There was a fatal error. Upgrade may be incomplete. Fix the issue and try again.

In logfile:

[Thu Dec 28 10:39:56.817972 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Notice:  Undefined index: APACHE_RUN_USER in /opt/ona/install/install.php on line 48, referer: http://dnsadmin.tuxit.eu/?runinstaller=y
[Thu Dec 28 10:39:56.818111 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Notice:  Undefined index: APACHE_RUN_USER in /opt/ona/install/install.php on line 48, referer: http://dnsadmin.tuxit.eu/?runinstaller=y
[Thu Dec 28 10:39:56.820339 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Notice:  Undefined variable: mainstyle in /opt/ona/install/install.php on line 156, referer: http://dnsadmin.tuxit.eu/?runinstaller=y
[Thu Dec 28 10:39:56.820433 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Notice:  Undefined variable: admin_passwd in /opt/ona/install/install.php on line 179, referer: http://dnsadmin.tuxit.eu/?runinstaller=y
[Thu Dec 28 10:39:56.820463 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Notice:  Undefined variable: sys_passwd in /opt/ona/install/install.php on line 185, referer: http://dnsadmin.tuxit.eu/?runinstaller=y
[Thu Dec 28 10:39:56.821117 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Notice:  Undefined index: context_name in /opt/ona/www/include/functions_general.inc.php on line 148, referer: http://dnsadmin.tuxit.eu/?runinstaller=y
[Thu Dec 28 10:39:56.822137 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Notice:  Undefined variable: database_host in /opt/ona/install/install.php on line 235, referer: http://dnsadmin.tuxit.eu/?runinstaller=y
[Thu Dec 28 10:39:56.822220 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Notice:  Undefined variable: admin_login in /opt/ona/install/install.php on line 235, referer: http://dnsadmin.tuxit.eu/?runinstaller=y
[Thu Dec 28 10:39:56.822249 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Notice:  Undefined variable: admin_passwd in /opt/ona/install/install.php on line 235, referer: http://dnsadmin.tuxit.eu/?runinstaller=y
[Thu Dec 28 10:39:56.823122 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Warning:  mysqli_real_connect(): (HY000/1045): Access denied for user 'ona_sys'@'localhost' (using password: NO) in /opt/ona/www/include/adodb5/drivers/adodb-mysqli.inc.php on line 124, referer: http://dnsadmin.tuxit.eu/?runinstaller=y
[Thu Dec 28 10:39:56.823546 2017] [:error] [pid 23362] [client 192.168.19.2:46698] PHP Notice:  Undefined variable: db_context in /opt/ona/install/install.php on line 351, referer: http://dnsadmin.tuxit.eu/?runinstaller=y

File: database_settings.inc.php:

<?php

$ona_contexts=array (
  'DEFAULT' => 
  array (
    'databases' => 
    array (
      0 => 
      array (
        'db_type' => 'mysqli',
        'db_host' => 'localhost',
        'db_login' => 'ona_sys',
        'db_passwd' => 'xxxxxxxxx',
        'db_database' => 'ona_ons',
        'db_debug' => false,
      ),
    ),
    'description' => 'Default data context',
    'context_color' => '#D3DBFF',
  ),
);

?>
mattpascoe commented 6 years ago

Good call on the mysqlt to mysqli change in the config file.. looks like I need to make words about that in the upgrade process.

So the next part is not quite clear to me what is going on. The PHP notice lines in the log are not an issue and can be ignored. The issue seems to be the PHP warning line about the access denied.

Specifically the strange part is it says "using password: NO".. This is weird because I assume you have a password set in the database_settings file. That simply gets passed in and used.

I guess at this point I'd start with trying to do a connection to mysql directly to double check that it works.. so something like mysql -u ona_sys -p ona_ons.. then provide your password.. If that works then there is something funky for sure on the ONA side. If that does not work then we'll have to dig into mysql some more.

tuXitbe commented 6 years ago

Hi MAtt,

Of course I tried local access to the mysql database using the credentials as entered in database_settings.inc.php.

Before trying to upgrade this version, I tried installing a fresh version with a fresh database, and this did not succeed either. If wanted i can try a fresh install again, reporting back to you what happens.

Tia, Erland.

mattpascoe commented 6 years ago

ok I think the best thing for me at this point is to just get a debian VM and see if I can recreate what you have. I'll give that a go and let you know!

Thanks again for the feedback.

mattpascoe commented 6 years ago

@tuXitbe I think I have the issues resolved. If you could test things out again I'd appreciate it. Please use the develop branch. If that works I'll merge it in to master.

I did do some testing on a Debian 9 system. What I did find however was that a fresh install required me to run the cli based installer. The reason for this is that by default Miradb on debian uses sockets for its authentication. This means that running the installer as root will work fine but trying to do it through the web interface does a connection to 'localhost' which does not work by default. The GUI will then work for upgrades etc since it uses the user created by ONA.

If you are so inclined you can set your system to allow the GUI install based on info here: https://stackoverflow.com/questions/28068155/access-denied-for-user-rootlocalhost-using-password-yes-after-new-instal (I did not try any of this)

Thanks again for your help and feedback.

tuXitbe commented 6 years ago

Hi Mat,

Success! Thanks. Now the next chalenge, getting it to work under nginx.

Thanks for the smooth support!

tuXitbe commented 6 years ago

Hi Matt,

Just to let you know, my setup using mariadb(local), nginx with php7.0-fpm running on debian stretch (9) works like a charm. ONA version 18.1.1.

Kind regards, Erland.

mattpascoe commented 6 years ago

@tuXitbe Awesome! Thanks for the feedback.. it is great to hear how people are using ONA. If you dont mind can you post your nginx config? I'd like to turn that in to a wiki page here on github.

tuXitbe commented 6 years ago

Of course, no problem:

server {
        listen 80; 
        listen [::]:80; 
        server_name ona.domain.ext dnsadmin.domain.ext; 
        root /opt/ona/www; 

        access_log /var/log/nginx/ona.access.log; 
        error_log  /var/log/nginx/ona.error.log info; 

        index index.php; 

        location ~ \.php$ { 
                include fastcgi_params; 
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
                fastcgi_intercept_errors on; 
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; 

        } 
}