5

I recently downloaded OpenSUSE OS version 11.4 from the site to use it as a server..In order to do that I downloaded the server edition that has Apache/2.2.17 and PHP5 downloaded by default.....Ok till now it is fine

Now I started the Apache successfully and put a test.php file in the documentRoot directory. test.php contain only <?php phpinfo() ?>

Then using my browser I typed http://localhost/test.php and here was the problem the browser didn't display what phpinfo() should display, instead it asked me whether I want to open or save test.php...which is driving me crazy.... I googled a lot but no solution

THis is /etc/apache2/conf.d/php5.conf

<IfModule mod_php5.c> AddHandler application/x-httpd-php .php4 AddHandler application/x-httpd-php .php5 AddHandler application/x-httpd-php .php AddHandler application/x-httpd-php-source .php4s AddHandler application/x-httpd-php-source .php5s AddHandler application/x-httpd-php-source .phps DirectoryIndex index.php4 DirectoryIndex index.php5 DirectoryIndex index.php </IfModule> 
2
  • Can you post your httpd.conf ? The part for PHP only not all of it. Commented Jul 4, 2011 at 17:58
  • ok just a minute Commented Jul 4, 2011 at 18:00

8 Answers 8

4

One thing worth trying, is verifying that your project is not in a user dir (public_html folder), or that the configuration in php5.conf (/etc/apache2/mods-available/php5.conf for some configuration) allows such interpretation.

<IfModule mod_php5.c> <FilesMatch "\.ph(p3?|tml)$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch> # To re-enable php in user directories comment the following lines # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it # prevents .htaccess files from disabling it. #<IfModule mod_userdir.c> # <Directory /home/*/public_html> # php_admin_value engine Off # </Directory> #</IfModule> </IfModule> 
2

You can check what's inside

nano /etc/apache2/mods-available/php5.conf 

also you can check

sudo dpkg -S php5 | grep libapache2-mod-php5 

which shows whether you have php5.conf in mods-enabled

I've got there:

<FilesMatch ".+\.ph(p[345]?|t|tml)$"> SetHandler application/x-httpd-php </FilesMatch> 

Note that this regexp matches .php5, but for some reason could not match .php.

Solution

apt-get remove libapache2-mod-php5 ; apt-get purge libapache2-mod-php5; apt-get install libapache2-mod-php5 

then open

nano /etc/apache2/mods-enabled/php5.conf 
  1. and replace

    <FilesMatch ".+\.ph(p[345]?|t|tml)$"> 

    with

    <FilesMatch ".+\.ph((p[345]?)|t|tml)$"> 
  2. or simply execute

    sudo perl -pe 's|\Q.ph(p[345]?\E|.ph((p[345]?)| if $. <= 3' /etc/apache2/mods-available/php5.conf 

and restart apache

sudo service apache2 restart 
1

Take a look at PHP documentation and make sure the configuration is right

http://www.php.net/manual/en/install.unix.apache2.php

This should be in your httpd.conf

LoadModule php5_module modules/libphp5.so <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> 
4
  • I can't find libphp5.so on my whole system, but i found mod_php5.so Commented Jul 4, 2011 at 18:12
  • @Ala ADUDEEB try with this. Make sure your file php5.conf is included in your default conf Commented Jul 4, 2011 at 18:23
  • php5.conf is in /etc/apache2/conf.d which is used by default by apache so this is not the problem Commented Jul 4, 2011 at 18:34
  • @AlaABUDEEB are you sure using the right php5.conf file? try to find where it's. $ find / -iname php5.conf Commented Oct 28, 2012 at 17:04
1

Probably you have no apache2-mod_php installed. Try to zypper install apache2-mod_php5 or whatever package name zypper search apache | grep php shows you.

0

sounds like mod_php5 is disabled somehow

try (as root)

a2enmod php5 service apache2 restart 

Then try to access the pages again

1
  • I did, but it writes "php5 already exists" Commented Jul 4, 2011 at 18:23
0

apache modules in suse/opensuse are enabled from /etc/sysconfig/apache2, include php module where needed, run SuSEconfig and restart apache2 service :)

http://wiki.apache.org/httpd/DistrosDefaultLayout#openSUSE_and_SLES_.28Apache_httpd_2.2.29:

0

I came up with the following solution to the same problem. Change the following directive in /etc/httpd/conf/httpd.conf. I still need to understand why this changed the behavior of Apache, but it worked for me.

Change this:

<Directory /> Options FollowSymLinks AllowOverride None </Directory> 

To this:

<Directory /> Options None AllowOverride None </Directory> 
0

I added php5 to a line thta starts with APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir reqtimeout authn_core authz_core" at /etc/sysconfig/apache2.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.