Submitted by lewisjenkins on Sat, 01/09/2016 - 18:56
Ubuntu 14.04 standard install, been running fine for months. Updated to latest Virtualmin 5.0 and system fully up to date.
I upgraded to PHP7 using the following tutorial:
https://www.digitalocean.com/community/tutorials/how-to-upgrade-to-php-7...
PHP7 is working, but Apache is now running as www-data instead of the virtual server owner, which breaks existing sites. Fortunately this is not a production server (I made a copy for testing), so no harm done. But I would like to get this working properly. Can you help?
Additional info: Re-checking Virtualmin config doesn't show any problems. Also, I see another person on the forum has the exact same issue:
Status:
Active
Comments
Submitted by andreychek on Sat, 01/09/2016 - 19:04 Comment #1
Howdy -- there's likely a config file that was installed by the new PHP packages that's causing a problem.
If you go into System Settings -> Re-Check Config, does it detect any PHP-related errors?
Submitted by lewisjenkins on Sat, 01/09/2016 - 19:20 Comment #2
Re-checking Virtualmin config doesn't show any problems. The system is ready for use by Virtualmin.
Submitted by andreychek on Sat, 01/09/2016 - 19:30 Comment #3
Okay, what is the output of this command:
find /etc/apache2/mods-enabled | xargs grep -i sethandler
Submitted by lewisjenkins on Sat, 01/09/2016 - 20:17 Comment #4
$ find /etc/apache2/mods-enabled | xargs grep -i sethandler
grep: /etc/apache2/mods-enabled: Is a directory
/etc/apache2/mods-enabled/proxy_balancer.conf: # SetHandler balancer-manager
/etc/apache2/mods-enabled/php7.0.conf: SetHandler application/x-httpd-php
/etc/apache2/mods-enabled/php7.0.conf: SetHandler application/x-httpd-php-source
/etc/apache2/mods-enabled/status.conf: SetHandler server-status
Submitted by andreychek on Sat, 01/09/2016 - 20:33 Comment #5
Ah, there we go... it looks like those packages installed a new config file for PHP7, located in "etc/apache2/mods-enabled/php7.0.conf".
In there, you would want to comment out the two "SetHandler" lines, as those can cause mod_php to override the other PHP handlers. After doing that, restart Apache, and then see if it begins working properly.
Submitted by lewisjenkins on Sat, 01/09/2016 - 20:48 Comment #6
That's caused the php code to show as text in the browser. For example, if I go to /phpinfo.php, the browser actually displays the following as plain text:
<?php phpinfo(); ?>
Submitted by dzappone on Sun, 01/10/2016 - 10:42 Comment #7
When this happened on one of my tests I had to go to each domain then Server Configuration --> Website Options and change PHP script execution mode back to FCGI.
Submitted by andreychek on Sun, 01/10/2016 - 10:50 Comment #8
Yeah that's an interesting question, what is the PHP Execution Mode currently set to for this domain?
Submitted by lewisjenkins on Mon, 01/11/2016 - 08:11 Comment #9
It's FastCGI. I've tried switching between different modes, and commenting / uncommenting the SetHandler lines, with various combinations but Apache always runs as www-data.
I'm not sure if this is significant, but in ~/etc there is a symlink to ~/etc/php7/php.ini, however the directory ~/etc/php7 does not exist.
Submitted by andreychek on Mon, 01/11/2016 - 12:52 Comment #10
The PHP config file it's pointing at shouldn't be the issue here.
Could you try disabling mod_php altogether, restart Apache, and then try accessing your site again?
When disabling mod_php, the "/etc/apache2/mods-enabled/php7.0.conf" file would be gone altogether... I'm wondering if something within that is causing a problem.
Another thought would be to try switching the PHP Execution Mode to CGI, just in case something with FCGID isn't working properly.
Submitted by lewisjenkins on Tue, 01/12/2016 - 07:21 Comment #11
I disabled mod_php and restarted Apache, and this got rid of the php7.0.conf file as you said.
Trying to run as FastCGI doesn't work, I get a 500 error. This is the error in the Apache logs:
[Tue Jan 12 12:48:52.275523 2016] [fcgid:warn] [pid 6956] (104)Connection reset by peer: [client 86.139.10.174:63538] mod_fcgid: error reading data from FastCGI server
[Tue Jan 12 12:48:52.275586 2016] [core:error] [pid 6956] [client 86.139.10.174:63538] End of script output before headers: phpinfo.php
So, I tried switching to CGI mode. This also doesn't work, and I get the following error in the browser:
The requested URL /cgi-bin/php7.0.cgi/phpinfo.php was not found on this server.
Submitted by lewisjenkins on Tue, 01/12/2016 - 13:18 Comment #12
OK, I've managed to get this working. It turns out that when installing PHP7, there are some extra packages required. In this case in was php7.0-cgi that was missing.
For the record, this works for me on Ubuntu 14.04.
sudo add-apt-repository ppa:ondrej/php-7.0
sudo apt-get update
sudo apt-get install php7.0
sudo apt-get install php7.0-cgi
sudo apt-get install php7.0-mysql
sudo apt-get install php7.0-mcrypt
sudo apt-get install php7.0-gd
sudo apt-get install php7.0-curl
sudo reboot
ALSO I had to disable mod_php
sudo a2dismod php7\.0
Thanks for your help with this.
Submitted by andreychek on Tue, 01/12/2016 - 12:00 Comment #13
Aha! I'm glad you figured that out, as I was getting pretty puzzled :-)
Thanks for sharing how you got it working!
Submitted by lewisjenkins on Wed, 01/13/2016 - 05:30 Comment #14
Actually, it turns out this isn't entirely fixed after all. Since I managed to get the first Virtual Server working, any subsequent Virtual Servers that have been added since are not working.
Currently, I have two newly created Virtual Servers - test.com and test2.com. Both have a single file public_html/index.php which contains <?php phpinfo(); ?>.
test.com - works fine.
test2.com - not working, with the following errors:
[Wed Jan 13 11:17:00.971035 2016] [fcgid:warn] [pid 1990] (104)Connection reset by peer: [client 86.139.10.174:53870] mod_fcgid: error reading data from FastCGI server
[Wed Jan 13 11:17:00.971114 2016] [core:error] [pid 1990] [client 86.139.10.174:53870] End of script output before headers: index.php
I've been through everything, and cannot find any configuration differences between the two Virtual Servers. And yet, only one of them is working :(
Submitted by andreychek on Wed, 01/13/2016 - 09:41 Comment #15
Can you try changing the PHP Execution Mode to CGI again, to see if it's still the same error you saw previously?
CGI produces better errors than FCGID, so that'll give us a better idea of what's going awry.
Submitted by lewisjenkins on Wed, 01/13/2016 - 18:25 Comment #16
I changed the test2.com server to CGI mode.
The browser now displays this:
"Not Found - The requested URL /cgi-bin/php7.0.cgi/index.php was not found on this server."
Submitted by dzappone on Thu, 01/21/2016 - 09:18 Comment #17
Hi - I wrote a tutorial on getting Ubuntu 14.04 working with PHP 5.6.x and 7.0.x with Virtualmin 5gpl. You can see it here:
https://www.23systems.net/2016/01/installing-php-5-6-x-7-0-x-ubuntu-14-04-virtualmin-5-0gpl-using-ppa/
It might have the answers you are looking for.
Submitted by Tonym2323 on Thu, 05/19/2016 - 13:47 Comment #18
I got PHP7 to work on Centos 7.2.1511 with nginx https2 and WOW I couldn't be happier, my wordpress site is loading freakishly fast 3x faster even with a bunch of plugins activated.
I ended up going with ius repo since centos says its ok https://wiki.centos.org/AdditionalResources/Repositories and these are the commands I used.
cd ~ curl 'https://setup.ius.io/' -o setup-ius.sh
bash setup-ius.sh
yum remove php-fpm php-cli php-common (when i used apache I didn't have to remove php 5.4 but with nginx I couldn't get it to use php7 no matter what I did)
yum install php70u-fpm-nginx php70u-cli php70u-mysqlnd
yum install php70u-cli.x86_64 php70u-common.x86_64 php70u-fpm.x86_64 php70u-gd.x86_64 php70u-mbstring.x86_64 php70u-mcrypt.x86_64 php70u-mysqlnd.x86_64 php70u-opcache.x86_64 php70u-pdo.x86_64 php70u-pear.noarch php70u-process.x86_64 php70u-xml.x86_64 php70u-xmlrpc.x86_64 php70u-json.x86_64 php70u-imap.x86_64 php70u-gmp.x86_64 php70u-bcmath.x86_64 php70u-pecl-apcu.x86_64 php70u-pecl-imagick.x86_64 php70u-soap.x86_64 php70u-tidy.x86_64
I am new to Virtualmin (came from cpanel was constantly being attacked) friend recommend Virtualmin with changed default ports and I've become a true believer! I've been testing this dev server for about 3 weeks now and I'm planning to move it to a production server if it continues to run this good.
Submitted by petertjuh on Thu, 08/25/2016 - 04:35 Comment #19
oops, messed up.... https://www.virtualmin.com/node/41821
Submitted by hescominsoon on Thu, 08/25/2016 - 07:12 Pro Licensee Comment #20
The IUS repo is not supported nor provided by Centos. Just because it is on the wiki does not mean centos endorses it. In face there is this specific statement above that section that lists potential third party repos for centos:
WARNING: These repositories are not provided nor supported by CentOS. The CentOS project has no control over these sites. Many have their own mailing lists, IRC channels, issue trackers, etc. for support issues with their packages.
If you get php7 to work with centos ...great. If not then you will need to remove them and go back to php provided by centos.....