Apache downloads the Php files instead of executing them

16 posts / 0 new
Last post
#1 Sun, 02/05/2012 - 12:44
carlatf

Apache downloads the Php files instead of executing them

Hi,

I had virtualmin running fine and I didn-t do anything yesterday on my server but suddenly apache downloads the php file instead of executing it. tresjolie.com.ar

a subserver of the same server works fine though

fiestajolie.com.ar

I know that something in the config must be wrong, but I searched everywhere and all seems to be fine. The error log doesnt show anything and I dont remember to have changed anything.

The system was not upgraded also,

Is there any line that I could add to force apache to excecute php files?

Mon, 02/06/2012 - 23:21
carlatf

Ok, something REALLY strange is happening.

I tried to bypass the error by pointing the domain to a subdirectory (as fiestajolie.com.ar) and now I can access to:

http://tresjolie.com.ar/component/community/search/browse?sort=online&It...

BUT

http://tresjolie.com.ar

STILL REQUESTS ME TO DOWNLOAD THE FILE.

Soo, php is working but is something terrible wrong with the configuration.

I disabled Apache-s cache mod because I thought maybe it was a problem with the cache, but no changes.

Users report the same as me.

Any ideas?

Ive been trying to solve this all day and nothing. Ive added the php handlers in every config line I could think of.

Best regards, Carla

Mon, 02/06/2012 - 23:21
carlatf

Btw, I realized the problem started when Virtualmin was updated.

Tue, 02/07/2012 - 08:51
andreychek

Howdy,

Were you able to get things working? When I access the URL's you shared, I see your website, and am not prompted to download a file.

However, one thing you may want to do, just to be sure, is to go into System Settings -> Re-Check Config, and make sure that Virtualmin doesn't see anything unusual there.

-Eric

Tue, 02/07/2012 - 14:15
carlatf

Hi,

I can access to:

http://tresjolie.com.ar/administrator

but not to http://tresjolie.com.ar/index.php

The users report the same.

I'm running Apache as www-data and php also, I have mod_php activated for the server.

To get if working I moved the directory from
/home/tresjolie/public_html to /home/tresjolie/domains/tresjolie.com.ar/public_html

I just Recheck of the configuration and I got: Apache configuration file /etc/apache2/mods-enabled/php5.conf contains SetHandler lines that PHP from running with domain owner permissions. These lines must be removed. I comment them out, but the problem persists.

Btw, if I comment out those lines, how apache knows it has to execute php files?

Best regards, Carla

Ps. My apache config:


<VirtualHost *:80>
ServerName tresjolie.com.ar
ServerAlias www.tresjolie.com.ar
DocumentRoot /home/tresjolie/domains/tresjolie.com.ar/public_html
ScriptAlias /cgi-bin/ /home/tresjolie/cgi-bin/
DirectoryIndex  index.php index.html index.php4 index.php5

# estos cuatro los pongo por desesperacion

AddType application/x-httpd-php .php
AddHandler application/x-httpd.php .php .phtml
AddHandler x-httpd.php .php .phtml
AddHandler php-script .php

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


#ExpiresActive On
#ExpiresByType text/html "access plus 30 seconds"
#ExpiresByType text/css "access plus 1 weeks"
#ExpiresByType text/javascript "access plus 1 weeks"
#ExpiresByType image/png "access plus 1 day"

# Compress some text file types
#AddOutputFilterByType DEFLATE text/html text/css text/xml application/x-javascript

# Deactivate compression for buggy browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Set header information for proxies
Header append Vary User-Agent


<Directory /home/tresjolie/domains/tresjolie.com.ar/public_html>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
#AddOutputFilterByType DEFLATE text/html text/plain text/xml
allow from all
AllowOverride None

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^tresjolie\.com\.ar$ [NC]
RewriteRule ^(.*)$ http://tresjolie.com.ar/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !\.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

</Directory>

<Directory "/home/tresjolie/cgi-bin">
allow from all
</Directory>

AddDefaultCharset UTF-8
ErrorDocument 404 http://tresjolie.com.ar

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel error
ErrorLog /var/log/virtualmin/tresjolie.com.ar_error_log
CustomLog /var/log/virtualmin/tresjolie.com.ar_access_log "combined"

#php_value memory_limit 128M
#RemoveHandler .php
#RemoveHandler .php5
#IPCCommTimeout 61
#FcgidMaxRequestLen 1073741824
#SuexecUserGroup "#1008" "#1013"
</VirtualHost>
Tue, 02/07/2012 - 15:04
andreychek

Howdy,

Ah, I do get a 500 Internal Server error when accessing that domain.

What error shows up in your Apache logs when that occurs? That's in $HOME/logs/error_log.

Regarding the SetHandler lines -- Virtualmin adds configuration to each Virtual Server it adds to Apache in order to allow it to work via FCGID or CGI. It doesn't need those SetHandler lines, and those will only cause problems.

-Eric

Tue, 02/07/2012 - 22:37
carlatf

Hi, I commented out the lines. I remind you that mod_php ius being used here, no fcgid or cgi.

Now, something odd is happening, I can access to the page www.tresjolie.com.ar

and the index.php seem to work fine, and some of my users too.

But SOME users also report that they still are being asked for the file to download, no matter how much they press F5.

I'm going to look into the error file to see why.

Wed, 02/08/2012 - 08:40
andreychek

But SOME users also report that they still are being asked for the file to download, no matter how much they press F5.

Well, I suspect some browsers have cached that file -- rather than just reloading the page, they may need to clear their browser cache if it just doesn't work for them.

-Eric

Sun, 01/06/2013 - 13:29
chiareu

Hi, today when I try to access domain.tld/phpmyadmin the same problem, instead of execute my browser downloaded the .php file. Other domains with same issue... first thing in my mind was... haked? WTF Until that moment no updates from last evening check.

In webmin/virtualmin interface there was some postgres updates pending, so I run it and after that apache was dead So I log over SSH, and after I read the upgrade procedure to Ubuntu 12.04 https://www.virtualmin.com/documentation/system/os/ubuntu-lucid-to-precise I started the upgrade.

Now in PHP Config, when I comment out the lines that begin with SetHandler, The Virtualmin check give me that error.. Apache configuration file /etc/apache2/mods-enabled/php5.conf contains SetHandler lines that prevent PHP from running with domain owner permissions. These lines must be removed. .. your system is not ready for use by Virtualmin.

With the lines commented the Virtualmin check is run OK, but in both cases the .php files are downloaded not executed...

The worst thing... I'm on the production server :(

Sun, 01/06/2013 - 22:08
andreychek

Hi, today when I try to access domain.tld/phpmyadmin the same problem, instead of execute my browser downloaded the .php file. Other domains with same issue... first thing in my mind was... haked? WTF Until that moment no updates from last evening check.

That can occur when you also have phpMyAdmin installed using the distro's .deb file.

What I'd recommend doing is removing the phpMyAdmin .deb, and instead install phpMyAdmin using the Virtualmin install script.

Alternatively, it should work if you were to change the PHP Execution Mode of that Virtual Server to mod_php.

-Eric

Mon, 01/07/2013 - 03:50
chiareu

Hi, until few days ago phpmyadmin was working fine from distro's install. So my tough was the same and I uninstalled phpmyadmin from system.

  1. The main issue was that *.php files on the server was displayed not executed.

Now, with "SetHandler" commented in config, the Virtualmin check is OK, but I must take all domain and change manual to use apache mod_php to execute .PHP files. In FCGId and CGI it keep showing the .PHP files instead execute php

So temporary solution was to set all domains to run exclusively in Apache mod_php

  1. Now I run in other problems with Mysql server, constantly it give me "Error 24, Too many open files (Out of resources when opening file/Can't open file)...."

Can you give me some advice regarding this? I tried already to modify "/etc/security/limits.conf"

Mon, 01/07/2013 - 09:42
andreychek

Howdy,

The problem you're seeing is related to the security warning you saw when upgrading Virtualmin. The distro's phpMyAdmin package is using a shared phpMyAdmin installation, one which relies on using mod_php to execute the PHP code, even when that Virtual Server is configured to use CGI or FCGID.

Allowing that is a large security issue, and can inadvertently grant a user access to all files in /home.

The recommended fix is to remove your distro's phpMyAdmin package, and to instead use Virtualmin's Install Script to install phpMyAdmin into the individual Virtual Server's that need it (or into one central Virtual Server, and have your users access that one central domain).

Now I run in other problems with Mysql server, constantly it give me "Error 24, Too many open files (Out of resources when opening file/Can't open file)...."

Could you start a new forum thread for that question? Then we can go over the problem you're seeing in that new thread :-) Thanks!

-Eric

Thu, 01/17/2013 - 19:18
3k

I have the same problem as Chiareu with PHPMyAdmin and RoundCube after the last upgrade. After the problems appeared I did a fresh install of PHPMyAdmin and RoundCube via Virtualmin's script, but the problem still remains. Due to security problems of a shared server I don't want to use mod_php. All websites with PHP are working fine.

Thu, 01/17/2013 - 21:27
3k

I suppose the problem started due to the Virtualmin's security fix of symbolic links. The configuration files in etc/apache2/conf.d referring to phpMyAdmin and RoundCube were using "FollowSymlinks". I tried to set them to "SymLinksIfOwnerMatch" and the Appache stopped sending phpMyAdmin index.php and showed the error:

Forbidden You don't have permission to access /phpmyadmin/index.php on this server.

So I'm a bit closer to the solution.

Fri, 02/24/2017 - 00:02
devadatta

I fixed it by adding the following 2 lines into: /etc/php5/fpm/pool.d/1487916120411608.conf

listen.owner = _your_vserver_username_
listen.group = _your_vserver_usergroup_
Topic locked