PHP on APACHE not work

Estou usando OpenSuse 13.1 and KDE

I did the installation of Apache and PHP
I created the file /srv/www/htdocs/index.html and /srv/www/htdocs/info.php

When I use the address


  http://localhost/index.html 

firefox shows the index.html page that was created before

But if I put the address

http://localhost/info.php 

firefox asks if I want to download this file

And nothing happens if I choose run with PHP instead do a donwnload.

The same happens when I call a PHP program within a HTML.

Please, what should I do so that PHP works on Apache?

Make sure the package: apache2-mod_php5 is installed.

rpm -q apache2-mod_php5
apache2-mod_php5-5.5.14-233.1.x86_64
(Your version will be different, I use a repository version - don’t worry about that)

If you’ve installed that package and php5 is not working properly, try issuing: a2enmod php5

Then restart Apache with: systemctl restart apache2

I have same issue. I can’t see any solution here. Is there any howto for debugging? I have made clean install 13.1. Apache is working fine with html. mod_php5.so is loaded 7 times, one by root, others by wwwrun

A few things you can look at:
a2enmod -l

Should list php5 in it.

Run:
curl -i http://your.server.ip/document.php

Copy paste the output and wrap it in CODE tags ( # in the toolbar )

If .php is being downloaded it would usually indicate that php5.conf is not being read properly and sethandler for .php files isn’t thus being properly set as application/x-httpd-php, we can see this from the curl command.

php5 is listed in a2enmod -l

Result from curl

                                                                                                             
HTTP/1.1 200 OK                                                                                                                                                                    
Date: Mon, 02 Feb 2015 10:23:28 GMT                                                                                                                                                
Server: Apache/2.4.6 (Linux/SUSE)                                                                                                                                                  
Last-Modified: Sat, 31 Jan 2015 21:42:41 GMT                                                                                                                                       
ETag: "13-50df999bf75ff"                                                                                                                                                           
Accept-Ranges: bytes                                                                                                                                                               
Content-Length: 19                                                                                                                                                                 
Content-Type: application/x-php                                                                                                                                                    
                                                                                                                                                                                   
<?php                                                                                                                                                                              
phpinfo();                                   

Please post the output of (code tag it): zypper se -si apache2

Have you edited any of the configuration files by hand? For some reason php isn’t being parsed by the module at all.

**zypper se -si apache2 **output:


S | Name             | Type    | Version      | Arch   | Repository          
--+------------------+---------+--------------+--------+---------------------
i | apache2          | package | 2.4.6-6.41.1 | i586   | openSUSE-13.1-Update
i | apache2-doc      | package | 2.4.6-6.41.1 | noarch | openSUSE-13.1-Update
i | apache2-mod_php5 | package | 5.4.20-34.3  | i586   | openSUSE-13.1-Update
i | apache2-prefork  | package | 2.4.6-6.41.1 | i586   | openSUSE-13.1-Update
i | apache2-utils    | package | 2.4.6-6.41.1 | i586   | openSUSE-13.1-Update


I have working 11.4 install on same box and I have manually updated/copied local changed config-files(parts) to 13.1 install. Something is missing, but I can’t find what. Working 11.4 has apache2-2.2.17-80.1.i586, php5-5.3.17-387.2.i586 and apache2-mod_php5-5.3.17-387.2.i586

Yeah well that’s it then - what files have you replaced exactly?

You can’t simply copy the configuration files from an earlier, Apache 2.2 no less, to an Apache 2.4 installation. There are several changes to the configuration files and their layout.

Sorry my bad respons. I have only copied parts of config-files. Parts I think was needed for my needs. At the moment I am not sure what they are. I could easely copy all cofig files 11.4 to new 13.1 and see what happens, but as you tell that would make it worse. Other way to debug is to reinstall Apache and php to get original config and then make needed changes one by one until I find error. I have tried find differences with grep but there is too many lines to find the interesting ones for my purpose. As I told 11.4 work fine and 13.1 also except php. So my work is to find the difference causing the problem.

Solved!

Error caused by default-server.conf:

  
  ServerName Intranet
# YaST auto define section
<IfDefine SSL>
 SSLEngine off
</IfDefine>

At some stage in my work I used YaST http-server module and it changed this file. I have several virtual IP-based hosts and all were affected by this. As I see this is bug in YaST and in apache2/php-module.

I have reverted to rpm-original default-server.conf. No change is needed in it when using virtual hosts.

Thank you Miuku for your support and engagement!

Good to hear you got it fixed!