Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Solved Cannot change PHP version on Lamp

    LAMP
    3
    13
    549
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LaurDaniel
      LaurDaniel last edited by

      Hi,
      I'm trying to change the PHP version from 7.4 to 8 like it's written in docs(changing the version in PHP_VERSION file), but after restart, nothing has changed.
      Thanks in advance!

      murgero 1 Reply Last reply Reply Quote 0
      • Topic has been marked as a question  nebulon nebulon 
      • murgero
        murgero App Dev @LaurDaniel last edited by

        @LaurDaniel Make sure you use the full version string "8.0"

        --
        https://urgero.org
        ~ Professional Nerd. Freelance Programmer. ~
        Matrix: @murgero:urgero.org

        1 Reply Last reply Reply Quote 1
        • murgero
          murgero App Dev @LaurDaniel last edited by

          @LaurDaniel Make sure you use the full version string "8.0"

          --
          https://urgero.org
          ~ Professional Nerd. Freelance Programmer. ~
          Matrix: @murgero:urgero.org

          1 Reply Last reply Reply Quote 1
          • Topic has been marked as solved  girish girish 
          • LaurDaniel
            LaurDaniel last edited by

            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"
            "

            girish 1 Reply Last reply Reply Quote 0
            • girish
              girish Staff @LaurDaniel last edited by

              @LaurDaniel remove the quotes around 8.0 . So, just PHP_VERSION=8.0.

              LaurDaniel 1 Reply Last reply Reply Quote 0
              • LaurDaniel
                LaurDaniel @girish last edited by

                @girish I tried that too, without success

                girish 1 Reply Last reply Reply Quote 0
                • girish
                  girish Staff @LaurDaniel last edited by

                  @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
                  
                  LaurDaniel 1 Reply Last reply Reply Quote 0
                  • LaurDaniel
                    LaurDaniel @girish last edited by

                    @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?

                    girish 1 Reply Last reply Reply Quote 0
                    • girish
                      girish Staff @LaurDaniel last edited by

                      @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.

                      LaurDaniel 1 Reply Last reply Reply Quote 0
                      • LaurDaniel
                        LaurDaniel @girish last edited by

                        @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

                        girish 1 Reply Last reply Reply Quote 0
                        • girish
                          girish Staff @LaurDaniel last edited by

                          @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 use php7.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 1 Reply Last reply Reply Quote 0
                          • LaurDaniel
                            LaurDaniel @girish last edited by

                            @girish The thing is that I run laravel 9, so that isn't the problem here. If I run phpinfo, I get that the php version is 8.1.5 but that's not really helping me. What should I do to manage an laravel 9 install?

                            girish 1 Reply Last reply Reply Quote 0
                            • girish
                              girish Staff @LaurDaniel last edited by

                              @LaurDaniel can you give me a small example of how to reproduce this? (as in, PHP code)

                              LaurDaniel 1 Reply Last reply Reply Quote 0
                              • LaurDaniel
                                LaurDaniel @girish last edited by

                                @girish I think this might help https://stackoverflow.com/a/43586197, but I need help to make it working with Cloudron Lamp app

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post
                                Powered by NodeBB