¿How to run occ on Ionos shared host with ssh/ PHP 8.1?

Hi, I mainly use the Web Interface for maintaining NextCloud. For some tasks, the OCC Web app was useful/necessary. However, on modern installations (I’m at Hub 4, 26.0.2) OCC Web is incompatible.
I have ssh access to my shared web hosting, with PHP 8.1.

However, trying e.g.

php8.1 occ -h

results in:

Content-type: text/html; charset=UTF-8

An unhandled exception has been thrown:
TypeError: OC\AppFramework\Http\Request::getScriptName(): Return value must be of type string, null returned in /homepages/11/c76155488/htdocs/nextcloud/lib/private/AppFramework/Http/Request.php:774
Stack trace:
#0 /homepages/11/c76155488/htdocs/nextcloud/lib/base.php(169): OC\AppFramework\Http\Request->getScriptName()
#1 /homepages/11/c76155488/htdocs/nextcloud/lib/base.php(606): OC::initPaths()
#2 /homepages/11/c76155488/htdocs/nextcloud/lib/base.php(1167): OC::init()
#3 /homepages/11/c76155488/htdocs/nextcloud/console.php(48): require_once('/homepages/11/d...')
#4 /homepages/11/c76155488/htdocs/nextcloud/occ(11): require_once('/homepages/11/d...')

¿Any idea on how to get occ running?

Maybe this can work

cd /var/www/nextcloud
sudo -u www-data php8.1 ./occ help

Remember, replace www-data with the user that owns your Nextcloud

@Robert_Winkler It’s the same with me. Neither occ nor cron.php are working properly

While logging in at ssh you are running as the same user like the web-user. So, no need for changing.

I’ve found the solution. Just use:

php8.1-cli ./occ [+ COMMAND]

1 Like

Excellent! It seems to work :wink:.