[SOLVED] PHP files get downloaded instead of executed in FCGId

11 posts / 0 new
Last post
#1 Thu, 06/14/2018 - 08:02
mao_dze_dun

[SOLVED] PHP files get downloaded instead of executed in FCGId

SOLVED!!!

So a few hours after posting I found this recent post: https://www.virtualmin.com/node/57240 The original poster is running Ubuntu 18.04 LTS just like me and the solution offered by siwuch seems to work properly for me.

SOLUTION

In "/etc/apache2/mods-enabled/php.conf" (replace php with your filename, depending on the php version you're using - in my case it was php7.2.conf) comment out the following two lines:

SetHandler application/x-httpd-php

SetHandler application/x-httpd-php-source

Restart the apache server via the following command:

sudo service apache2 restart

Now set your webstite to FCGId (Virtualmin -> Server Configuration -> Website options -> PHP script execution mode ) and it should work properly.

I'm putting the solution here, as well, just in case somebody stumbled on this topic from Google. All credit goes to siwuch who posted the fix in the topic I've linked to.

ORIGINAL POST

Hello, I am a complete noob to VPS and Virtualmin, so I'd be thankful if I can rely a bit on the community wisdom :).

I've got a VPS from OVH and I installed Ubutnu 18.04 LTS a couple of weeks ago, and it is to be solely used for a few Wordpress websites. So, Virtualmin is pretty awesome and so far I've been able to get by and pass the blocks I've hit with fervorous googling, but this is something I've been banging my head against, for days.

The problem:

If the "PHP script execution mode" in "Website options" is set to FCGId, i.e. the default option, php files are downloaded instead of executed. Settings it to mod_php, fixes the problem, but then I have a permissions problem with Wordpress - can't update or install plugins. I've to either set permissions of all folders to 777 (which even a noob like me knows is a big no-no) or change the ownership of everything inside the public_html folder to www-data, which I understand is the default Ubuntu user, but from what I've seen, this is also a security risk.

I've read around the web and the Virtualmin forums and have seen this issue is not as unique, but most, if of the solutions are for CentOS and not Ubuntu.

What I've tried:

  • I've updated everything and kept it up to date. From what I've gathered, there are no 3rd party repositories added to my Ubuntu install (everything in /etc/apt/sources.list is either *.ubuntu.com or *.virtualmin.com). I did see PHP from a 3rd party repo could cause this, but to my understanding - that's not the case here
  • I've tried commenting out "SetHandler application/x-httpd-php" in /etc/apache2/mods-available/php7.2.conf
  • I've used the command "virtualmin fix-domain-permissions --all-domains --subservers"
  • I've used the command "virtualmin modify-web --mode fcgid --all-domains"
  • I've tried a clean re-install of both Virtualmin and the server
  • I've checked the Webserver error log file in /var/log/virtualmin/ but there was nothing there

I'm probably forgetting something but this is the info I can think of. I would be very thankful if somebody has an idea how to fix this. If I understand it correctly, FCGId is the Wordpress friendly mode of PHP script execution.

Thanks in advance.

Sat, 11/03/2018 - 10:20
bluora

Thanks. Exact same issue tonight.

Wed, 12/19/2018 - 01:46
sentence

Many thanks, you saved hours from my life! :D

Thu, 12/27/2018 - 06:34
musicmouse

For me this issue has become a reason to stop using Vitaminic. I use Vitaminic so that I don't have to worry about how I should do all those millions of server settings. But how can I trust Vitaminic when it doesn't even get this very basic thing right?

Thu, 12/27/2018 - 09:40
John_B

My problem came after moving from php7.0 to php7.1 on Debian 9 (where php7.0 is still the standard package in the repo). The fix was (1) apt-get install php7.1-cgi; (2) modify files as per https://www.virtualmin.com/comment/754860#comment-754860 I do not think it is really Virtualmin at fault as my php upgrade was done outside Virtualmin. On the other hand, when you have a problem like this Virtualmin does introduce another layer of complexity. Probably all control panels do.

Sun, 12/30/2018 - 10:48
jcsv75

I just wanted to say thanks as well. This has solved my problem which was exactly the same as described above. The issue started to occur after I upgraded from Ubuntu 16.04 to 18.04 which changed the default php version from 7.0 to 7.2. Once I commented out the two lines in php7.2.conf and restarted apache, the problem was gone. cheers!

Wed, 01/16/2019 - 03:28
szrick

Just want to share one more solution if none of the above mentioned ways seems working.

You need to comment out (i.e. add # in front of the line so it becomes a comment)

SetHandler application/x-httpd-php

SetHandler application/x-httpd-php-source

in 2 (two) config files:-

/etc/apache2/mods-enabled/php7.2.conf (in my case is php 7.2)

/etc/apache2/apache2.conf

After that, remember to

  1. sudo service apache2 restart

  2. Clear your browser cache (Ctrl+Shift+Delete)

Mine was solved using the above procedures after days of debugging.

Sun, 08/18/2019 - 12:51
adiljv

Hi,

I have the same problem but i use PHP 5.6 and i dont find "/etc/apache2/mods-enabled/php5.6.conf"

I use PHP 7.2 and php5.6 to run specific script with .

anyone can help me .

Thanks

Sun, 08/25/2019 - 07:22 (Reply to #8)
Sadeghpm

Also check "/etc/apache2/apache2.conf"

Tue, 11/19/2019 - 12:25
WalterWhite
WalterWhite's picture

I've tried all of this and it's still doing it. (Downloading rather than executing the php files)

Brand new install of Ubuntu Server 18.04 LTS and Virtualmin via the script.

Tue, 11/19/2019 - 13:21
WalterWhite
WalterWhite's picture

So as a test I decided to just drop all the website files into the var/www/html folder for localhost and presto. It works. So there's something definitely wrong with Virtualmin that prevents it from working and constantly downloading the index.php rather than processing it.

Does anybody have any other ideas I can try? I've been at this for three days and gotten absolutely nowhere.