How to update PHP with Apache

Discussion in 'HOWTO-Related Questions' started by fernandoch, Mar 4, 2021.

  1. fernandoch

    fernandoch Member HowtoForge Supporter

    Hello,
    Do you have any guide to update PHP from let's say version 7.3 to version 7.4 without breaking Apache?
    Thanks
     
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

  3. fernandoch

    fernandoch Member HowtoForge Supporter

    Thanks but not very clear for me
    This is what I did.
    apt install $(apt list --installed | grep php7.3- | cut -d '/' -f1 | sed -e 's/7.3/7.4/g')
    So I installed all these packages
    php7.4-apcu
    php7.4-apcu-bc
    php7.4-cli
    php7.4-common
    php7.4-curl
    php7.4-gd
    php7.4-imagick
    php7.4-imap
    php7.4-intl
    php7.4-json
    php7.4-mbstring
    php7.4-mysql
    php7.4-opcache
    php7.4-readline
    php7.4-xml
    php7.4-zip
    And then this to enable php7.4 module for apache, but it did not work.
    Code:
    root@ns32XXX22:/var/www# a2dismod php7.3
    Module php7.3 disabled.
    To activate the new configuration, you need to run:
      service apache2 restart
    root@ns32XXX22:/var/www# a2enmod php7.4
    Considering dependency mpm_prefork for php7.4:
    Considering conflict mpm_event for mpm_prefork:
    Considering conflict mpm_worker for mpm_prefork:
    Module mpm_prefork already enabled
    Considering conflict php5 for php7.4:
    Enabling module php7.4.
    To activate the new configuration, you need to run:
      service apache2 restart
    root@ns32XXX22:/var/www# service apache2 restart
    Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
    root@ns32XXX22:/var/www# a2enmod php7.3
    Considering dependency mpm_prefork for php7.3:
    Considering conflict mpm_event for mpm_prefork:
    Considering conflict mpm_worker for mpm_prefork:
    Module mpm_prefork already enabled
    Considering conflict php5 for php7.3:
    Enabling module php7.3.
    To activate the new configuration, you need to run:
      service apache2 restart
    root@ns32XXX22:/var/www# service apache2 restart
    I had to enable again php7.3 for apache.
    What am I doing wrong?
     
  4. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    You are trying to change the default PHP version, but you should not. I suspect you are using ISPConfig?
    Add the versions as additional versions and select the version you want to use in your web settings. It is exactly described in the guide how to do this.
     
  5. fernandoch

    fernandoch Member HowtoForge Supporter

    OK, I fixed it, I was missing libapache2-mod-php7.4
    Once installed it worked for php7.4
     
    ahrasis likes this.
  6. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    No, you should not do this. Mod-php should not be used, and you shouldn't change the default version.
     
  7. fernandoch

    fernandoch Member HowtoForge Supporter

    What do you mean by changing the default version?
    I added a ppa with more php versions.
    And what do you mean by Mod-php should not be used? Please can you clarify?
     
  8. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Are you using ISPConfig?
     
  9. fernandoch

    fernandoch Member HowtoForge Supporter

    No, I am not.
     
  10. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Alright - I assumed you did, because most of the users on this forum do, especially the HowToForge supporters :)

    In that case, switch from mod-php to php-fpm with
    Code:
    a2dismod mpm_prefork php7.4
    a2enmod mpm_event php-7.4fpm
     
  11. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Note php#.#-fpm uses a2enconf rather than a2enmod
     
    Last edited: Mar 6, 2021
    Th0m likes this.
  12. fernandoch

    fernandoch Member HowtoForge Supporter

  13. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Performance (eg. supporting http2) and security.
     

Share This Page