Cant run occ command on php 7.4

Hello,
I was in the process of updating my PHP 7.0 to 7.3, but somehow accidentally updated to 7.4. Smh. Anyway, i updated OC from 10.3 o 10.4 before i realized the php version. I took a look around our OC environment, and it appears everything that i can see works (for now), so i likely wont try and downgrade PHP for the time being.

One issue i saw, was that my environment’s url now has “/index.php/apps/files…” in it…and i would like to remove the index.php inclusion, as it was before i updated both php version and oc version. I tried to following this guide (https://doc.owncloud.org/server/admin_manual/configuration/server/index_php_less_urls.html) but am unable to run the occ command, which results in this error:

MyUser: sudo -u www-data php occ maintenance:update:htaccess
This version of ownCloud is not compatible with PHP 7.4
You are currently running PHP 7.4.6.

Does anyone know how i can work around this and remove the index.php from my url, without running the occ command?

Figured it out. I added the following to the bottom of the root .htaccess file.

#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 /core/templates/403.php
ErrorDocument 404 /core/templates/404.php
<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
  RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
  RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff|ico|jpg|jpeg|json)$
  RewriteCond %{REQUEST_FILENAME} !core/img/favicon.ico$
  RewriteCond %{REQUEST_FILENAME} !/robots.txt
  RewriteCond %{REQUEST_FILENAME} !/remote.php
  RewriteCond %{REQUEST_FILENAME} !/public.php
  RewriteCond %{REQUEST_FILENAME} !/cron.php
  RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php
  RewriteCond %{REQUEST_FILENAME} !/status.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
  RewriteCond %{REQUEST_FILENAME} !/updater/
  RewriteCond %{REQUEST_FILENAME} !/ocs-provider/
  RewriteCond %{REQUEST_FILENAME} !/ocm-provider/
  RewriteCond %{REQUEST_URI} !^/.well-known/(acme-challenge|pki-validation)/.*
  RewriteRule . index.php [PT,E=PATH_INFO:$1]
  RewriteBase /
  <IfModule mod_env.c>
    SetEnv front_controller_active true
    <IfModule mod_dir.c>
      DirectorySlash off
    </IfModule>
  </IfModule>
</IfModule>

Hey,

from what i know you would get the same message in your Web GUI of ownCloud if your server is running PHP 7.4 because ownCloud 10.4 isn’t compatible with PHP 7.4.

I think your web server is still running PHP 7.3 but the default PHP on the command line is already PHP 7.4. Maybe this could bring you some issues if you are running the cron job of ownCloud on command line because this also won’t work with PHP 7.4.

That’s weird though, because if i do “php -v” in the command line, it will show me php 7.4. Not sure how the webserver could run 7.3, but it’s very possible. I know for sure when i was updating php, i typed 7.3, not 7.4.

You’re right about the cron job, i checked it’s status in the admin settings, and it is in fact not running.

So now, im not sure how to fix this yet

1 Like

Fixed, by changing the php version that is used by command line:

$ sudo a2dismod php7.4
$ sudo a2enmod php7.3
$ sudo service apache2 restart
$ sudo update-alternatives --set php /usr/bin/php7.3
1 Like