why change site php ver not working?

Discussion in 'General' started by skysky, Nov 4, 2024 at 1:06 PM.

  1. skysky

    skysky Member

    Hi
    I have a site that I changed the php ver, but somehow it is not working. no matter what php ver I picked, it always shows the default ver 8.1
    I used to work. How to troubleshoot this issue?

    thanks,
     

    Attached Files:

  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Where does it show that? The only way to reliably test this is to add a php file with phpinfo(); command inside into a website. You can e.g. not see the PHP version in the website vhost file.
     
    ahrasis likes this.
  3. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    if you're logging in as an ssh user and expecting to see the cli using the same php version as the website's set to, it doesn't work like that..

    the cli always uses the system default php. you can use the full path eg /usr/bin/php8.3 to specify a different version..
    any additional php versions also need to be included in your jailkit if used.
    if you're using a websites own ssh user login and want to use just the command 'php' to use eg /usr/bin/php8.3 then set it as an alias in that users ~/.bashrc file
     
    ahrasis likes this.
  4. skysky

    skysky Member

    Yes, That's exactly how I tested. But somehow it always shows ver 8.1

    I don't know how to troubleshoot.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Check the apache or nginx sites-available directory to see if the vhost file of that site has a .err file ending. Also, did you do this change as admin user in ISPConfig? If not, it might be that the client protection is on which limits such changes by the client and allows the admin user only to change the PHP version.
     
  6. skysky

    skysky Member

    I found out the reason. there is such code in the vhost file setting the php ver to 8.1, after changing the ver number in codes, it works now. thanks.

    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # Adjust the PHP version if necessary
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
     
  7. remkoh

    remkoh Active Member

    This reases all kinds of questions o_O
    What OS and which ISPC version are you running?

    Default PHP config in vhost file on Ubuntu is:
    Code:
    location ~ \.php$ {
        try_files /<random>.htm @php;
    }
    
    location @php {
        try_files $uri @redirect;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php/<web id>.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
    }
    
    which makes PHP run the version you have set in ISPC panel and runs as website user.
     
  8. skysky

    skysky Member

    I am running Ubuntu 22.04.4 LTS
     
  9. remkoh

    remkoh Active Member

    Above config was taken from Ubuntu 24.04.1 LTS. Your version shouldn't be much different.

    Did you set your PHP vhost config as Nginx directive in the Options tab of your website on your ISPC panel?
    Then above config gets overwritten in the vhost file.
    Otherwise I can't explain your completely different config.
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    That's not from ISPConfig. So it seems you manually inserted that code, which of course, must disable PHP version changing via ISPConfig
     
  11. Lolamoni22

    Lolamoni22 New Member

    Glad you figured it out! Changing the version often solves compatibility issues.
     
  12. remkoh

    remkoh Active Member

    He didn't figure it out yet.
    The given code isn't default ISPC code.
    Somewhere that gets overwritten by the given faulty code, probably where I mentioned.

    And besides that, when you're using ISPC you should NEVER manually alter vhost config files.
    The next time somehing about the website is changed in the ISPC panel then the vhost config file is rewritten, putting the faulty code back in place.
     

Share This Page