Ubuntu 18.04 = Virtualmin 6.0.11 : LAMP - PHP not working - download PHP code

18 posts / 0 new
Last post
#1 Wed, 05/23/2018 - 18:31
Didier Misson

Ubuntu 18.04 = Virtualmin 6.0.11 : LAMP - PHP not working - download PHP code

Hello I test the new Ubuntu 18.04 with the new Virtualmin install script 6.0.11.

It's a new Proxmox container (unpriviledge container).

I simply

  • install the Ubuntu 18.04
  • run Virtualmin beta 6.0.11 install script

so, Virtualmin, Webmin, Usermin, LAMP, Fail2ban, Bind9, Postfix was automaticaly installed by the script.

All seem normal.

I create a new server with Virtualmin :

A simple HTML page is correctly display "Hello Word" .

BUT

If I try a PHP page like "info.php", the browser try to DOWNLOAD the PHP code ! So, Apache + PHP don't run PHP, but simply send PHP code to the user ...

Some day ago, I try to install Virtualmin manually with the .deb package. And it was working ! "info.php" display all PHP informations (and not dowload the code)

So, it's probably a bug in the Virtualmin install script ?

Perhaps a little setting missing between Apache and PHP ?

Thanks Didier

Thu, 05/24/2018 - 09:28
nobody

Same here. This seems a problem with FCGId (FPM appears to be working).

Thu, 05/24/2018 - 11:22
duard
duard's picture

Same problem here. My php sites are downloading instead of executing.

fresh install !!!!!

Thu, 05/24/2018 - 11:35
duard
duard's picture

RESOLVED => comment this line on virtual hosts conf files in sites-avaiable

php_admin_value engine Off
Thu, 05/24/2018 - 13:33 (Reply to #4)
Didier Misson

oh... How I don't see this !...

YES ! info.php works.

But, it's not really solved. It's a bypass and, ok we can work with Ubuntu 18.04 LTS.

How to correct this, so that we don't need to edit the Apache VirtualHost each time we create a new site ?

Thanks. Didier

Didier Misson

Fri, 05/25/2018 - 10:05
nobody

However now php does not appear to be running as the account owner.

Sat, 05/26/2018 - 08:20
Sat, 06/09/2018 - 20:45
siwuch

The reason this happening is mod_php is globally enabled and it has precedence over CGI or FCGI (which allows running under account owner). If the site is configured to run as CGI or FCGI, the following line is added to apache vhost file:

php_admin_value engine Off

This disables mod_php for the site. As a result, when apache receives request it follows processing with mod_php, but then vhost config disables php with the line above, and you get the code displayed / downloaded, instead interpreted by PHP.

In order to fix, comment out the lines that globally enable mod_php in /etc/apache2/mods-enabled/php*.conf (replace * with correct version on your server). Two lines needs to be commented out, in my case this file looks as follows:

      1 <FilesMatch ".+\.ph(p[3457]?|t|tml)$">
      2     #SetHandler application/x-httpd-php               <---------- this one
      3 </FilesMatch>
      4 <FilesMatch ".+\.phps$">
      5     #SetHandler application/x-httpd-php-source          <------------- and this one
      6     # Deny access to raw php sources by default
      7     # To re-enable it's recommended to enable access to the files
      8     # only in specific virtual host or directory
      9     Require all denied
     10 </FilesMatch>
     11 # Deny access to files without filename (e.g. '.php')
     12 <FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">
     13     Require all denied
     14 </FilesMatch>
     15
     16 # Running PHP scripts in user directories is disabled by default
     17 #
     18 # To re-enable PHP in user directories comment the following lines
     19 # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
     20 # prevents .htaccess files from disabling it.
     21 <IfModule mod_userdir.c>
     22     <Directory /home/*/public_html>
     23         php_admin_flag engine Off
     24     </Directory>
     25 </IfModule>

Comment out the lines, restart apache, set your site to run as domain owner in fcgid mode, that should be it. Also keep in mind that tinkering with vhost definitions outside of Virtualmin like suggested in one of the posts above, will cause problems one day, because Virtualmin will eventually overwrite the file one day, when making config changes to the site.

Wed, 01/16/2019 - 11:12 (Reply to #8)
manzwebdesigns
manzwebdesigns's picture

Hi,

I did as you suggested and my site was already set to run in fcgid mode... still downloading the file.

Bud Manz

Wed, 12/11/2019 - 09:02 (Reply to #9)
NettSite
NettSite's picture

Thank you for sharing this! I am running on Ubuntu 16.04, and everything was fine with PHP 7.0, but I had to add 7.3 to accommodate Laravel stuff, and then all sites started downloading php files.

You saved my bacon!

Fri, 06/15/2018 - 02:11
mao_dze_dun

Just wanted to personally thank siwuch. You helped me with something that kept me banging my head against the wall for two weeks. I cannot thank you enough.

Tue, 10/02/2018 - 04:20
filerem
filerem's picture

thanks to #siwuch for your fix !

--
It's a beautiful day !

Mon, 10/15/2018 - 09:33
vcg_global

Yes thank you siwuch. I created an account simply to thank you. I've been trying to figure this out for days now. Much appreciated!

Sun, 10/21/2018 - 20:04
hescominsoon

so this is a virt bug?

Sun, 10/21/2018 - 20:30
andreychek

Yeah, there's a few outstanding issues with Ubuntu 18.04 support, unfortunately. Due to that, we haven't yet listed that as one of the supported distros. We're working on fixing those issues though, and hope to have full support for that in the near future! But we unfortunately don't have an ETA.

Once it's fully supported, we'll make a news release here in the Forums, as well as list it as a supported OS in the install script, and list it in the os-support page here on the website.

-Eric

Wed, 10/31/2018 - 22:23 (Reply to #15)
siwuch

andreychek, how safe is it to install current Virtualmin / Webmin (6.04 / 1.894) on Ubuntu 18.04? I just finished installing after disabling Netplan, fixed this PHP code download issue and so far so good. I have not tested extensively, and I'm wondering what kind of issues are the ones that are left until official Ubuntu 18.04 support is added. Should I expect any issues down the road if I keep current setup? I know I'm asking about unsupported stuff, was just wondering, maybe the remaining issues are not that significant and it's safe to keep that guy and then just upgrade to the most recent Virtualmin once it's released, without breaking the whole thing...

Wed, 10/31/2018 - 22:30 (Reply to #16)
andreychek

Howdy,

You've gotten past the hard part. There's actually quite a few folks now using Ubuntu 18.04, it's mostly those issues that you've already fixed.

You shouldn't be seeing "random" issues down the road... if things work now, they should work later too.

Personally, if I were in your shoes, I'd move forward with using Ubuntu 18.04 :-)

And if you do happen to run into any issues, let us know and we'll add those to the list!

-Eric

Thu, 11/01/2018 - 12:30 (Reply to #17)
siwuch

Fantastic, thanks!

Topic locked