Php prompts to save instead of executing

18 posts / 0 new
Last post
#1 Mon, 07/06/2009 - 05:09
daniorama

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

Mon, 07/06/2009 - 09:08
andreychek

Yeah, it shouldn't do that ;-)

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

Mon, 07/06/2009 - 10:34 (Reply to #2)
daniorama

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!

Mon, 07/06/2009 - 10:47 (Reply to #3)
andreychek

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

Mon, 07/06/2009 - 11:14 (Reply to #4)
daniorama

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

Mon, 07/06/2009 - 12:20 (Reply to #5)
andreychek

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'

Mon, 07/06/2009 - 12:21 (Reply to #6)
andreychek

Oops, I see you already took care of that issue, I didn't read far enough :-)

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

-Eric

Mon, 07/06/2009 - 11:26 (Reply to #7)
daniorama

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!

Mon, 07/06/2009 - 12:01 (Reply to #8)
daniorama

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?

Mon, 07/06/2009 - 20:22 (Reply to #9)
andreychek

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

Mon, 07/06/2009 - 12:06
ronald
ronald's picture

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

Mon, 07/06/2009 - 12:42 (Reply to #11)
daniorama

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

Mon, 07/06/2009 - 12:32
daniorama

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

Mon, 07/06/2009 - 12:44
ronald
ronald's picture

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.

Tue, 07/07/2009 - 10:35
daniorama

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!

Sun, 09/04/2011 - 01:15
oranjbox

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

Sun, 09/04/2011 - 01:34
oranjbox

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.

Sun, 09/04/2011 - 01:38 (Reply to #17)
oranjbox

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

Topic locked