Php files beiing downloaded instead of executed

If none of the more specific forums is the right place to ask

Php files beiing downloaded instead of executed

Postby Recif » 2020-01-29 09:57

Hello,

New server Debian 10 with php 7.3 and Apache 2.4 First virtualhost created works perfectly (Wordpress) Second one all php files are beeing downloaded instead of executed Phpmyadmin shows php file content!...
I spent 2 days with tons of solutions and verifications on the web, but until now nothing works! :-((
Could someone helps on this problem? As one of the virtual hosts works, this is not an installation problem. But I reviewed all apache 2 conf sites and I can't find anything!...

Here is the one which works:

Code: Select all
<VirtualHost *:80 [fa99::ec4:7aff:f855:fc6a]:80>
SuexecUserGroup "#1001" "#1001"
ServerName site-1.fr
ServerAlias www.site-1.fr
ServerAlias webmail.site-1.fr
ServerAlias admin.site-1.fr
DocumentRoot /home/site-1/public_html
ErrorLog /var/log/virtualmin/site-1.fr_error_log
CustomLog /var/log/virtualmin/site-1.fr_access_log combined
ScriptAlias /cgi-bin/ /home/site-1/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/site-1/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php7.3
FCGIWrapper /home/site-1/fcgi-bin/php7.3.fcgi .php
FCGIWrapper /home/site-1/fcgi-bin/php7.3.fcgi .php7.3
</Directory>
<Directory /home/site-1/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.site-1.fr
RewriteRule ^(.*) https://site-1.fr:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.site-1.fr
RewriteRule ^(.*) https://site-1.fr:10000/ [R]
RemoveHandler .php
RemoveHandler .php7.3
FcgidMaxRequestLen 1073741824
IPCCommTimeout 31
</VirtualHost>


The other which doesn't work :

Code: Select all
<VirtualHost *:80 [fe99::ec4:7aff:xr88:fc6a]:80>
SuexecUserGroup "#1010" "#1003"
ServerName test.com
ServerAlias www.test.com
ServerAlias webmail.test.com
ServerAlias admin.test.com
DocumentRoot /home/test/public_html
ErrorLog /var/log/virtualmin/test.com_error_log
CustomLog /var/log/virtualmin/test.com_access_log combined
ScriptAlias /cgi-bin/ /home/test/cgi-bin/
AddHandler fcgid-script .php
AddHandler fcgid-script .php7.3
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/test/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php7.3
FCGIWrapper /home/test/fcgi-bin/php7.3.fcgi .php
FCGIWrapper /home/test/fcgi-bin/php7.3.fcgi .php7.3
</Directory>
<Directory /home/test/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.test.com
RewriteRule ^(.*) https://test.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.test.com
RewriteRule ^(.*) https://test.com:10000/ [R]
RemoveHandler .php
RemoveHandler .php7.3
php_admin_value engine Off
FcgidMaxRequestLen 1073741824
</VirtualHost>


Any idea?
Thanks
Recif
 
Posts: 12
Joined: 2007-09-04 12:12

Re: Php files beiing downloaded instead of executed

Postby Chrisdb » 2020-01-29 10:57

can you also post the output of your .htaccess file(s)..
Chrisdb
 
Posts: 253
Joined: 2018-04-10 07:16

Re: Php files beiing downloaded instead of executed

Postby Recif » 2020-01-29 11:25

Yes, for test.com there is no htaccess, for the other :

Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Recif
 
Posts: 12
Joined: 2007-09-04 12:12

Re: Php files beiing downloaded instead of executed

Postby Chrisdb » 2020-01-29 11:50

What files do you have under: /home/test/public_html

Does your problem occur with index.php? What is the content of this file?

**EDIT
Do you have execute rights in /home/test/public_html
Chrisdb
 
Posts: 253
Joined: 2018-04-10 07:16

Re: Php files beiing downloaded instead of executed

Postby Recif » 2020-01-29 12:07

Only index.php with a simple

Code: Select all
<? php
echo ok


Rights: yes, and I tested with 0777 chmod for all dirs and files, but same problem...
Recif
 
Posts: 12
Joined: 2007-09-04 12:12

Re: Php files beiing downloaded instead of executed

Postby Recif » 2020-01-29 12:25

Well, I found something : when I remove "php_admin_value engine Off" at the end of the virtualhost directives, it show the page "ok"! So why the automatic virtualhost process generator (virtualmin) is adding this line?... :-(
Recif
 
Posts: 12
Joined: 2007-09-04 12:12

Re: Php files beiing downloaded instead of executed

Postby Chrisdb » 2020-01-29 12:39

Recif wrote:Well, I found something : when I remove "php_admin_value engine Off" at the end of the virtualhost directives, it show the page "ok"! So why the automatic virtualhost process generator (virtualmin) is adding this line?... :-(


You beat me to it :D
see (at the bottom):
https://cwiki.apache.org/confluence/display/HTTPD/PHPDownload
Chrisdb
 
Posts: 253
Joined: 2018-04-10 07:16

Re: Php files beiing downloaded instead of executed

Postby Recif » 2020-01-29 13:02

Ok! :D
Thanks for answers :wink:
Recif
 
Posts: 12
Joined: 2007-09-04 12:12


Return to General Questions

Who is online

Users browsing this forum: No registered users and 13 guests

fashionable