I followed the following step given on an openSuSE site but I am still encountering the same problem i.e. a phpinfo.php file gets downloaded when I browse it in my browser.
In case the browser wants to save your php files instead of displaying the content, you should enable php support in the /etc/apache2/mod_userdir.conf file. Add the following line to it, just after the <Directory /home/*/public_html> line and restart the server.
Include /etc/apache2/conf.d/php5.conf
phpinfo.php
<?
phpinfo();
?>
Also, I restarted apache using following command but it din solve the problem either.
From your adding a line to mod_userdir.conf, I guess that you serve from the public_html directory in the home directories of your users and not from* /srv *(would have been nice you explained this). I also guess that the file you get served as text is in such a *public_html *directory.
I am in doubt if adding this line in that place is correct. I am serving from* /srv/www/htdocs *and some other directories, but not from users. In my default-server.conf all files in conf.d/ are included automaticaly. Thus, if you have the mod_php5 module installed, this is allready done without any further action.
Sorry for not explaining that earlier. I am also serving from /srv/www/htdocs. I have removed the public_html line from mod_userdir.conf. I added it just because it was mentioned in a forum as a solution to the problem i am facing.
But I am still facing the same problem even after removing that line and restart apache.
But do you have /etc/apache2/conf.d/php5.conf? And is the package *apache2-phpp_mod5 *installed? I gave you a lot of points to check and to report about, but we do not get anything back.
And that test file, is it now in* /srv/www/htdocs* or elsewhere? Do not less us guess so many things. Take the trouble to type, to post configuration files (within CODE tags), in short you should tell as much as possible.
>
> Sorry for not explaining that earlier. I am also serving from
> /srv/www/htdocs. I have removed the public_html line from
> mod_userdir.conf. I added it just because it was mentioned in a forum as
> a solution to the problem i am facing.
>
> But I am still facing the same problem even after removing that line
> and restart apache.
>
you said you followed some advice from an openSUSE forum, if i remember
correctly. you didn’t say how you installed apache2 & php5 though. to make
sure you actually have the necessary packages installed, you could run
from a terminal as root:
rpm -qa | grep .php.
that should result in a list of installed packages that have “php” in
their name. for php to work via apache, these modules have to be among
them: php5 and apache2-mod_php5.
if installed via yast or zypper, on a recent openSUSE release, you’ll have
to enable php5 in /etc/sysconfig/apache2.
that’s a text file with a lot of commented-out examples. the important
line starts with “APACHE_MODULES=”, without “#” in front. That line has to
include “php5” somewhere, for apache to handle php files.