Cannot change PHP version on Lamp
-
This is what PHP_VERSION file is containing
"
; Set the desired PHP version in this file
; Restart app for changes to take effect
PHP_VERSION="8.0"
" -
@LaurDaniel remove the quotes around 8.0 . So, just
PHP_VERSION=8.0
. -
@LaurDaniel I feel I am missing something:
- The default version of PHP in a new install in 8.0
- I tried changing PHP_VERSION to 8.1 and restart the app. That worked.
So.. Can you tell me:
- Is this a new install or are you using an old PHP installation where we previously had PHP 7.4 as the default?
- In the Update section of the app, can you check what the Appstore Id is? In the past, we had an old app which was PHP 7.2. Maybe you are using that one? The latest package is
lamp.cloudronapp.php74@2.2.0
My
PHP_VERSION
file looks like this:; Set the desired PHP version in this file ; Restart app for changes to take effect PHP_VERSION=8.1
-
@girish I checked the Appstore Id and it looks like it's the latest, lamp.cloudronapp.php74@2.2.0 and it's last updated 2 weeks ago.
I will try a new installation and maybe that will do it. My question is, when uninstalling an lamp application, I will also delete the database credentials?
-
@LaurDaniel The default install is PHP 8.0 for a while now. Can you post the app logs, so we can try to see why it's resetting to PHP 7.4 ? BTW, how do you know it's PHP 7.4?
And yes, deleting the app will delete the database as well.
-
@girish I know it's 7.4 because I run php -v command in terminal. I tried to download the logs file but I'm getting data only from 23.08 to 28.08.
I see that I have an error in the logs and I'll try to paste it here directly from logs terminal. I also have to mention that I'm trying to get working an Laravel 9 application.
Here is the error from my logs:
Sep 01 15:52:40 [Thu Sep 01 12:52:40.022063 2022] [php:error] [pid 50] [client 172.18.0.1:43456] PHP Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/data/vendor/laravel/framework/src/Illuminate/Collections/Collection.php:1354\nStack trace:\n#0 /app/data/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()\n#1 /app/data/vendor/composer/ClassLoader.php(571): include('...')\n#2 /app/data/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()\n#3 /app/data/vendor/laravel/framework/src/Illuminate/Collections/helpers.php(15): Composer\Autoload\ClassLoader->loadClass()\n#4 /app/data/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(89): collect()\n#5 /app/data/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(78): Illuminate\Foundation\PackageManifest->config()\n#6 /app/data/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php(26): Illuminate\Foundation\PackageManifest->aliases()\n#7 /app/data/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(230): Illuminate\Foundation\Bootstrap\RegisterFacades->bootstrap()\n#8 /app/data/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(152): Illuminate\Foundation\Application->bootstrapWith()\n#9 /app/data/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(136): Illuminate\Foundation\Http\Kernel->bootstrap()\n#10 /app/data/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()\n#11 /app/data/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle()\n#12 {main} in /app/data/vendor/laravel/framework/src/Illuminate/Collections/Collection.php on line 11 -
@LaurDaniel The CLI
php
is always 7.4. This is because of a packaging quirk . On ubuntu, the php is a meta symlink and this is not possible to change at run time easily when switching PHP versions. In your scripts, instead usephp7.4
,php8.0
,php8.1
binaries instead.The apache PHP module is the correct way to test if the change worked. Can you check the output of
phpinfo
instead?From your error, it seems you are using an old laravel with newer PHP. See https://laracasts.com/discuss/channels/laravel/php-fatal-error-during-inheritance-of-arrayaccess-uncaught-errorexception-return-type-of-illuminatesupportcollectionoffsetexistskey and https://stackoverflow.com/questions/70245146/php-deprecated-issue-when-running-artisan-command . I am not an expert on PHP/laravel mismatch, but it looks like that is the root cause here.
-
@LaurDaniel can you give me a small example of how to reproduce this? (as in, PHP code)
-
@girish I think this might help https://stackoverflow.com/a/43586197, but I need help to make it working with Cloudron Lamp app