Php prompts to save instead of executing

Hello, after the last update none of my php scripts work. Whenever I tried to access a .php file through the browser it prompts me to save the file instead of executing it. Anyone knows what could be the problem? Thanks

Yeah, it shouldn’t do that :wink:

Are you running Virtualmin GPL or Pro?

And do you know what execution mode PHP is in – mod_php, cgi, or fcgid?

Lastly, do any PHP scripts work, for this or other Virtual Servers? Or do they all have this trouble?

-Eric

is GPL, and it’s happening on all the virtual servers, even if I use the php_info script. If I use the command php -v on the terminal I get: PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2

I’m not sure how to know the execution mode. Thanks!

Okay, are you seeing any errors in the Apache error log? Either in /var/log/apache2/error_log, or $HOME/logs/error_log?

If you aren’t sure whether you were using CGI or mod_php, my guess is that you had mod_php enabled.

So, something may have broken that for some reason.

What do you see if you type:

ls /etc/apache2/mods-enabled/

If you have files in there beginning with “php”, what are their contents?

-Eric

Ok, I just found that the php5 module was not enabled and when I tried to enable it I got an error saying:

Starting web server: apache2apache2: Syntax error on line 185 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory
failed!

I don’t know why that file does not exist. What should I do then? Thank you

Ok, I reinstalled the mod-lib-php5 package and now the libphp5.so is there and apache is not giving errors. But I still cannot execute php5, it seems the mime type is missing should I add it (on that case what should I include?) or php should handle it alone. Thanks!

I have added the mime-type:
application/x-httpd-php php

and also tried:
application/x-httpd-php /usr/bin/php

but none of them make it work… what should I do?

do you have
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
AddType text/html .php

Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory failed!

This error makes it sound like mod_php is not installed.

What does this command show:

dpkg -l ‘php

Oops, I see you already took care of that issue, I didn’t read far enough :slight_smile:

Yeah, I’d look into what Ronald is suggesting, that may help!

-Eric

Sorry for my ignorance, but where should I have or add those commands? Thanks

I added them on /etc/apache2/apache2.conf but no changes…

Im on a Centos box, not debian. I’m not sure where it would be exactly on your machine, nor if you need to add those lines.
On my box it is:

/etc/httpd/conf.d/php.conf

as for the mime-types you have added, I can only say that I can not locate them on my machine. It may be a Debian way of doing things, I don’t know. Likely Eric can troubleshoot this way better than I can, but I thought I’d mention it anyways.

On Debian and Ubuntu, all those config things for PHP would generally go into /etc/apache2/mods-enabled/php5.conf.

What does that file look like now?

-Eric

Ok, it’s working now. I just needed to install php5 and wait a bit, maybe it was something regarding the dns spreading. The mime-types are not needed just the changes in the php5.conf. Thanks for the help!

Eric,

I’m experiencing this issue, however only with a few of my virtual servers. Some appear to work correctly while others are trying to download the php files instead of executing it. I’m not sure where to narrow it down. Running debian 6, and have installed the recent apache updates

Looks like the following lines have been removed from a few of my virtual servers, or weren’t added, when I reloaded apache the other day to apply changes it broke everything

AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/digaserve/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/digaserve/fcgi-bin/php5.fcgi .php5

Seems to be working now that I’ve added those lines back.

+ExecCGI was also removed. Only on a few virtual servers. Including one I hadn’t been working on. Strange.