How to use PHP7 on a web site and older PHP on another web site?

19 posts / 0 new
Last post
#1 Fri, 11/02/2018 - 10:25
virtualpaul

How to use PHP7 on a web site and older PHP on another web site?

Hi,

I am using debian 9 and virtualmin.

I am trying to migrate one web site to PHP7 but I want the other web sites to keep using whatever PHP they are using.

I first installed the php7 using this:

   aptitude install php7.0 php7.0-mysql php7.0-cgi
   aptitude install libapache2-mod-php7.0
   /etc/init.d/apache2 restart

When I go here

           
Virtualmin -> Server Configuration -> PHP Versions:

I see:

            This virtual server is using the mod_php or FPM execution mode for PHP, such does not allow per-directory version selection.

So I tried to fix this using:


Virtualmin -> Server Configuration -> Website Options:
               PHP script execution mode [X] Apache CGI

But then I get 'Internal Server Error' when I load the web site.

In the log, I see this:

... AH01215: suexec policy violation: see suexec log for more details: ...
... End of script output before headers: php7.0.cgi

Not sure what to do next.

Sat, 11/03/2018 - 18:17
marcelorp

Did you run the 'Recheck Configuration'? What is the output?

And what are the permissions of the folders and php files on that website wich you trying to run PHP7?

Mon, 11/05/2018 - 07:01
virtualpaul

I did not change any permissions when adding PHP7.
The individual files seem to be 0644 and the folders are 0755. PHP5.x is running fine with the current permissions.
Do I need to change the permissions before PHP7 can run?

Here is what I think are the relevant output of 'Recheck Configuration' :

Apache is installed.
The following PHP versions are available : 5.6.30 (/usr/bin/php5-cgi), 7.0.30 (/usr/bin/php-cgi7.0), 5.6 (mod_php)
PHP-FPM support was not detected : No FPM configuration directory found
Apache is configured to host SSL websites.
MySQL is installed and running.
The selected package management and update systems are installed OK.

.. your system is ready for use by Virtualmin.

Mon, 11/05/2018 - 08:21
marcelorp

see suexec log for more details: ... Did you have access to that log?

Mon, 11/05/2018 - 11:01
virtualpaul

Sorry no. I am not sure where this suexec log is located... I am using debian 9.

Mon, 11/05/2018 - 13:27
marcelorp

Did you check here:
https://www.virtualmin.com/node/37098

Its for CentOS, but may be it can help you. I just use CentOS, never used other OS before, so I can't help with that. But finding the log, it will make easier to solve your problem. I think...

Tue, 11/06/2018 - 07:28
virtualpaul

The more I read, the more I get mixed up...

I tried 'suexec -V' to see the default log folder but I got: bash: suexec: command not found

But when I tried to enable it in apache using 'a2enmod suexec', I got: Module suexec already enabled

I read in many posts that people having suexec problem means that their apache does not come from the virtualmin repository.
So I updated my '/etc/apt/sources.list' to point to virtualmin:

deb http://software.virtualmin.com/vm/6/gpl/apt virtualmin-stretch main
deb http://software.virtualmin.com/vm/6/gpl/apt virtualmin-universal main

Then I did this as suggested:

wget http://software.virtualmin.com/lib/RPM-GPG-KEY-virtualmin-6
apt-key add RPM-GPG-KEY-virtualmin-6

The above allowed me to update webmin/virtualmin from virtualmin. But then a new error message appeared:

Your system's primary IP address appears to have changed from xx.xx.xx.xx to yy.yy.yy.yy Virtual servers using the old address may be unreachable or serve the wrong web content.
and
The Suexec command on your system is configured to only run scripts under /var/www, but the Virtualmin virtual server home directory is /home. CGI and PHP scripts run as domain owners will not be executed.

I tried this also just to be sure 'aptitude install apache2' and I got: apache2 is already installed at the requested version (2.4.25-3+deb9u5)

So I am not sure how to update 'apache2'. I saw many post where people lose their web sites by reinstalling apache.
I am guessing this is a pretty standard problem since when you first install a linux server, you get asked if you want to install apache so most people would install it...

I also did this: Virtualmin -> System Settings -> Server Templates -> Default Settings -> Apache Website Automatically add appropriate SuExec directive [yes]

I retried 'Virtualmin -> Server Configuration -> Website Options: PHP script execution mode [X] Apache CGI' but this time I got: Failed to save website options : The Suexec command on your system is configured to only run scripts under /var/www, but the Virtualmin virtual server home directory is /home. CGI and PHP scripts run as domain owners will not be executed.

Tue, 11/06/2018 - 07:39
marcelorp

Did you have some files in /etc/apache2/suexec? Like www-data?

Tue, 11/06/2018 - 08:18
virtualpaul

Yes. www-data is present and ww-data.dpkg-old is also present but nothing else.

Thanks for helping me!

Tue, 11/06/2018 - 08:20
marcelorp

Post the content of this files here. And try to add a new line with /home/ save the file and restart apache. So try to recheck the virtualmin configuration.

Tue, 11/06/2018 - 08:49
virtualpaul

The files were both empty.

I tried adding the following in www-data: /home/ I restarted apache and did the recheck but got the same error: The Suexec command on your system is configured to only run scripts under /var/www, but the Virtualmin virtual server home directory is /home. CGI and PHP scripts run as domain owners will not be executed.

I retried with just '/home' without the '/' at the end but got the same error.

Tue, 11/06/2018 - 09:01
marcelorp

Try this:

apt-get install apache2-suexec-custom

Edit /etc/apache2/suexec/www-data

/home
public_html/cgi-bin
# The first two lines contain the suexec document root and the suexec userdir
# suffix. Both features can be disabled separately by prepending a # character.
# This config file is only used by the apache2-suexec-custom package.


If not fix, try to Disable the option Automatically add appropriate SuExec directive? under Virtualmin -> System Settings -> Server Template -> Default Settings -> Apache website

Tue, 11/06/2018 - 12:20 (Reply to #12)
virtualpaul

marcelorp, thanks a lot for your help! It is working now. (see at the bottom of this thread).

Tue, 11/06/2018 - 09:25
virtualpaul

I tried the first part 'apache2-suexec-custom' but that did not change anything. I was still getting the error: The Suexec command on your system is configured to only run scripts under /var/www, but the Virtualmin virtual server home directory is /home. CGI and PHP scripts run as domain owners will not be executed.

The option 'Automatically add appropriate SuExec directive?' set to no seems to get rid of that message though.

So I retried the original option at the top of the post: Virtualmin -> Server Configuration -> Website Options: PHP script execution mode [X] Apache CGI

But I still get 'Internal Server Error' when I load the web site using this option.

In the log, I still see this:

... AH01215: suexec policy violation: see suexec log for more details: ...
... End of script output before headers: php7.0.cgi

I still don't know where the suexec log is located... I retried 'suexec -V' but got this again: bash: suexec: command not found

Tue, 11/06/2018 - 09:38
marcelorp

I really dont know how to fix. Did you try to remove all apache package and reinstall then with virtualmin repo? You Virtualmin installation, how did you install? On fresh system? By installer?

Tue, 11/06/2018 - 09:45
jimdunn

[ I am not an employee of Webmin, just a satisfied customer ]

@virtualpaul, in case no one mentioned this, just an FYI:

1) if you need "multiple PHP" in a production environment, you should use CentOS since that is the only "approved" method.

2) Virtualmin on Debian with multiple PHP is "possible" but requires workarounds that are non-approved for production use.

Tue, 11/06/2018 - 09:58 (Reply to #16)
virtualpaul

Thanks for the info.

Do you remember a link for '1)' or '2)'? Maybe there is some explanation that could help me fix the problem.

I thought PHP was just an interpreter called when processing a web page. I am having difficulties understanding why a specific OS would be needed for this.

Tue, 11/06/2018 - 09:48
marcelorp

I really dont know this...but I never used other SO than CentOS, so can be because of this that I cant help the member.

Tue, 11/06/2018 - 09:50
virtualpaul

No I did not reinstall apache. According to a post I read by Joe, just doing 'apt-get install apache2' would probably work. Is there a safe way to do this apache reinstall?

I installed Virtualmin many years ago using this:

wget http://software.virtualmin.com/gpl/scripts/install.sh
chmod +x install.sh
./install.sh

Is there an order for the repository in /etc/apt/sources.list since I put the virtualmin repository at first thinking it would take precedence. But perhaps I have to put it at the end? I mean that if there are more than one source for apache, how does aptitude know which one to take.

Also, I found the location of suexec log: /var/log/apache2/suexec.log The error says: command not in docroot (/home/...

So the '/home' I added in '/etc/apache2/www-data' does not seem to work. Any idea why?

[EDIT] Ok it was a typo on my part, I changed the folder to '/home' in '/etc/apache2/suexec/www-data' and now it works...

Also I finally found where is suexec on debian so '/usr/lib/apache2/suexec -V' works and I can see the its configuration now.

Topic locked