Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Upgrade from php5 to php7 issue in apache

  1. #1

    Default Upgrade from php5 to php7 issue in apache

    One application forced me to upgrade from php5 to php7. Now when I go to a local website it tries to open the php file instead of running the file which is simply index.php.

    After some investigating I found out that it tried open the file like this:
    Code:
    http://www.domain.local/
    however when accessing it like this:
    Code:
    http://www.domain.local/index.php
    it actually runs the file. In php5 it behaved correctly.

    Also, I notices this:

    Code:
    <IfModule mod_php7.c>
           <FilesMatch "\.ph(p[345]?|tml)$">
               SetHandler application/x-httpd-php
           </FilesMatch>
           <FilesMatch "\.php[345]?s$">
               SetHandler application/x-httpd-php-source
           </FilesMatch>
            DirectoryIndex index.php4
            DirectoryIndex index.php5
            DirectoryIndex index.php
    </IfModule>
    and I was wondering if it should be like this:

    Code:
    <IfModule mod_php7.c>
           <FilesMatch "\.ph(p[3457]?|tml)$">
               SetHandler application/x-httpd-php
           </FilesMatch>
           <FilesMatch "\.php[3457]?s$">
               SetHandler application/x-httpd-php-source
           </FilesMatch>
            DirectoryIndex index.php4
            DirectoryIndex index.php5
            DirectoryIndex index.php7
            DirectoryIndex index.php
    </IfModule>

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,004

    Default Re: Upgrade from php5 to php7 issue in apache

    Can you please confirm that the "it" you are talking about is Apache2?
    And that the configuration parts you show are somewhere in the Apache 2 configuration files on the Apache server? And then please name that file!
    Henk van Velden

  3. #3

    Default Re: Upgrade from php5 to php7 issue in apache

    Quote Originally Posted by hcvv View Post
    Can you please confirm that the "it" you are talking about is Apache2?
    apache version 2.4.

    Of coarse they are from my setup that worked with php5 but now not php7. The version of apache has not changed from 2.4 but perhaps changed by some revision number that I didn't notice.

    the files is
    Code:
    /etc/apache2/conf.d/php7.conf
    .

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,004

    Default Re: Upgrade from php5 to php7 issue in apache

    Talking about "it" can be very confusing. I have seen cases here where people thought that the browser/client is responsible for processing the PHP and happily talked about "it" not doing it. Took some time before we found out that his "it" was Firefox where we thought "it" was Apache. The lesson is that one never can be too precise in describing computer problems.

    What you think should be changed in /etc/apache2/conf.d/php7.conf are only suffixes of files that should be processed by PHP7 (you add the suffix php7 to the range). But as you use a file which ends in the suffix .php, it falls in that category already.

    What you tell is that when having index.php in the URL it works as expected.
    When omitting the file name, it falls back to directory indexing, but the DirectoryIndex statements tell it to use one of the files named there instead when available. Because index.php is there (I hope there are no other files there?) it will then serve index.php instead of doing directory indexing. But then it forgets to process it through php. Which worked in the PHP5 case.
    Henk van Velden

  5. #5
    Join Date
    Oct 2008
    Location
    Glasgow, Scotland
    Posts
    1,131

    Default Re: Upgrade from php5 to php7 issue in apache

    Quote Originally Posted by Reg_gie View Post
    apache version 2.4.

    Of coarse they are from my setup that worked with php5 but now not php7. The version of apache has not changed from 2.4 but perhaps changed by some revision number that I didn't notice.

    the files is
    Code:
    /etc/apache2/conf.d/php7.conf
    .
    Perhaps php7.conf is not included in your www.domain.local.conf file?
    If this is a VirtualHost the file will probably either exist in /apache2/vhosts.d or there will be an entry in ip-based_vhosts.conf.
    there is normally something like:
    Code:
    DocumentRoot /srv/www/vhosts.d/domain.local
    ...
     Include /etc/apache2/conf.d/*.conf
    But you might have a list with php5.conf included.

    Anyway please show your active server configuration files.

    You would only need separate index.php[457] entries for DirectoryIndex if you actually had page files with those names. I just have index.html and assign .html to be parsed by the PHP module.
    ~Thank you for sharing an interesting problem.
    --
    slàinte mhath,
    rayH

  6. #6

    Default Re: Upgrade from php5 to php7 issue in apache

    Fixed (for now, hopefully it stays) but I can't say I know the exact reason.

    I added a new PHP module, php7-macros in this case, and when it restarted it worked correctly. I did a visual compare of the before and after of the apache configuration files (using meld and comparing against my nightly backups) and it seems to have re-ordered the loading of the apache modules. Maybe there was just some configuration change that didn't happen when it was supposed to and that adding of the php module caused it to correct itself or maybe php had an issue that was fixed when the module was added. One of those is my best guess but I don't really know for sure.

  7. #7
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,004

    Default Re: Upgrade from php5 to php7 issue in apache

    Nice it works now, but a bit unsatisfactory.
    Henk van Velden

  8. #8

    Default Re: Upgrade from php5 to php7 issue in apache

    Quote Originally Posted by hcvv View Post
    Nice it works now, but a bit unsatisfactory.
    My sentiments exactly.

  9. #9

    Default Re: Upgrade from php5 to php7 issue in apache

    So... I had to install a couple of more php7 modules and once I did the problem returned but this time it doesn't recognise PHP at all and even with http://domain/index.php it opens up a save box instead of executing PHP. Uhg!

  10. #10
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,806
    Blog Entries
    14

    Default Re: Upgrade from php5 to php7 issue in apache

    You need to enable php7 for apache2. Add it through YaST or through
    Code:
    sudo a2enmod php7 && sudo systemctl restart apache2.service
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •