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

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

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


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.


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.


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

Thanks. Exact same issue tonight.

Wed, 12/19/2018 - 01:46

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

Thu, 12/27/2018 - 06:34

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

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

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

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)


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


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 .


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

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

Tue, 11/19/2019 - 12:25
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'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.

Sun, 12/15/2019 - 05:14

Hi all,

I've had this problem after installing PHP 7.3 on my ubuntu 16.04 and non of the above would fix it. After a few days I gave up and did the following:

Backup my sites and take a backup of my postfix and dovecot files Delete my sites From command line remove Apache2 then apt autoremove which essentially removed virtualmin lamp stack Ran the virtualmin installer again Created new sites and restored databases and home folders for each site

Voila! they now run under FCGID as before using PHP 7.3

After the "repair" Dovecot refused to start, remove everything in /run/dovecot and it stated ok

Sat, 12/28/2019 - 22:04

Same here, i've spent 3 days on this after doing the recommended updates Virtualmin said to do, Now ALL my sites are down, I've tried everything and every PHP file on all sites hosted want to download instead of run. I've tried everything and as siad above - THIS is why I used Virtualmin to begin with, so I dont have to deal with this. One click - UPDATE has cost me days and no help or answers. I'm just wore out.


Sun, 12/29/2019 - 09:02

A note for anyone seeing this issue -- while it doesn't appear to occur in all cases, we have some some reports of this occurring.

The following document contains troubleshooting steps which should resolve it:


Topic locked