PHP 7.2 on Ubuntu 16.04 VPS (Domains don't render and website redirect to a download)

14 posts / 0 new
Last post
#1 Fri, 05/18/2018 - 09:57
tgalvao

PHP 7.2 on Ubuntu 16.04 VPS (Domains don't render and website redirect to a download)

Hi, Iam running a VPS server with Ubuntu 16.04 installed.

I have used the ondrej ppa to update to php 7.2. It is recognized by the webmin/virtualmin but now all my websites are redirecting for a file download instead of rendering the php files.

It works just fine with php 7.0, but I need an higher version in order to deploy my Laravel APPs.

How can I fix this?

Regards,

Tiago

Sat, 05/19/2018 - 09:24
cyrilt

I have the exact same issue. But I noticed it runs fine on PHP 7.2 but as soon as I update something on virtualmin everything gets messed up. I didn't check on 7.0.

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

Same problem here, all PHP files are downloading instead executing

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 - 11:39 (Reply to #4)
cyrilt

finally some hope! :D Would you please be able to elaborate on it?

Tue, 05/29/2018 - 08:02
cyrilt

I found a way.

I edited the conf file for the relevant php

sudo nano /etc/apache2/mods-available/php7.2.conf

and commented out: SetHandler application/x-httpd-php

and it worked

Fri, 01/04/2019 - 14:42
sz00gun

@cyrilt I had the same problem, however it works for me too. (your fix)

Let's do more tests now... Ps. did you get more problems? all works fine for you? PHP7.2 on Ubuntu 16.04?

Sat, 01/05/2019 - 16:59
ADDISON74

You should check the following (Debian 8 and 9):

  • Check if php7.0-cgi is installed. Command for this is:, apt install php7.0-cgi

  • Disable php apache module: a2dismod php7.0 and restart apache service. If php_mod is enabled you cannot use your particular php.ini of your vhost. Just create a php file in your website root and use phpinfo() inside it. Load the file in browser. If it says Server API = CGI/FastCGI and Loaded Configuration File = /home/[your_name]/etc/php7.0/php.ini this is a good vhost configuration.

  • Check the file content /etc/apache2/sites-available/[your_website].conf for FCGIWrapper directives. Comment the lines which refer to PHP 5 in case you have them and leave only for PHP 7. Also comment the lines which start with php. We disabled the apache php_mod before.

  • Check if /home/[your_name]/etc/php7.0 folder exists. Also if it has inside a php.ini file. If not create it with the content from /usr/lib/php/7.0/php.ini-production (the path could be different).

  • Check if /home/[your_name]/fcgi/php7.0.fcgi file exists. If not create it with the following content:

!/bin/bash

PHPRC=$PWD/../etc/php7.0 <-- this folder should exist export PHPRC umask 022 export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=99999 export PHP_FCGI_MAX_REQUESTS exec /usr/bin/php-cgi7.0 <-- this file should exist

Once you save it use the following command chattr +i php7.0.fcgi. This will protect this file from changes. If you want to edit it use the same command with -i.

Please note I used php7.0.fcgi as file name. You will find this name in /etc/apache2/sites-available/[your_host].conf. It should be like this.

FCGIWrapper /home/[your_name]/fcgi-bin/php7.0.fcgi .php FCGIWrapper /home/[your_name]/fcgi-bin/php7.0.fcgi .php7.0

Restart apache service and load website in browser. It should work.

All the files should have the owner and group of your vhost. If your created as root it will create trouble.

Virtualmin is working fine with one PHP version from the very beginning. If you have 5.6 and 7.x over a while all changes should be made manually. Virtualmin is keeping the setting for both versions in a vhost and this will create trouble. Virtualmin is missing php.ini for PHP 7. It took me 3 hours to fix a server for a client who updated for Debian 7 to 8 and wanted PHP 5.6 and 7 same time for different vhosts. Virtualmin is creating trouble when setting up PHP Versions. Avoid for a while this feature.

Sat, 01/05/2019 - 17:38
hescominsoon

i am guessing you folks are using the Ubuntu ppa to extend ubuntu's php capabilities....unfortunately this places Ubuntu out of its default state..once you "fix" it the next time you run apt to update virt it is going to overwrite with it's configs..now you have a broken mess in terms of PHP and Apache. Extending PHP in cent is much easier because remi's repo doesn't mess with any Apache files..unlike Ubuntu ppa. I have a cent 7 server that has php 5.4, 5.5, 5.6, 7.0 all at the same time..easily..because the third party repos do not screw with the apache configs. upgrading sql in cent puts me in the same mess with databases as upgrading php does in ubuntu. I would HIGHLY suggest if you are using 16.04 to NOT use the ppa to try to get anything other than php 7.0 until Ubuntu releases official packages for it. I am waiting for the 18.04 branch to become officially supported then i am going to backup virt...pave the server..and then restore into it's base default PHP 7.2.x series. If you want faster updates use Debian but you will be reloading every 18-24 months.

Sat, 01/05/2019 - 18:34
hescominsoon

actually forget remi's for php in cent it's the software collections repo which is provided by cent themselves.

Sat, 01/05/2019 - 21:18
andreychek

Howdy,

I just wanted to share Virtualmin's recommended way of adding additional PHP versions, that can be seen here:

https://www.virtualmin.com/documentation/web/multiplephp

If anyone is seeing an issue with it downloading PHP code, rather than executing it, it's likely just an issue with a SetHandler line in the Apache config. That can be fixed with this here:

https://www.virtualmin.com/documentation/system/faq#toc-why-does-php--pr...

Lastly, note that we advise caution in using the REMI repo. While some do use that successfully, we have seen issues come up with it. If you want to go that direction, perhaps try it out on a test server before setting it up on your production system.

-Eric

Sun, 01/06/2019 - 10:12 (Reply to #11)
hescominsoon

also in 16.04 using the ppa to extend php is causing issues with virt and apache..hence my request for on ubuntu virt to manage php directly in it's own repo so we do not have to worry about ppa screwing with virt's apache configuration.

Sun, 01/06/2019 - 10:10
hescominsoon

yes i would like to see the virtualmin installer use the software collections repo and add the latest php AND mysql that are available in said repo. adding the php versions is easy..but upgrading mysql..not so much. It would be great if virt on cent would use scl and automatically install mysql 5.7 at least and the latest php that is available.

Tue, 10/22/2019 - 15:31
paul_intermediatica

In my case, I could Fix it with this thread:

https://www.virtualmin.com/node/57448

Paul Marti interMediática MX

Topic locked