New Apache/PHP install prompts browser to download PHP file

I have a one-week-old installation of openSUSE 11.1 and have just installed Apache2 and PHP5. I saved a small file in my home directory’s “public_html” directory with the following content


Loading this file as http://localhost/~myusername/test.php prompts my browser (Firefox 3) to save the file. Now, either the correct MIME type isn’t being issued and/or the server isn’t processing the file.

This is what “a2enmod -l” shows:

actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user authn_dbm autoindex cgi dir env expires include log_config mime negotiation setenvif ssl suexec userdir php5

I referred to Linux Apache MySQL PHP Server (lamp), but it makes no mention of actually configuring PHP to work properly with Apache, since I guess it’s supposed to “just work” but not in my case.

I’ll begin searching for the solution but in case anybody knows, I’m hoping this post will result in a quicker answer. I’m not an experienced web developer in Linux, only a previous tinkerer, as I’m a refugee from the Windows world.

Have you modified the mime section in the apache config file (and
restarted apache)?

AddType application/x-httpd-php .php .phtml .html

Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 x86 Kernel
up 1 day 12:12, 1 user, load average: 0.08, 0.29, 0.31
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.82

Mea culpa. I didn’t actually choose the pattern for LAMP in YaST but had only installed Apache2 and PHP5 myself. The yast2-http-server and apache2-mod_php5 packages were selected and must have been the culprits. I did an “rcapache2 restart” and now my PHP files load.

I also had to wrap <html></html> tags around my previous code test before the browser would actually display it.

That was quick :slight_smile: See my answer above. It was my fault all along, but I’ll make a note of your answer for future reference. Thanks.

No worries, that stuff always happens. However, if you have too wrap it
with html tags, then you still need to investigate mime types :wink: It
should just work with your original code.

Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 x86 Kernel
up 1 day 13:20, 1 user, load average: 0.07, 0.14, 0.07
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.82

It must have been a browser caching problem because I don’t need the extra HTML tags now. Thanks.