BartekSz95 / phpvirtualbox

A web interface to manage and access Virtualbox machines.
Other
55 stars 15 forks source link

HTTP error: 500 Internal Server Error #6

Closed band-rk closed 1 year ago

band-rk commented 1 year ago

Error 500 appeared after installation before login 1 virtualbox 7.0.4

BartekSz95 commented 1 year ago

Something wrong is with your VirtualBox installation, not with phpVirtualBox.

Please, read wiki, Setting up VirtualBox section: https://github.com/phpvirtualbox/phpvirtualbox/wiki#setting-up-virtualbox

If not, read details, maybe you don't have installed php-xml or other required PHP plugin.

band-rk commented 1 year ago

The virtualbox work properly. Fiv VMs are work. vboxweb package was install, configure and running. phpvirtualbox ver 5.2 was installed for the purpose of testing (worked! but work incorrect). After installing phpvirtualbox ver 7.0 the error abowe was apper.

BartekSz95 commented 1 year ago

I'm using this version of phpVirtualBox with VBox 7.0 on my dedicated server and works fine. You don't post details, so what can I know what you have wrong on your configuration? This isn't problem with phpVirtualBox, but with configs or server settings. Lots things changes between 5.2 and 7.0. If you only copied-pasted to existed version of phpVBox or you have old config, this can cause the problem. But like I said before, all informations is on Details tab.

dirk-cgn commented 1 year ago

I had the same issue as @band-rk, so I looked in the error log:

PHP Fatal error: Uncaught TypeError: Return value of VBox_Collection::current() must be an instance of mixed, instance of IGuestOSType returned in /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/lib/vboxServiceWrappers.php:156\nStack trace:\n#0 /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/lib/vboxServiceWrappers.php(173): VBox_Collection->current()\n#1 /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/lib/vboxconnector.php(3170): VBox_Collection->valid()\n#2 /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/lib/vboxconnector.php(952): vboxconnector->remote_vboxGetGuestOSTypes()\n#3 /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/api.php(316): vboxconnector->__call()\n#4 {main}\n thrown in /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/lib/vboxServiceWrappers.php on line 156

I tried fixing it by changing line 156 in phpvirtualbox-7.0-rc1/endpoints/lib/vboxServiceWrappers.php:

    #[\ReturnTypeWillChange]
    public function current()
    {
        return current($this->_objects);
    }

Previous this method returned : mixed, but this didn't work with my PHP 7.4. Using this change phpVirtualBox works with VBox 7.0(.4) on my Debian machine.

Hope this helps.

BartekSz95 commented 1 year ago

@dirk-cgn

I had the same issue as @band-rk, so I looked in the error log:

PHP Fatal error: Uncaught TypeError: Return value of VBox_Collection::current() must be an instance of mixed, instance of IGuestOSType returned in /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/lib/vboxServiceWrappers.php:156\nStack trace:\n#0 /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/lib/vboxServiceWrappers.php(173): VBox_Collection->current()\n#1 /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/lib/vboxconnector.php(3170): VBox_Collection->valid()\n#2 /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/lib/vboxconnector.php(952): vboxconnector->remote_vboxGetGuestOSTypes()\n#3 /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/api.php(316): vboxconnector->__call()\n#4 {main}\n thrown in /opt/vbox/phpvirtualbox-7.0-rc1/endpoints/lib/vboxServiceWrappers.php on line 156

I tried fixing it by changing line 156 in phpvirtualbox-7.0-rc1/endpoints/lib/vboxServiceWrappers.php:

    #[\ReturnTypeWillChange]
    public function current()
    {
        return current($this->_objects);
    }

Previous this method returned : mixed, but this didn't work with my PHP 7.4. Using this change phpVirtualBox works with VBox 7.0(.4) on my Debian machine.

Hope this helps.

I can't remove this line, because this one will break compatibility with PHP8.

My version is for PHP8.0, 8.1 and 8.2. I can't support 7.4, because PHP authors changed a lot into PHP8. Problem is with PHP7.4 which is officially unsupported by developers.

There is a list of supported PHP versions: https://www.php.net/supported-versions.php

Sorry, but I can't create phpVirtualBox for every PHP versions. Only way is upgrading PHP to 8.1 or 8.2. If your server is based on Debian or Ubuntu, you can use this packages for PHP8.2: https://deb.sury.org/

There is tutorial: https://php.watch/articles/install-php82-ubuntu-debian

dirk-cgn commented 1 year ago

@BartekSz95 thanks for the extensive comment and the links to the PHP versions. I've not coded in PHP for a few years now, and I am really behind the current versions, so that is very helpful. I found your fork when looking for a version of phpvirtualbox running with Vbox 7, and unfortunately I didn't see any notice that it is for PHP 8.0+ only. Anyway, I got it to work for me thanks to your repo, so many thanks for that! And maybe my hint will help others which are trying to get it to run with an older version of PHP. I can completely understand that you're only supporting current versions.

So thanks for the repo and your good work!

BartekSz95 commented 1 year ago

@dirk-cgn Yes, I need to put information about supported PHP versions to README.md file. I glad that everything works after PHP update to current versions 🙂 Thanks for good words!