Installing Apache2 web-server while installing OpenSuSE LEAP 15.1 is not such a good idea. I think I did this for the first time last week, because I can't remember having these problems when adding the mod_php7 module before.
The case: Installing OpenSuSE LEAP 15.1 - server with Apache2 web-server
I must admit that I can't remember having problems adding modules like mod_php before. Therefore I was stuck with googling "my ass off"(trying to find the right search-phrase to find some article with the same problem).
After the installation of th OS and Apache I went into Yast to find the mod_php7, and as far as I can remember it was installed, so I thought that everything was ok, so I added my "index.php" in the DirectoryIndex, httpd.conf-file
# List of resources to look for when the client requests a directory DirectoryIndex index.html index.php
But the server did not react the way it should: It started to download the file instead of executing it.
I'm not sure in which order I did this in but there are two things that has to be done(if not allready):
1. Add the module using a2enmod(Apache2 and adding modules)(yeah, that was a note to myself some time ago):
a2enmod php7
2. Add the application type to the config files(for me I found the AddType in mod_mime-defaults.conf). Here I found an article, and had I read the whole thread from serverfault.com I would of found my answer a lot quicker..maybe, but I found it here in an Ubuntu-forum):
<IfModule mod_php7.c> AddType application/x-httpd-php .php </IfModule>
And yes! That was it. These two points are important to remember. Happy face
I have a theory that you don't have to do this manually when you install the Apache web-server and php after the installation of the OS...But I'm not sure.