Mailing List Archive

Running php 7.0 and 7.2 for different websites with apache
Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.

I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:

<VirtualHost *:80>
        ServerAdmin xxx
        ServerName x.x.x.x/site1
        DocumentRoot /var/www/html/
        DirectoryIndex info.php
        ErrorLog /var/log/httpd/site1-error.log
        CustomLog /var/log/httpd/site1-access.log combined

    <IfModule !mod_php7.c>
        <FilesMatch \.(php|phar)$>
            SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
        </FilesMatch>
    </IfModule>
</VirtualHost>

The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.

I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.

I must have missed some configuration step and would appreciate any pointers.

Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
Hello,

You mention PHP is set to listen to different tcp ports, yet the
config you show from apache points to a unix socket with
mod_proxy_fcgi

Also worth mentioning you don't need php7_module at all when pointing
to FPM with mod_proxy_fcgi, so I would just unload that module asap in
case you have some other config lying around taking precedence and
causing the problems you mention.

Cheers

El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
>
> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
>
> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
>
> <VirtualHost *:80>
> ServerAdmin xxx
> ServerName x.x.x.x/site1
> DocumentRoot /var/www/html/
> DirectoryIndex info.php
> ErrorLog /var/log/httpd/site1-error.log
> CustomLog /var/log/httpd/site1-access.log combined
>
> <IfModule !mod_php7.c>
> <FilesMatch \.(php|phar)$>
> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
> </FilesMatch>
> </IfModule>
> </VirtualHost>
>
> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
>
> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
>
> I must have missed some configuration step and would appreciate any pointers.
>
> Thank you.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


--
Daniel Ferradal
HTTPD Project
#httpd help at Freenode

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
> Hello,
>
> You mention PHP is set to listen to different tcp ports, yet the
> config you show from apache points to a unix socket with
> mod_proxy_fcgi
>
> Also worth mentioning you don't need php7_module at all when pointing
> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
> case you have some other config lying around taking precedence and
> causing the problems you mention.
>
> Cheers
>
> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
>>
>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
>>
>> <VirtualHost *:80>
>> ServerAdmin xxx
>> ServerName x.x.x.x/site1
>> DocumentRoot /var/www/html/
>> DirectoryIndex info.php
>> ErrorLog /var/log/httpd/site1-error.log
>> CustomLog /var/log/httpd/site1-access.log combined
>>
>> <IfModule !mod_php7.c>
>> <FilesMatch \.(php|phar)$>
>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
>> </FilesMatch>
>> </IfModule>
>> </VirtualHost>
>>
>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
>>
>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
>>
>> I must have missed some configuration step and would appreciate any pointers.
>>
>> Thank you.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?

     SetHandler "proxy:fcgi://localhost:9002
     ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
     AddHandler php70-fcgi .php
     Action php70-fcgi /cgi-bin/php70.fcgi


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
Hello,

What you must remove is all scriptalias, addhandler/action directives.
So I'd say with a directive for each virtualhost you mentioned you
have you just would need (and of course disable mod_php module):

In one for one version pointing to 9002 port:
<FilesMatch \.(php|phar)$>
SetHandler "proxy:fcgi://localhost:9002"
</FilesMatch>

In the other virtualhost you want to have pointing to 9003:
<FilesMatch \.(php|phar)$>
SetHandler "proxy:fcgi://localhost:9003"
</FilesMatch>

Apache is really much more simple and easier than many examples out
there try to show.

El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
>
> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
> > Hello,
> >
> > You mention PHP is set to listen to different tcp ports, yet the
> > config you show from apache points to a unix socket with
> > mod_proxy_fcgi
> >
> > Also worth mentioning you don't need php7_module at all when pointing
> > to FPM with mod_proxy_fcgi, so I would just unload that module asap in
> > case you have some other config lying around taking precedence and
> > causing the problems you mention.
> >
> > Cheers
> >
> > El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
> >> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
> >>
> >> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
> >>
> >> <VirtualHost *:80>
> >> ServerAdmin xxx
> >> ServerName x.x.x.x/site1
> >> DocumentRoot /var/www/html/
> >> DirectoryIndex info.php
> >> ErrorLog /var/log/httpd/site1-error.log
> >> CustomLog /var/log/httpd/site1-access.log combined
> >>
> >> <IfModule !mod_php7.c>
> >> <FilesMatch \.(php|phar)$>
> >> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
> >> </FilesMatch>
> >> </IfModule>
> >> </VirtualHost>
> >>
> >> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
> >>
> >> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
> >>
> >> I must have missed some configuration step and would appreciate any pointers.
> >>
> >> Thank you.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >> For additional commands, e-mail: users-help@httpd.apache.org
> >>
> >
> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
>
> SetHandler "proxy:fcgi://localhost:9002
> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
> AddHandler php70-fcgi .php
> Action php70-fcgi /cgi-bin/php70.fcgi
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


--
Daniel Ferradal
HTTPD Project
#httpd help at Freenode

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
> Hello,
>
> What you must remove is all scriptalias, addhandler/action directives.
> So I'd say with a directive for each virtualhost you mentioned you
> have you just would need (and of course disable mod_php module):
>
> In one for one version pointing to 9002 port:
> <FilesMatch \.(php|phar)$>
> SetHandler "proxy:fcgi://localhost:9002"
> </FilesMatch>
>
> In the other virtualhost you want to have pointing to 9003:
> <FilesMatch \.(php|phar)$>
> SetHandler "proxy:fcgi://localhost:9003"
> </FilesMatch>
>
> Apache is really much more simple and easier than many examples out
> there try to show.
>
> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
>>> Hello,
>>>
>>> You mention PHP is set to listen to different tcp ports, yet the
>>> config you show from apache points to a unix socket with
>>> mod_proxy_fcgi
>>>
>>> Also worth mentioning you don't need php7_module at all when pointing
>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
>>> case you have some other config lying around taking precedence and
>>> causing the problems you mention.
>>>
>>> Cheers
>>>
>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
>>>>
>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
>>>>
>>>> <VirtualHost *:80>
>>>> ServerAdmin xxx
>>>> ServerName x.x.x.x/site1
>>>> DocumentRoot /var/www/html/
>>>> DirectoryIndex info.php
>>>> ErrorLog /var/log/httpd/site1-error.log
>>>> CustomLog /var/log/httpd/site1-access.log combined
>>>>
>>>> <IfModule !mod_php7.c>
>>>> <FilesMatch \.(php|phar)$>
>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
>>>> </FilesMatch>
>>>> </IfModule>
>>>> </VirtualHost>
>>>>
>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
>>>>
>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
>>>>
>>>> I must have missed some configuration step and would appreciate any pointers.
>>>>
>>>> Thank you.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>
>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
>>
>> SetHandler "proxy:fcgi://localhost:9002
>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
>> AddHandler php70-fcgi .php
>> Action php70-fcgi /cgi-bin/php70.fcgi
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
This is what I did:

- I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/librh-php70-php7.so" in the former and the equivalent in the latter.

- For the the site1.conf I have:

<VirtualHost *:80>
        ServerAdmin xxx
        ServerName x.x.x.x
        DocumentRoot /var/www/html/
        ErrorLog /var/log/httpd/site1-error.log
        CustomLog /var/log/httpd/site1-access.log combined

        <FilesMatch \.(php|phar)$>
                SetHandler "proxy:fcgi://localhost:9002"
        </FilesMatch>
</VirtualHost>

and for site2.conf

<VirtualHost *:80>
        ServerAdmin xxx
        ServerName x.x.x.x
        DocumentRoot /var/www/html/
        ErrorLog /var/log/httpd/site2-error.log
        CustomLog /var/log/httpd/site2-access.log combined

        <FilesMatch \.(php|phar)$>
                SetHandler "proxy:fcgi://localhost:9003"
        </FilesMatch>
</VirtualHost>

- I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.

Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.

So, there must be something more I need to do?

Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
On 04/08/2021 07:34 PM, H wrote:
> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
>> Hello,
>>
>> What you must remove is all scriptalias, addhandler/action directives.
>> So I'd say with a directive for each virtualhost you mentioned you
>> have you just would need (and of course disable mod_php module):
>>
>> In one for one version pointing to 9002 port:
>> <FilesMatch \.(php|phar)$>
>> SetHandler "proxy:fcgi://localhost:9002"
>> </FilesMatch>
>>
>> In the other virtualhost you want to have pointing to 9003:
>> <FilesMatch \.(php|phar)$>
>> SetHandler "proxy:fcgi://localhost:9003"
>> </FilesMatch>
>>
>> Apache is really much more simple and easier than many examples out
>> there try to show.
>>
>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
>>>> Hello,
>>>>
>>>> You mention PHP is set to listen to different tcp ports, yet the
>>>> config you show from apache points to a unix socket with
>>>> mod_proxy_fcgi
>>>>
>>>> Also worth mentioning you don't need php7_module at all when pointing
>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
>>>> case you have some other config lying around taking precedence and
>>>> causing the problems you mention.
>>>>
>>>> Cheers
>>>>
>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
>>>>>
>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
>>>>>
>>>>> <VirtualHost *:80>
>>>>> ServerAdmin xxx
>>>>> ServerName x.x.x.x/site1
>>>>> DocumentRoot /var/www/html/
>>>>> DirectoryIndex info.php
>>>>> ErrorLog /var/log/httpd/site1-error.log
>>>>> CustomLog /var/log/httpd/site1-access.log combined
>>>>>
>>>>> <IfModule !mod_php7.c>
>>>>> <FilesMatch \.(php|phar)$>
>>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
>>>>> </FilesMatch>
>>>>> </IfModule>
>>>>> </VirtualHost>
>>>>>
>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
>>>>>
>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
>>>>>
>>>>> I must have missed some configuration step and would appreciate any pointers.
>>>>>
>>>>> Thank you.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>
>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
>>>
>>> SetHandler "proxy:fcgi://localhost:9002
>>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
>>> AddHandler php70-fcgi .php
>>> Action php70-fcgi /cgi-bin/php70.fcgi
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>
> This is what I did:
>
> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/librh-php70-php7.so" in the former and the equivalent in the latter.
>
> - For the the site1.conf I have:
>
> <VirtualHost *:80>
>         ServerAdmin xxx
>         ServerName x.x.x.x
>         DocumentRoot /var/www/html/
>         ErrorLog /var/log/httpd/site1-error.log
>         CustomLog /var/log/httpd/site1-access.log combined
>
>         <FilesMatch \.(php|phar)$>
>                 SetHandler "proxy:fcgi://localhost:9002"
>         </FilesMatch>
> </VirtualHost>
>
> and for site2.conf
>
> <VirtualHost *:80>
>         ServerAdmin xxx
>         ServerName x.x.x.x
>         DocumentRoot /var/www/html/
>         ErrorLog /var/log/httpd/site2-error.log
>         CustomLog /var/log/httpd/site2-access.log combined
>
>         <FilesMatch \.(php|phar)$>
>                 SetHandler "proxy:fcgi://localhost:9003"
>         </FilesMatch>
> </VirtualHost>
>
> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
>
> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
>
> So, there must be something more I need to do?
>
> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
>
How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?

I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.

And I restarted httpd after each change.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
There is no such thing as default php version for a site.

You have to make sure you have really two different instances of
php-fpm running for the different php versions you want to use.

Chances are you have the same php-fpm service with two pools, so both
may be with the same version.

Apache doesn't care what you do from now on, since it is just reverse
proxying requests to the selected servers. So it is up to you and your
php-fpm config and how you start them now.

El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribió:
>
> On 04/08/2021 07:34 PM, H wrote:
> > On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
> >> Hello,
> >>
> >> What you must remove is all scriptalias, addhandler/action directives.
> >> So I'd say with a directive for each virtualhost you mentioned you
> >> have you just would need (and of course disable mod_php module):
> >>
> >> In one for one version pointing to 9002 port:
> >> <FilesMatch \.(php|phar)$>
> >> SetHandler "proxy:fcgi://localhost:9002"
> >> </FilesMatch>
> >>
> >> In the other virtualhost you want to have pointing to 9003:
> >> <FilesMatch \.(php|phar)$>
> >> SetHandler "proxy:fcgi://localhost:9003"
> >> </FilesMatch>
> >>
> >> Apache is really much more simple and easier than many examples out
> >> there try to show.
> >>
> >> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
> >>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
> >>>> Hello,
> >>>>
> >>>> You mention PHP is set to listen to different tcp ports, yet the
> >>>> config you show from apache points to a unix socket with
> >>>> mod_proxy_fcgi
> >>>>
> >>>> Also worth mentioning you don't need php7_module at all when pointing
> >>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
> >>>> case you have some other config lying around taking precedence and
> >>>> causing the problems you mention.
> >>>>
> >>>> Cheers
> >>>>
> >>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
> >>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
> >>>>>
> >>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
> >>>>>
> >>>>> <VirtualHost *:80>
> >>>>> ServerAdmin xxx
> >>>>> ServerName x.x.x.x/site1
> >>>>> DocumentRoot /var/www/html/
> >>>>> DirectoryIndex info.php
> >>>>> ErrorLog /var/log/httpd/site1-error.log
> >>>>> CustomLog /var/log/httpd/site1-access.log combined
> >>>>>
> >>>>> <IfModule !mod_php7.c>
> >>>>> <FilesMatch \.(php|phar)$>
> >>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
> >>>>> </FilesMatch>
> >>>>> </IfModule>
> >>>>> </VirtualHost>
> >>>>>
> >>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
> >>>>>
> >>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
> >>>>>
> >>>>> I must have missed some configuration step and would appreciate any pointers.
> >>>>>
> >>>>> Thank you.
> >>>>>
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>>
> >>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
> >>>
> >>> SetHandler "proxy:fcgi://localhost:9002
> >>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
> >>> AddHandler php70-fcgi .php
> >>> Action php70-fcgi /cgi-bin/php70.fcgi
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>
> > This is what I did:
> >
> > - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/librh-php70-php7.so" in the former and the equivalent in the latter.
> >
> > - For the the site1.conf I have:
> >
> > <VirtualHost *:80>
> > ServerAdmin xxx
> > ServerName x.x.x.x
> > DocumentRoot /var/www/html/
> > ErrorLog /var/log/httpd/site1-error.log
> > CustomLog /var/log/httpd/site1-access.log combined
> >
> > <FilesMatch \.(php|phar)$>
> > SetHandler "proxy:fcgi://localhost:9002"
> > </FilesMatch>
> > </VirtualHost>
> >
> > and for site2.conf
> >
> > <VirtualHost *:80>
> > ServerAdmin xxx
> > ServerName x.x.x.x
> > DocumentRoot /var/www/html/
> > ErrorLog /var/log/httpd/site2-error.log
> > CustomLog /var/log/httpd/site2-access.log combined
> >
> > <FilesMatch \.(php|phar)$>
> > SetHandler "proxy:fcgi://localhost:9003"
> > </FilesMatch>
> > </VirtualHost>
> >
> > - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
> >
> > Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
> >
> > So, there must be something more I need to do?
> >
> > Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
> >
> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
>
> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
>
> And I restarted httpd after each change.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


--
Daniel Ferradal
HTTPD Project
#httpd help at Freenode

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
On 04/08/2021 08:57 PM, Daniel Ferradal wrote:
> There is no such thing as default php version for a site.
>
> You have to make sure you have really two different instances of
> php-fpm running for the different php versions you want to use.
>
> Chances are you have the same php-fpm service with two pools, so both
> may be with the same version.
>
> Apache doesn't care what you do from now on, since it is just reverse
> proxying requests to the selected servers. So it is up to you and your
> php-fpm config and how you start them now.
>
> El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribió:
>> On 04/08/2021 07:34 PM, H wrote:
>>> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
>>>> Hello,
>>>>
>>>> What you must remove is all scriptalias, addhandler/action directives.
>>>> So I'd say with a directive for each virtualhost you mentioned you
>>>> have you just would need (and of course disable mod_php module):
>>>>
>>>> In one for one version pointing to 9002 port:
>>>> <FilesMatch \.(php|phar)$>
>>>> SetHandler "proxy:fcgi://localhost:9002"
>>>> </FilesMatch>
>>>>
>>>> In the other virtualhost you want to have pointing to 9003:
>>>> <FilesMatch \.(php|phar)$>
>>>> SetHandler "proxy:fcgi://localhost:9003"
>>>> </FilesMatch>
>>>>
>>>> Apache is really much more simple and easier than many examples out
>>>> there try to show.
>>>>
>>>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
>>>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
>>>>>> Hello,
>>>>>>
>>>>>> You mention PHP is set to listen to different tcp ports, yet the
>>>>>> config you show from apache points to a unix socket with
>>>>>> mod_proxy_fcgi
>>>>>>
>>>>>> Also worth mentioning you don't need php7_module at all when pointing
>>>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
>>>>>> case you have some other config lying around taking precedence and
>>>>>> causing the problems you mention.
>>>>>>
>>>>>> Cheers
>>>>>>
>>>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
>>>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
>>>>>>>
>>>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
>>>>>>>
>>>>>>> <VirtualHost *:80>
>>>>>>> ServerAdmin xxx
>>>>>>> ServerName x.x.x.x/site1
>>>>>>> DocumentRoot /var/www/html/
>>>>>>> DirectoryIndex info.php
>>>>>>> ErrorLog /var/log/httpd/site1-error.log
>>>>>>> CustomLog /var/log/httpd/site1-access.log combined
>>>>>>>
>>>>>>> <IfModule !mod_php7.c>
>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
>>>>>>> </FilesMatch>
>>>>>>> </IfModule>
>>>>>>> </VirtualHost>
>>>>>>>
>>>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
>>>>>>>
>>>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
>>>>>>>
>>>>>>> I must have missed some configuration step and would appreciate any pointers.
>>>>>>>
>>>>>>> Thank you.
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>>
>>>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
>>>>>
>>>>> SetHandler "proxy:fcgi://localhost:9002
>>>>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
>>>>> AddHandler php70-fcgi .php
>>>>> Action php70-fcgi /cgi-bin/php70.fcgi
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>
>>> This is what I did:
>>>
>>> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/librh-php70-php7.so" in the former and the equivalent in the latter.
>>>
>>> - For the the site1.conf I have:
>>>
>>> <VirtualHost *:80>
>>> ServerAdmin xxx
>>> ServerName x.x.x.x
>>> DocumentRoot /var/www/html/
>>> ErrorLog /var/log/httpd/site1-error.log
>>> CustomLog /var/log/httpd/site1-access.log combined
>>>
>>> <FilesMatch \.(php|phar)$>
>>> SetHandler "proxy:fcgi://localhost:9002"
>>> </FilesMatch>
>>> </VirtualHost>
>>>
>>> and for site2.conf
>>>
>>> <VirtualHost *:80>
>>> ServerAdmin xxx
>>> ServerName x.x.x.x
>>> DocumentRoot /var/www/html/
>>> ErrorLog /var/log/httpd/site2-error.log
>>> CustomLog /var/log/httpd/site2-access.log combined
>>>
>>> <FilesMatch \.(php|phar)$>
>>> SetHandler "proxy:fcgi://localhost:9003"
>>> </FilesMatch>
>>> </VirtualHost>
>>>
>>> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
>>>
>>> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
>>>
>>> So, there must be something more I need to do?
>>>
>>> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
>>>
>> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
>>
>> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
>>
>> And I restarted httpd after each change.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
This is from ps aux | grep fpm:

root     17004  0.0  0.6 339008 11244 ?        Ss   01:18   0:00 php-fpm: master process (/etc/opt/rh/rh-php70/php-fpm.conf)
apache   17005  0.0  0.3 339112  7352 ?        S    01:18   0:00 php-fpm: pool www
apache   17006  0.0  0.3 339112  7356 ?        S    01:18   0:00 php-fpm: pool www
apache   17007  0.0  0.4 339252  8452 ?        S    01:18   0:00 php-fpm: pool www
apache   17008  0.0  0.3 339112  7360 ?        S    01:18   0:00 php-fpm: pool www
apache   17009  0.0  0.3 339112  7368 ?        S    01:18   0:00 php-fpm: pool www
root     17036  0.0  0.9 562800 18540 ?        Ss   01:18   0:00 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
apache   17037  0.0  0.3 562800  6976 ?        S    01:18   0:00 php-fpm: pool www
apache   17038  0.0  0.3 562800  6976 ?        S    01:18   0:00 php-fpm: pool www
apache   17039  0.0  0.3 562800  6976 ?        S    01:18   0:00 php-fpm: pool www
apache   17040  0.0  0.3 562800  6976 ?        S    01:18   0:00 php-fpm: pool www
apache   17041  0.0  0.3 562800  6980 ?        S    01:18   0:00 php-fpm: pool www

Does this not look correct?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
You're making this very difficult for yourself by having 2 different versions of PHP installed on 1 server box. Even if you get working maintaining will be challenging.

Suggestion- run PHP and PHP-FPM in separate Docker containers on same server, each with specific version of PHP you need. Then have Apache proxy to these containers as required
________________________________
From: H <agents@meddatainc.com>
Sent: Thursday, April 8, 2021 9:26 PM
To: users@httpd.apache.org <users@httpd.apache.org>
Subject: Re: [users@httpd] Running php 7.0 and 7.2 for different websites with apache

On 04/08/2021 08:57 PM, Daniel Ferradal wrote:
> There is no such thing as default php version for a site.
>
> You have to make sure you have really two different instances of
> php-fpm running for the different php versions you want to use.
>
> Chances are you have the same php-fpm service with two pools, so both
> may be with the same version.
>
> Apache doesn't care what you do from now on, since it is just reverse
> proxying requests to the selected servers. So it is up to you and your
> php-fpm config and how you start them now.
>
> El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribi?:
>> On 04/08/2021 07:34 PM, H wrote:
>>> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
>>>> Hello,
>>>>
>>>> What you must remove is all scriptalias, addhandler/action directives.
>>>> So I'd say with a directive for each virtualhost you mentioned you
>>>> have you just would need (and of course disable mod_php module):
>>>>
>>>> In one for one version pointing to 9002 port:
>>>> <FilesMatch \.(php|phar)$>
>>>> SetHandler "proxy:fcgi://localhost:9002"
>>>> </FilesMatch>
>>>>
>>>> In the other virtualhost you want to have pointing to 9003:
>>>> <FilesMatch \.(php|phar)$>
>>>> SetHandler "proxy:fcgi://localhost:9003"
>>>> </FilesMatch>
>>>>
>>>> Apache is really much more simple and easier than many examples out
>>>> there try to show.
>>>>
>>>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribi?:
>>>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
>>>>>> Hello,
>>>>>>
>>>>>> You mention PHP is set to listen to different tcp ports, yet the
>>>>>> config you show from apache points to a unix socket with
>>>>>> mod_proxy_fcgi
>>>>>>
>>>>>> Also worth mentioning you don't need php7_module at all when pointing
>>>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
>>>>>> case you have some other config lying around taking precedence and
>>>>>> causing the problems you mention.
>>>>>>
>>>>>> Cheers
>>>>>>
>>>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribi?:
>>>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
>>>>>>>
>>>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
>>>>>>>
>>>>>>> <VirtualHost *:80>
>>>>>>> ServerAdmin xxx
>>>>>>> ServerName x.x.x.x/site1
>>>>>>> DocumentRoot /var/www/html/
>>>>>>> DirectoryIndex info.php
>>>>>>> ErrorLog /var/log/httpd/site1-error.log
>>>>>>> CustomLog /var/log/httpd/site1-access.log combined
>>>>>>>
>>>>>>> <IfModule !mod_php7.c>
>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
>>>>>>> </FilesMatch>
>>>>>>> </IfModule>
>>>>>>> </VirtualHost>
>>>>>>>
>>>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
>>>>>>>
>>>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.digitalocean.com%2fcommunity%2ftutorials%2fhow-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7&c=E,1,nGU2QIv_y4smfnrUNnx9CDP8bkt1CgBCY00J7ykv7wIqnjBmryO1KuEik3Og-vkjZWpESUYdCo9JVJ3o77e7nOazFVuJCoH57Wvd5gM1XdQ,&typo=1 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
>>>>>>>
>>>>>>> I must have missed some configuration step and would appreciate any pointers.
>>>>>>>
>>>>>>> Thank you.
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>>
>>>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
>>>>>
>>>>> SetHandler "proxy:fcgi://localhost:9002
>>>>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
>>>>> AddHandler php70-fcgi .php
>>>>> Action php70-fcgi /cgi-bin/php70.fcgi
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>
>>> This is what I did:
>>>
>>> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flibrh-php70-php7.so&c=E,1,ObjWDSRkeobJmAvtgGDv7IZhOuViBCsywRH4WTkNPs2Zia5LKubUYQ80Kog5ge58me6QKtwGLdOjH_AqFDhPNxL5rUy39Dx47NdG4foHL0fSSrc,&typo=1" in the former and the equivalent in the latter.
>>>
>>> - For the the site1.conf I have:
>>>
>>> <VirtualHost *:80>
>>> ServerAdmin xxx
>>> ServerName x.x.x.x
>>> DocumentRoot /var/www/html/
>>> ErrorLog /var/log/httpd/site1-error.log
>>> CustomLog /var/log/httpd/site1-access.log combined
>>>
>>> <FilesMatch \.(php|phar)$>
>>> SetHandler "proxy:fcgi://localhost:9002"
>>> </FilesMatch>
>>> </VirtualHost>
>>>
>>> and for site2.conf
>>>
>>> <VirtualHost *:80>
>>> ServerAdmin xxx
>>> ServerName x.x.x.x
>>> DocumentRoot /var/www/html/
>>> ErrorLog /var/log/httpd/site2-error.log
>>> CustomLog /var/log/httpd/site2-access.log combined
>>>
>>> <FilesMatch \.(php|phar)$>
>>> SetHandler "proxy:fcgi://localhost:9003"
>>> </FilesMatch>
>>> </VirtualHost>
>>>
>>> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
>>>
>>> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
>>>
>>> So, there must be something more I need to do?
>>>
>>> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
>>>
>> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
>>
>> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
>>
>> And I restarted httpd after each change.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
This is from ps aux | grep fpm:

root 17004 0.0 0.6 339008 11244 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php70/php-fpm.conf)
apache 17005 0.0 0.3 339112 7352 ? S 01:18 0:00 php-fpm: pool www
apache 17006 0.0 0.3 339112 7356 ? S 01:18 0:00 php-fpm: pool www
apache 17007 0.0 0.4 339252 8452 ? S 01:18 0:00 php-fpm: pool www
apache 17008 0.0 0.3 339112 7360 ? S 01:18 0:00 php-fpm: pool www
apache 17009 0.0 0.3 339112 7368 ? S 01:18 0:00 php-fpm: pool www
root 17036 0.0 0.9 562800 18540 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
apache 17037 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
apache 17038 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
apache 17039 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
apache 17040 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
apache 17041 0.0 0.3 562800 6980 ? S 01:18 0:00 php-fpm: pool www

Does this not look correct?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
> This is from ps aux | grep fpm:
>
> root 17004 0.0 0.6 339008 11244 ? Ss 01:18 0:00 php-fpm: master process
> (/etc/opt/rh/rh-php70/php-fpm.conf)
> apache 17005 0.0 0.3 339112 7352 ? S 01:18 0:00 php-fpm: pool www
> apache 17006 0.0 0.3 339112 7356 ? S 01:18 0:00 php-fpm: pool www
> apache 17007 0.0 0.4 339252 8452 ? S 01:18 0:00 php-fpm: pool www
> apache 17008 0.0 0.3 339112 7360 ? S 01:18 0:00 php-fpm: pool www
> apache 17009 0.0 0.3 339112 7368 ? S 01:18 0:00 php-fpm: pool www
> root 17036 0.0 0.9 562800 18540 ? Ss 01:18 0:00 php-fpm: master process
> (/etc/opt/rh/rh-php72/php-fpm.conf)
> apache 17037 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> apache 17038 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> apache 17039 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> apache 17040 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> apache 17041 0.0 0.3 562800 6980 ? S 01:18 0:00 php-fpm: pool www
>
> Does this not look correct?


Yes. It seems correct.

This is just one way, there are many, but it would work:
# 1) disable mod_php
# 2) enable mod_proxy and mod_proxy_fcgi
# 3) create a file called php7.0-fpm.conf that will handle PHP7.0 requests

<IfModule proxy_fcgi_module>
# Enable http authorization headers
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"
# or if you prefer use TCP instead of UX socket
#SetHandler "proxy:fcgi://localhost:9002"
</FilesMatch>
</IfModule>

# 4) create a file called php7.2-fpm.conf that will handle PHP7.2 requests

<IfModule proxy_fcgi_module>
# Enable http authorization headers
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost"
# or if you prefer use TCP instead of UX socket
#SetHandler "proxy:fcgi://localhost:9003"
</FilesMatch>
</IfModule>

# 5) inside your virtualhosts, include the desired PHP conf file:
# eg: Include /yourconfpath/php7.2-fpm.conf

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
Looks correct yes. But still lots of things you are not showing could be wrong.

To solve issues you have to go one thing at a time, you know for sure
apache is pointing to different ports, if you disabled mod_php. Now
you must make sure the fpm pools are correct, both versions listening
to each port, that you disabled all mod_php stuff, etc. things we
can't see because you don't show, so it is quite hard to hand-guide
you with just small bits of info.

El vie, 9 abr 2021 a las 3:26, H (<agents@meddatainc.com>) escribió:
>
> On 04/08/2021 08:57 PM, Daniel Ferradal wrote:
> > There is no such thing as default php version for a site.
> >
> > You have to make sure you have really two different instances of
> > php-fpm running for the different php versions you want to use.
> >
> > Chances are you have the same php-fpm service with two pools, so both
> > may be with the same version.
> >
> > Apache doesn't care what you do from now on, since it is just reverse
> > proxying requests to the selected servers. So it is up to you and your
> > php-fpm config and how you start them now.
> >
> > El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribió:
> >> On 04/08/2021 07:34 PM, H wrote:
> >>> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
> >>>> Hello,
> >>>>
> >>>> What you must remove is all scriptalias, addhandler/action directives.
> >>>> So I'd say with a directive for each virtualhost you mentioned you
> >>>> have you just would need (and of course disable mod_php module):
> >>>>
> >>>> In one for one version pointing to 9002 port:
> >>>> <FilesMatch \.(php|phar)$>
> >>>> SetHandler "proxy:fcgi://localhost:9002"
> >>>> </FilesMatch>
> >>>>
> >>>> In the other virtualhost you want to have pointing to 9003:
> >>>> <FilesMatch \.(php|phar)$>
> >>>> SetHandler "proxy:fcgi://localhost:9003"
> >>>> </FilesMatch>
> >>>>
> >>>> Apache is really much more simple and easier than many examples out
> >>>> there try to show.
> >>>>
> >>>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
> >>>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
> >>>>>> Hello,
> >>>>>>
> >>>>>> You mention PHP is set to listen to different tcp ports, yet the
> >>>>>> config you show from apache points to a unix socket with
> >>>>>> mod_proxy_fcgi
> >>>>>>
> >>>>>> Also worth mentioning you don't need php7_module at all when pointing
> >>>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
> >>>>>> case you have some other config lying around taking precedence and
> >>>>>> causing the problems you mention.
> >>>>>>
> >>>>>> Cheers
> >>>>>>
> >>>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
> >>>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
> >>>>>>>
> >>>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
> >>>>>>>
> >>>>>>> <VirtualHost *:80>
> >>>>>>> ServerAdmin xxx
> >>>>>>> ServerName x.x.x.x/site1
> >>>>>>> DocumentRoot /var/www/html/
> >>>>>>> DirectoryIndex info.php
> >>>>>>> ErrorLog /var/log/httpd/site1-error.log
> >>>>>>> CustomLog /var/log/httpd/site1-access.log combined
> >>>>>>>
> >>>>>>> <IfModule !mod_php7.c>
> >>>>>>> <FilesMatch \.(php|phar)$>
> >>>>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
> >>>>>>> </FilesMatch>
> >>>>>>> </IfModule>
> >>>>>>> </VirtualHost>
> >>>>>>>
> >>>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
> >>>>>>>
> >>>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
> >>>>>>>
> >>>>>>> I must have missed some configuration step and would appreciate any pointers.
> >>>>>>>
> >>>>>>> Thank you.
> >>>>>>>
> >>>>>>>
> >>>>>>> ---------------------------------------------------------------------
> >>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>>>>
> >>>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
> >>>>>
> >>>>> SetHandler "proxy:fcgi://localhost:9002
> >>>>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
> >>>>> AddHandler php70-fcgi .php
> >>>>> Action php70-fcgi /cgi-bin/php70.fcgi
> >>>>>
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>>
> >>> This is what I did:
> >>>
> >>> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/librh-php70-php7.so" in the former and the equivalent in the latter.
> >>>
> >>> - For the the site1.conf I have:
> >>>
> >>> <VirtualHost *:80>
> >>> ServerAdmin xxx
> >>> ServerName x.x.x.x
> >>> DocumentRoot /var/www/html/
> >>> ErrorLog /var/log/httpd/site1-error.log
> >>> CustomLog /var/log/httpd/site1-access.log combined
> >>>
> >>> <FilesMatch \.(php|phar)$>
> >>> SetHandler "proxy:fcgi://localhost:9002"
> >>> </FilesMatch>
> >>> </VirtualHost>
> >>>
> >>> and for site2.conf
> >>>
> >>> <VirtualHost *:80>
> >>> ServerAdmin xxx
> >>> ServerName x.x.x.x
> >>> DocumentRoot /var/www/html/
> >>> ErrorLog /var/log/httpd/site2-error.log
> >>> CustomLog /var/log/httpd/site2-access.log combined
> >>>
> >>> <FilesMatch \.(php|phar)$>
> >>> SetHandler "proxy:fcgi://localhost:9003"
> >>> </FilesMatch>
> >>> </VirtualHost>
> >>>
> >>> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
> >>>
> >>> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
> >>>
> >>> So, there must be something more I need to do?
> >>>
> >>> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
> >>>
> >> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
> >>
> >> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
> >>
> >> And I restarted httpd after each change.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >> For additional commands, e-mail: users-help@httpd.apache.org
> >>
> >
> This is from ps aux | grep fpm:
>
> root 17004 0.0 0.6 339008 11244 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php70/php-fpm.conf)
> apache 17005 0.0 0.3 339112 7352 ? S 01:18 0:00 php-fpm: pool www
> apache 17006 0.0 0.3 339112 7356 ? S 01:18 0:00 php-fpm: pool www
> apache 17007 0.0 0.4 339252 8452 ? S 01:18 0:00 php-fpm: pool www
> apache 17008 0.0 0.3 339112 7360 ? S 01:18 0:00 php-fpm: pool www
> apache 17009 0.0 0.3 339112 7368 ? S 01:18 0:00 php-fpm: pool www
> root 17036 0.0 0.9 562800 18540 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
> apache 17037 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> apache 17038 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> apache 17039 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> apache 17040 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> apache 17041 0.0 0.3 562800 6980 ? S 01:18 0:00 php-fpm: pool www
>
> Does this not look correct?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


--
Daniel Ferradal
HTTPD Project
#httpd help at Freenode

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
On 04/08/2021 09:30 PM, Bender, Charles wrote:
> You're making this very difficult for yourself by having 2 different versions of PHP installed on 1 server box. Even if you get working maintaining will be challenging.
>
> Suggestion- run PHP and PHP-FPM in separate Docker containers on same server, each with specific version of PHP you need. Then have Apache proxy to these containers as required
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *From:* H <agents@meddatainc.com>
> *Sent:* Thursday, April 8, 2021 9:26 PM
> *To:* users@httpd.apache.org <users@httpd.apache.org>
> *Subject:* Re: [users@httpd] Running php 7.0 and 7.2 for different websites with apache
> ?
> On 04/08/2021 08:57 PM, Daniel Ferradal wrote:
> > There is no such thing as default php version for a site.
> >
> > You have to make sure you have really two different instances of
> > php-fpm running for the different php versions you want to use.
> >
> > Chances are you have the same php-fpm service with two pools, so both
> > may be with the same version.
> >
> > Apache doesn't care what you do from now on, since it is just reverse
> > proxying requests to the selected servers. So it is up to you and your
> > php-fpm config and how you start them now.
> >
> > El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribi?:
> >> On 04/08/2021 07:34 PM, H wrote:
> >>> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
> >>>> Hello,
> >>>>
> >>>> What you must remove is all scriptalias, addhandler/action directives.
> >>>> So I'd say with a directive for each virtualhost you mentioned you
> >>>> have you just would need (and of course disable mod_php module):
> >>>>
> >>>> In one for one version pointing to 9002 port:
> >>>> <FilesMatch \.(php|phar)$>
> >>>>???? SetHandler? "proxy:fcgi://localhost:9002"
> >>>> </FilesMatch>
> >>>>
> >>>> In the other virtualhost you? want to have pointing to 9003:
> >>>> <FilesMatch \.(php|phar)$>
> >>>>???? SetHandler? "proxy:fcgi://localhost:9003"
> >>>> </FilesMatch>
> >>>>
> >>>> Apache is really much more simple and easier than many examples out
> >>>> there try to show.
> >>>>
> >>>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribi?:
> >>>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
> >>>>>> Hello,
> >>>>>>
> >>>>>> You mention PHP is set to listen to different tcp ports, yet the
> >>>>>> config you show from apache points to a unix socket with
> >>>>>> mod_proxy_fcgi
> >>>>>>
> >>>>>> Also worth mentioning you don't need php7_module at all when pointing
> >>>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
> >>>>>> case you have some other config lying around taking precedence and
> >>>>>> causing the problems you mention.
> >>>>>>
> >>>>>> Cheers
> >>>>>>
> >>>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribi?:
> >>>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
> >>>>>>>
> >>>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
> >>>>>>>
> >>>>>>> <VirtualHost *:80>
> >>>>>>>???????? ServerAdmin xxx
> >>>>>>>???????? ServerName x.x.x.x/site1
> >>>>>>>???????? DocumentRoot /var/www/html/
> >>>>>>>???????? DirectoryIndex info.php
> >>>>>>>???????? ErrorLog /var/log/httpd/site1-error.log
> >>>>>>>???????? CustomLog /var/log/httpd/site1-access.log combined
> >>>>>>>
> >>>>>>>???? <IfModule !mod_php7.c>
> >>>>>>>???????? <FilesMatch \.(php|phar)$>
> >>>>>>>???????????? SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
> >>>>>>>???????? </FilesMatch>
> >>>>>>>???? </IfModule>
> >>>>>>> </VirtualHost>
> >>>>>>>
> >>>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
> >>>>>>>
> >>>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.digitalocean.com%2fcommunity%2ftutorials%2fhow-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7&c=E,1,nGU2QIv_y4smfnrUNnx9CDP8bkt1CgBCY00J7ykv7wIqnjBmryO1KuEik3Og-vkjZWpESUYdCo9JVJ3o77e7nOazFVuJCoH57Wvd5gM1XdQ,&typo=1 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
> >>>>>>>
> >>>>>>> I must have missed some configuration step and would appreciate any pointers.
> >>>>>>>
> >>>>>>> Thank you.
> >>>>>>>
> >>>>>>>
> >>>>>>> ---------------------------------------------------------------------
> >>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>>>>
> >>>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
> >>>>>
> >>>>>????? SetHandler "proxy:fcgi://localhost:9002
> >>>>>????? ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
> >>>>>????? AddHandler php70-fcgi .php
> >>>>>????? Action php70-fcgi /cgi-bin/php70.fcgi
> >>>>>
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>>
> >>> This is what I did:
> >>>
> >>> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flibrh-php70-php7.so&c=E,1,ObjWDSRkeobJmAvtgGDv7IZhOuViBCsywRH4WTkNPs2Zia5LKubUYQ80Kog5ge58me6QKtwGLdOjH_AqFDhPNxL5rUy39Dx47NdG4foHL0fSSrc,&typo=1" in the former and the equivalent in the latter.
> >>>
> >>> - For the the site1.conf I have:
> >>>
> >>> <VirtualHost *:80>
> >>>???????? ServerAdmin xxx
> >>>???????? ServerName x.x.x.x
> >>>???????? DocumentRoot /var/www/html/
> >>>???????? ErrorLog /var/log/httpd/site1-error.log
> >>>???????? CustomLog /var/log/httpd/site1-access.log combined
> >>>
> >>>???????? <FilesMatch \.(php|phar)$>
> >>>???????????????? SetHandler "proxy:fcgi://localhost:9002"
> >>>???????? </FilesMatch>
> >>> </VirtualHost>
> >>>
> >>> and for site2.conf
> >>>
> >>> <VirtualHost *:80>
> >>>???????? ServerAdmin xxx
> >>>???????? ServerName x.x.x.x
> >>>???????? DocumentRoot /var/www/html/
> >>>???????? ErrorLog /var/log/httpd/site2-error.log
> >>>???????? CustomLog /var/log/httpd/site2-access.log combined
> >>>
> >>>???????? <FilesMatch \.(php|phar)$>
> >>>???????????????? SetHandler "proxy:fcgi://localhost:9003"
> >>>???????? </FilesMatch>
> >>> </VirtualHost>
> >>>
> >>> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
> >>>
> >>> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
> >>>
> >>> So, there must be something more I need to do?
> >>>
> >>> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
> >>>
> >> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
> >>
> >> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
> >>
> >> And I restarted httpd after each change.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >> For additional commands, e-mail: users-help@httpd.apache.org
> >>
> >
> This is from ps aux | grep fpm:
>
> root???? 17004? 0.0? 0.6 339008 11244 ???????? Ss?? 01:18?? 0:00 php-fpm: master process (/etc/opt/rh/rh-php70/php-fpm.conf)
> apache?? 17005? 0.0? 0.3 339112? 7352 ???????? S??? 01:18?? 0:00 php-fpm: pool www
> apache?? 17006? 0.0? 0.3 339112? 7356 ???????? S??? 01:18?? 0:00 php-fpm: pool www
> apache?? 17007? 0.0? 0.4 339252? 8452 ???????? S??? 01:18?? 0:00 php-fpm: pool www
> apache?? 17008? 0.0? 0.3 339112? 7360 ???????? S??? 01:18?? 0:00 php-fpm: pool www
> apache?? 17009? 0.0? 0.3 339112? 7368 ???????? S??? 01:18?? 0:00 php-fpm: pool www
> root???? 17036? 0.0? 0.9 562800 18540 ???????? Ss?? 01:18?? 0:00 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
> apache?? 17037? 0.0? 0.3 562800? 6976 ???????? S??? 01:18?? 0:00 php-fpm: pool www
> apache?? 17038? 0.0? 0.3 562800? 6976 ???????? S??? 01:18?? 0:00 php-fpm: pool www
> apache?? 17039? 0.0? 0.3 562800? 6976 ???????? S??? 01:18?? 0:00 php-fpm: pool www
> apache?? 17040? 0.0? 0.3 562800? 6976 ???????? S??? 01:18?? 0:00 php-fpm: pool www
> apache?? 17041? 0.0? 0.3 562800? 6980 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>
> Does this not look correct?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
Possibly but there are many webpages that purportedly tell you how to configure a CentOS 7 server to serve different php versions to different sites. Some of them use serve both 7.0 and 7.2.


Obviously there is something I have missed.
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
On 04/09/2021 04:00 AM, Dino Ciuffetti wrote:
>> This is from ps aux | grep fpm:
>>
>> root 17004 0.0 0.6 339008 11244 ? Ss 01:18 0:00 php-fpm: master process
>> (/etc/opt/rh/rh-php70/php-fpm.conf)
>> apache 17005 0.0 0.3 339112 7352 ? S 01:18 0:00 php-fpm: pool www
>> apache 17006 0.0 0.3 339112 7356 ? S 01:18 0:00 php-fpm: pool www
>> apache 17007 0.0 0.4 339252 8452 ? S 01:18 0:00 php-fpm: pool www
>> apache 17008 0.0 0.3 339112 7360 ? S 01:18 0:00 php-fpm: pool www
>> apache 17009 0.0 0.3 339112 7368 ? S 01:18 0:00 php-fpm: pool www
>> root 17036 0.0 0.9 562800 18540 ? Ss 01:18 0:00 php-fpm: master process
>> (/etc/opt/rh/rh-php72/php-fpm.conf)
>> apache 17037 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>> apache 17038 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>> apache 17039 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>> apache 17040 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>> apache 17041 0.0 0.3 562800 6980 ? S 01:18 0:00 php-fpm: pool www
>>
>> Does this not look correct?
>
> Yes. It seems correct.
>
> This is just one way, there are many, but it would work:
> # 1) disable mod_php
> # 2) enable mod_proxy and mod_proxy_fcgi
> # 3) create a file called php7.0-fpm.conf that will handle PHP7.0 requests
>
> <IfModule proxy_fcgi_module>
> # Enable http authorization headers
> <IfModule setenvif_module>
> SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
> </IfModule>
> <FilesMatch ".+\.ph(ar|p|tml)$">
> SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"
> # or if you prefer use TCP instead of UX socket
> #SetHandler "proxy:fcgi://localhost:9002"
> </FilesMatch>
> </IfModule>
>
> # 4) create a file called php7.2-fpm.conf that will handle PHP7.2 requests
>
> <IfModule proxy_fcgi_module>
> # Enable http authorization headers
> <IfModule setenvif_module>
> SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
> </IfModule>
> <FilesMatch ".+\.ph(ar|p|tml)$">
> SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost"
> # or if you prefer use TCP instead of UX socket
> #SetHandler "proxy:fcgi://localhost:9003"
> </FilesMatch>
> </IfModule>
>
> # 5) inside your virtualhosts, include the desired PHP conf file:
> # eg: Include /yourconfpath/php7.2-fpm.conf
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
I did this but still not working so I must be missing something more. Do you know of a link to how to set this up to work? I have visited several webpages but still missing something.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
On 04/09/2021 06:03 AM, Daniel Ferradal wrote:
> Looks correct yes. But still lots of things you are not showing could be wrong.
>
> To solve issues you have to go one thing at a time, you know for sure
> apache is pointing to different ports, if you disabled mod_php. Now
> you must make sure the fpm pools are correct, both versions listening
> to each port, that you disabled all mod_php stuff, etc. things we
> can't see because you don't show, so it is quite hard to hand-guide
> you with just small bits of info.
>
> El vie, 9 abr 2021 a las 3:26, H (<agents@meddatainc.com>) escribió:
>> On 04/08/2021 08:57 PM, Daniel Ferradal wrote:
>>> There is no such thing as default php version for a site.
>>>
>>> You have to make sure you have really two different instances of
>>> php-fpm running for the different php versions you want to use.
>>>
>>> Chances are you have the same php-fpm service with two pools, so both
>>> may be with the same version.
>>>
>>> Apache doesn't care what you do from now on, since it is just reverse
>>> proxying requests to the selected servers. So it is up to you and your
>>> php-fpm config and how you start them now.
>>>
>>> El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribió:
>>>> On 04/08/2021 07:34 PM, H wrote:
>>>>> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
>>>>>> Hello,
>>>>>>
>>>>>> What you must remove is all scriptalias, addhandler/action directives.
>>>>>> So I'd say with a directive for each virtualhost you mentioned you
>>>>>> have you just would need (and of course disable mod_php module):
>>>>>>
>>>>>> In one for one version pointing to 9002 port:
>>>>>> <FilesMatch \.(php|phar)$>
>>>>>> SetHandler "proxy:fcgi://localhost:9002"
>>>>>> </FilesMatch>
>>>>>>
>>>>>> In the other virtualhost you want to have pointing to 9003:
>>>>>> <FilesMatch \.(php|phar)$>
>>>>>> SetHandler "proxy:fcgi://localhost:9003"
>>>>>> </FilesMatch>
>>>>>>
>>>>>> Apache is really much more simple and easier than many examples out
>>>>>> there try to show.
>>>>>>
>>>>>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
>>>>>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> You mention PHP is set to listen to different tcp ports, yet the
>>>>>>>> config you show from apache points to a unix socket with
>>>>>>>> mod_proxy_fcgi
>>>>>>>>
>>>>>>>> Also worth mentioning you don't need php7_module at all when pointing
>>>>>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
>>>>>>>> case you have some other config lying around taking precedence and
>>>>>>>> causing the problems you mention.
>>>>>>>>
>>>>>>>> Cheers
>>>>>>>>
>>>>>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
>>>>>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
>>>>>>>>>
>>>>>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
>>>>>>>>>
>>>>>>>>> <VirtualHost *:80>
>>>>>>>>> ServerAdmin xxx
>>>>>>>>> ServerName x.x.x.x/site1
>>>>>>>>> DocumentRoot /var/www/html/
>>>>>>>>> DirectoryIndex info.php
>>>>>>>>> ErrorLog /var/log/httpd/site1-error.log
>>>>>>>>> CustomLog /var/log/httpd/site1-access.log combined
>>>>>>>>>
>>>>>>>>> <IfModule !mod_php7.c>
>>>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
>>>>>>>>> </FilesMatch>
>>>>>>>>> </IfModule>
>>>>>>>>> </VirtualHost>
>>>>>>>>>
>>>>>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
>>>>>>>>>
>>>>>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
>>>>>>>>>
>>>>>>>>> I must have missed some configuration step and would appreciate any pointers.
>>>>>>>>>
>>>>>>>>> Thank you.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>>>>
>>>>>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
>>>>>>>
>>>>>>> SetHandler "proxy:fcgi://localhost:9002
>>>>>>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
>>>>>>> AddHandler php70-fcgi .php
>>>>>>> Action php70-fcgi /cgi-bin/php70.fcgi
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>>
>>>>> This is what I did:
>>>>>
>>>>> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/librh-php70-php7.so" in the former and the equivalent in the latter.
>>>>>
>>>>> - For the the site1.conf I have:
>>>>>
>>>>> <VirtualHost *:80>
>>>>> ServerAdmin xxx
>>>>> ServerName x.x.x.x
>>>>> DocumentRoot /var/www/html/
>>>>> ErrorLog /var/log/httpd/site1-error.log
>>>>> CustomLog /var/log/httpd/site1-access.log combined
>>>>>
>>>>> <FilesMatch \.(php|phar)$>
>>>>> SetHandler "proxy:fcgi://localhost:9002"
>>>>> </FilesMatch>
>>>>> </VirtualHost>
>>>>>
>>>>> and for site2.conf
>>>>>
>>>>> <VirtualHost *:80>
>>>>> ServerAdmin xxx
>>>>> ServerName x.x.x.x
>>>>> DocumentRoot /var/www/html/
>>>>> ErrorLog /var/log/httpd/site2-error.log
>>>>> CustomLog /var/log/httpd/site2-access.log combined
>>>>>
>>>>> <FilesMatch \.(php|phar)$>
>>>>> SetHandler "proxy:fcgi://localhost:9003"
>>>>> </FilesMatch>
>>>>> </VirtualHost>
>>>>>
>>>>> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
>>>>>
>>>>> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
>>>>>
>>>>> So, there must be something more I need to do?
>>>>>
>>>>> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
>>>>>
>>>> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
>>>>
>>>> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
>>>>
>>>> And I restarted httpd after each change.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>
>> This is from ps aux | grep fpm:
>>
>> root 17004 0.0 0.6 339008 11244 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php70/php-fpm.conf)
>> apache 17005 0.0 0.3 339112 7352 ? S 01:18 0:00 php-fpm: pool www
>> apache 17006 0.0 0.3 339112 7356 ? S 01:18 0:00 php-fpm: pool www
>> apache 17007 0.0 0.4 339252 8452 ? S 01:18 0:00 php-fpm: pool www
>> apache 17008 0.0 0.3 339112 7360 ? S 01:18 0:00 php-fpm: pool www
>> apache 17009 0.0 0.3 339112 7368 ? S 01:18 0:00 php-fpm: pool www
>> root 17036 0.0 0.9 562800 18540 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
>> apache 17037 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>> apache 17038 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>> apache 17039 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>> apache 17040 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>> apache 17041 0.0 0.3 562800 6980 ? S 01:18 0:00 php-fpm: pool www
>>
>> Does this not look correct?
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
You write "both versions listening to each port", I have each version listening to its port, ie php 70 to 9002 and php 72 to 9003 as confirmed by netstat -tlpn.

By the way, here are my httpd modules:

Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 access_compat_module (shared)
 actions_module (shared)
 alias_module (shared)
 allowmethods_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_anon_module (shared)
 authn_core_module (shared)
 authn_dbd_module (shared)
 authn_dbm_module (shared)
 authn_file_module (shared)
 authn_socache_module (shared)
 authz_core_module (shared)
 authz_dbd_module (shared)
 authz_dbm_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_owner_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cache_module (shared)
 cache_disk_module (shared)
 data_module (shared)
 dbd_module (shared)
 deflate_module (shared)
 dir_module (shared)
 dumpio_module (shared)
 echo_module (shared)
 env_module (shared)
 expires_module (shared)
 ext_filter_module (shared)
 filter_module (shared)
 headers_module (shared)
 include_module (shared)
 info_module (shared)
 log_config_module (shared)
 logio_module (shared)
 mime_magic_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 remoteip_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 slotmem_plain_module (shared)
 slotmem_shm_module (shared)
 socache_dbm_module (shared)
 socache_memcache_module (shared)
 socache_shmcb_module (shared)
 status_module (shared)
 substitute_module (shared)
 suexec_module (shared)
 unique_id_module (shared)
 unixd_module (shared)
 userdir_module (shared)
 version_module (shared)
 vhost_alias_module (shared)
 dav_module (shared)
 dav_fs_module (shared)
 dav_lock_module (shared)
 lua_module (shared)
 mpm_prefork_module (shared)
 proxy_module (shared)
 lbmethod_bybusyness_module (shared)
 lbmethod_byrequests_module (shared)
 lbmethod_bytraffic_module (shared)
 lbmethod_heartbeat_module (shared)
 proxy_ajp_module (shared)
 proxy_balancer_module (shared)
 proxy_connect_module (shared)
 proxy_express_module (shared)
 proxy_fcgi_module (shared)
 proxy_fdpass_module (shared)
 proxy_ftp_module (shared)
 proxy_http_module (shared)
 proxy_scgi_module (shared)
 proxy_wstunnel_module (shared)
 ssl_module (shared)
 systemd_module (shared)
 cgi_module (shared)
 php7_module (shared)

Does the above look correct? Should the last one, php7_module, be loaded since I am trying to run both 7.0 and 7.2?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
That´s probably it. You still have php7_module, and are probably
pointing to it somewhere in your config. For the looks of it you need
a serious and thorough cleanup of your configuration that you haven´t
done yet.

Like we told you earlier, get rid of that module.

As for your question:
You just need mod_proxy and mod_proxy_fcgi to reverse proxy requests
to php-fpm, that´s it, you are reverse proxying requests for php files
to another service, and php-fpm will interpret those and return the
dynamic content to apache.
PHP libs have nothing to do in your Apache if you are using/want to
use php-fpm, which is a good path imo. So no, no php modules of any
kind in apache, apache will not do any more interpretation of php
code.

Also let me take the liberty to tell you that you could take the
chance and clean that horrendous list of modules you will never use.

Ideally you should just load those modules you use, no more no less.

Ideally you will use mpm_event too, not mpm_prefork, but I don´t want
to distract you too much, focus on ridding everything php but the
mod_proxy mod_proxy_fcgi and the directives we mentioned earlier.


Cheers



El vie, 9 abr 2021 a las 17:36, H (<agents@meddatainc.com>) escribió:
>
> On 04/09/2021 06:03 AM, Daniel Ferradal wrote:
> > Looks correct yes. But still lots of things you are not showing could be wrong.
> >
> > To solve issues you have to go one thing at a time, you know for sure
> > apache is pointing to different ports, if you disabled mod_php. Now
> > you must make sure the fpm pools are correct, both versions listening
> > to each port, that you disabled all mod_php stuff, etc. things we
> > can't see because you don't show, so it is quite hard to hand-guide
> > you with just small bits of info.
> >
> > El vie, 9 abr 2021 a las 3:26, H (<agents@meddatainc.com>) escribió:
> >> On 04/08/2021 08:57 PM, Daniel Ferradal wrote:
> >>> There is no such thing as default php version for a site.
> >>>
> >>> You have to make sure you have really two different instances of
> >>> php-fpm running for the different php versions you want to use.
> >>>
> >>> Chances are you have the same php-fpm service with two pools, so both
> >>> may be with the same version.
> >>>
> >>> Apache doesn't care what you do from now on, since it is just reverse
> >>> proxying requests to the selected servers. So it is up to you and your
> >>> php-fpm config and how you start them now.
> >>>
> >>> El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribió:
> >>>> On 04/08/2021 07:34 PM, H wrote:
> >>>>> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
> >>>>>> Hello,
> >>>>>>
> >>>>>> What you must remove is all scriptalias, addhandler/action directives.
> >>>>>> So I'd say with a directive for each virtualhost you mentioned you
> >>>>>> have you just would need (and of course disable mod_php module):
> >>>>>>
> >>>>>> In one for one version pointing to 9002 port:
> >>>>>> <FilesMatch \.(php|phar)$>
> >>>>>> SetHandler "proxy:fcgi://localhost:9002"
> >>>>>> </FilesMatch>
> >>>>>>
> >>>>>> In the other virtualhost you want to have pointing to 9003:
> >>>>>> <FilesMatch \.(php|phar)$>
> >>>>>> SetHandler "proxy:fcgi://localhost:9003"
> >>>>>> </FilesMatch>
> >>>>>>
> >>>>>> Apache is really much more simple and easier than many examples out
> >>>>>> there try to show.
> >>>>>>
> >>>>>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
> >>>>>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
> >>>>>>>> Hello,
> >>>>>>>>
> >>>>>>>> You mention PHP is set to listen to different tcp ports, yet the
> >>>>>>>> config you show from apache points to a unix socket with
> >>>>>>>> mod_proxy_fcgi
> >>>>>>>>
> >>>>>>>> Also worth mentioning you don't need php7_module at all when pointing
> >>>>>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
> >>>>>>>> case you have some other config lying around taking precedence and
> >>>>>>>> causing the problems you mention.
> >>>>>>>>
> >>>>>>>> Cheers
> >>>>>>>>
> >>>>>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
> >>>>>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
> >>>>>>>>>
> >>>>>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
> >>>>>>>>>
> >>>>>>>>> <VirtualHost *:80>
> >>>>>>>>> ServerAdmin xxx
> >>>>>>>>> ServerName x.x.x.x/site1
> >>>>>>>>> DocumentRoot /var/www/html/
> >>>>>>>>> DirectoryIndex info.php
> >>>>>>>>> ErrorLog /var/log/httpd/site1-error.log
> >>>>>>>>> CustomLog /var/log/httpd/site1-access.log combined
> >>>>>>>>>
> >>>>>>>>> <IfModule !mod_php7.c>
> >>>>>>>>> <FilesMatch \.(php|phar)$>
> >>>>>>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
> >>>>>>>>> </FilesMatch>
> >>>>>>>>> </IfModule>
> >>>>>>>>> </VirtualHost>
> >>>>>>>>>
> >>>>>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
> >>>>>>>>>
> >>>>>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
> >>>>>>>>>
> >>>>>>>>> I must have missed some configuration step and would appreciate any pointers.
> >>>>>>>>>
> >>>>>>>>> Thank you.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> ---------------------------------------------------------------------
> >>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>>>>>>
> >>>>>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
> >>>>>>>
> >>>>>>> SetHandler "proxy:fcgi://localhost:9002
> >>>>>>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
> >>>>>>> AddHandler php70-fcgi .php
> >>>>>>> Action php70-fcgi /cgi-bin/php70.fcgi
> >>>>>>>
> >>>>>>>
> >>>>>>> ---------------------------------------------------------------------
> >>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>>>>
> >>>>> This is what I did:
> >>>>>
> >>>>> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/librh-php70-php7.so" in the former and the equivalent in the latter.
> >>>>>
> >>>>> - For the the site1.conf I have:
> >>>>>
> >>>>> <VirtualHost *:80>
> >>>>> ServerAdmin xxx
> >>>>> ServerName x.x.x.x
> >>>>> DocumentRoot /var/www/html/
> >>>>> ErrorLog /var/log/httpd/site1-error.log
> >>>>> CustomLog /var/log/httpd/site1-access.log combined
> >>>>>
> >>>>> <FilesMatch \.(php|phar)$>
> >>>>> SetHandler "proxy:fcgi://localhost:9002"
> >>>>> </FilesMatch>
> >>>>> </VirtualHost>
> >>>>>
> >>>>> and for site2.conf
> >>>>>
> >>>>> <VirtualHost *:80>
> >>>>> ServerAdmin xxx
> >>>>> ServerName x.x.x.x
> >>>>> DocumentRoot /var/www/html/
> >>>>> ErrorLog /var/log/httpd/site2-error.log
> >>>>> CustomLog /var/log/httpd/site2-access.log combined
> >>>>>
> >>>>> <FilesMatch \.(php|phar)$>
> >>>>> SetHandler "proxy:fcgi://localhost:9003"
> >>>>> </FilesMatch>
> >>>>> </VirtualHost>
> >>>>>
> >>>>> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
> >>>>>
> >>>>> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
> >>>>>
> >>>>> So, there must be something more I need to do?
> >>>>>
> >>>>> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
> >>>>>
> >>>> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
> >>>>
> >>>> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
> >>>>
> >>>> And I restarted httpd after each change.
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>
> >> This is from ps aux | grep fpm:
> >>
> >> root 17004 0.0 0.6 339008 11244 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php70/php-fpm.conf)
> >> apache 17005 0.0 0.3 339112 7352 ? S 01:18 0:00 php-fpm: pool www
> >> apache 17006 0.0 0.3 339112 7356 ? S 01:18 0:00 php-fpm: pool www
> >> apache 17007 0.0 0.4 339252 8452 ? S 01:18 0:00 php-fpm: pool www
> >> apache 17008 0.0 0.3 339112 7360 ? S 01:18 0:00 php-fpm: pool www
> >> apache 17009 0.0 0.3 339112 7368 ? S 01:18 0:00 php-fpm: pool www
> >> root 17036 0.0 0.9 562800 18540 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
> >> apache 17037 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> >> apache 17038 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> >> apache 17039 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> >> apache 17040 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> >> apache 17041 0.0 0.3 562800 6980 ? S 01:18 0:00 php-fpm: pool www
> >>
> >> Does this not look correct?
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >> For additional commands, e-mail: users-help@httpd.apache.org
> >>
> >
> You write "both versions listening to each port", I have each version listening to its port, ie php 70 to 9002 and php 72 to 9003 as confirmed by netstat -tlpn.
>
> By the way, here are my httpd modules:
>
> Loaded Modules:
> core_module (static)
> so_module (static)
> http_module (static)
> access_compat_module (shared)
> actions_module (shared)
> alias_module (shared)
> allowmethods_module (shared)
> auth_basic_module (shared)
> auth_digest_module (shared)
> authn_anon_module (shared)
> authn_core_module (shared)
> authn_dbd_module (shared)
> authn_dbm_module (shared)
> authn_file_module (shared)
> authn_socache_module (shared)
> authz_core_module (shared)
> authz_dbd_module (shared)
> authz_dbm_module (shared)
> authz_groupfile_module (shared)
> authz_host_module (shared)
> authz_owner_module (shared)
> authz_user_module (shared)
> autoindex_module (shared)
> cache_module (shared)
> cache_disk_module (shared)
> data_module (shared)
> dbd_module (shared)
> deflate_module (shared)
> dir_module (shared)
> dumpio_module (shared)
> echo_module (shared)
> env_module (shared)
> expires_module (shared)
> ext_filter_module (shared)
> filter_module (shared)
> headers_module (shared)
> include_module (shared)
> info_module (shared)
> log_config_module (shared)
> logio_module (shared)
> mime_magic_module (shared)
> mime_module (shared)
> negotiation_module (shared)
> remoteip_module (shared)
> reqtimeout_module (shared)
> rewrite_module (shared)
> setenvif_module (shared)
> slotmem_plain_module (shared)
> slotmem_shm_module (shared)
> socache_dbm_module (shared)
> socache_memcache_module (shared)
> socache_shmcb_module (shared)
> status_module (shared)
> substitute_module (shared)
> suexec_module (shared)
> unique_id_module (shared)
> unixd_module (shared)
> userdir_module (shared)
> version_module (shared)
> vhost_alias_module (shared)
> dav_module (shared)
> dav_fs_module (shared)
> dav_lock_module (shared)
> lua_module (shared)
> mpm_prefork_module (shared)
> proxy_module (shared)
> lbmethod_bybusyness_module (shared)
> lbmethod_byrequests_module (shared)
> lbmethod_bytraffic_module (shared)
> lbmethod_heartbeat_module (shared)
> proxy_ajp_module (shared)
> proxy_balancer_module (shared)
> proxy_connect_module (shared)
> proxy_express_module (shared)
> proxy_fcgi_module (shared)
> proxy_fdpass_module (shared)
> proxy_ftp_module (shared)
> proxy_http_module (shared)
> proxy_scgi_module (shared)
> proxy_wstunnel_module (shared)
> ssl_module (shared)
> systemd_module (shared)
> cgi_module (shared)
> php7_module (shared)
>
> Does the above look correct? Should the last one, php7_module, be loaded since I am trying to run both 7.0 and 7.2?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


--
Daniel Ferradal
HTTPD Project
#httpd help at Freenode

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
On 04/09/2021 11:48 AM, Daniel Ferradal wrote:
> That´s probably it. You still have php7_module, and are probably
> pointing to it somewhere in your config. For the looks of it you need
> a serious and thorough cleanup of your configuration that you haven´t
> done yet.
>
> Like we told you earlier, get rid of that module.
>
> As for your question:
> You just need mod_proxy and mod_proxy_fcgi to reverse proxy requests
> to php-fpm, that´s it, you are reverse proxying requests for php files
> to another service, and php-fpm will interpret those and return the
> dynamic content to apache.
> PHP libs have nothing to do in your Apache if you are using/want to
> use php-fpm, which is a good path imo. So no, no php modules of any
> kind in apache, apache will not do any more interpretation of php
> code.
>
> Also let me take the liberty to tell you that you could take the
> chance and clean that horrendous list of modules you will never use.
>
> Ideally you should just load those modules you use, no more no less.
>
> Ideally you will use mpm_event too, not mpm_prefork, but I don´t want
> to distract you too much, focus on ridding everything php but the
> mod_proxy mod_proxy_fcgi and the directives we mentioned earlier.
>
>
> Cheers
>
>
>
> El vie, 9 abr 2021 a las 17:36, H (<agents@meddatainc.com>) escribió:
>> On 04/09/2021 06:03 AM, Daniel Ferradal wrote:
>>> Looks correct yes. But still lots of things you are not showing could be wrong.
>>>
>>> To solve issues you have to go one thing at a time, you know for sure
>>> apache is pointing to different ports, if you disabled mod_php. Now
>>> you must make sure the fpm pools are correct, both versions listening
>>> to each port, that you disabled all mod_php stuff, etc. things we
>>> can't see because you don't show, so it is quite hard to hand-guide
>>> you with just small bits of info.
>>>
>>> El vie, 9 abr 2021 a las 3:26, H (<agents@meddatainc.com>) escribió:
>>>> On 04/08/2021 08:57 PM, Daniel Ferradal wrote:
>>>>> There is no such thing as default php version for a site.
>>>>>
>>>>> You have to make sure you have really two different instances of
>>>>> php-fpm running for the different php versions you want to use.
>>>>>
>>>>> Chances are you have the same php-fpm service with two pools, so both
>>>>> may be with the same version.
>>>>>
>>>>> Apache doesn't care what you do from now on, since it is just reverse
>>>>> proxying requests to the selected servers. So it is up to you and your
>>>>> php-fpm config and how you start them now.
>>>>>
>>>>> El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribió:
>>>>>> On 04/08/2021 07:34 PM, H wrote:
>>>>>>> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> What you must remove is all scriptalias, addhandler/action directives.
>>>>>>>> So I'd say with a directive for each virtualhost you mentioned you
>>>>>>>> have you just would need (and of course disable mod_php module):
>>>>>>>>
>>>>>>>> In one for one version pointing to 9002 port:
>>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>>> SetHandler "proxy:fcgi://localhost:9002"
>>>>>>>> </FilesMatch>
>>>>>>>>
>>>>>>>> In the other virtualhost you want to have pointing to 9003:
>>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>>> SetHandler "proxy:fcgi://localhost:9003"
>>>>>>>> </FilesMatch>
>>>>>>>>
>>>>>>>> Apache is really much more simple and easier than many examples out
>>>>>>>> there try to show.
>>>>>>>>
>>>>>>>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
>>>>>>>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
>>>>>>>>>> Hello,
>>>>>>>>>>
>>>>>>>>>> You mention PHP is set to listen to different tcp ports, yet the
>>>>>>>>>> config you show from apache points to a unix socket with
>>>>>>>>>> mod_proxy_fcgi
>>>>>>>>>>
>>>>>>>>>> Also worth mentioning you don't need php7_module at all when pointing
>>>>>>>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
>>>>>>>>>> case you have some other config lying around taking precedence and
>>>>>>>>>> causing the problems you mention.
>>>>>>>>>>
>>>>>>>>>> Cheers
>>>>>>>>>>
>>>>>>>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
>>>>>>>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
>>>>>>>>>>>
>>>>>>>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
>>>>>>>>>>>
>>>>>>>>>>> <VirtualHost *:80>
>>>>>>>>>>> ServerAdmin xxx
>>>>>>>>>>> ServerName x.x.x.x/site1
>>>>>>>>>>> DocumentRoot /var/www/html/
>>>>>>>>>>> DirectoryIndex info.php
>>>>>>>>>>> ErrorLog /var/log/httpd/site1-error.log
>>>>>>>>>>> CustomLog /var/log/httpd/site1-access.log combined
>>>>>>>>>>>
>>>>>>>>>>> <IfModule !mod_php7.c>
>>>>>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>>>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
>>>>>>>>>>> </FilesMatch>
>>>>>>>>>>> </IfModule>
>>>>>>>>>>> </VirtualHost>
>>>>>>>>>>>
>>>>>>>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
>>>>>>>>>>>
>>>>>>>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
>>>>>>>>>>>
>>>>>>>>>>> I must have missed some configuration step and would appreciate any pointers.
>>>>>>>>>>>
>>>>>>>>>>> Thank you.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>>>>>>
>>>>>>>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
>>>>>>>>>
>>>>>>>>> SetHandler "proxy:fcgi://localhost:9002
>>>>>>>>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
>>>>>>>>> AddHandler php70-fcgi .php
>>>>>>>>> Action php70-fcgi /cgi-bin/php70.fcgi
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>>>>
>>>>>>> This is what I did:
>>>>>>>
>>>>>>> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/librh-php70-php7.so" in the former and the equivalent in the latter.
>>>>>>>
>>>>>>> - For the the site1.conf I have:
>>>>>>>
>>>>>>> <VirtualHost *:80>
>>>>>>> ServerAdmin xxx
>>>>>>> ServerName x.x.x.x
>>>>>>> DocumentRoot /var/www/html/
>>>>>>> ErrorLog /var/log/httpd/site1-error.log
>>>>>>> CustomLog /var/log/httpd/site1-access.log combined
>>>>>>>
>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>> SetHandler "proxy:fcgi://localhost:9002"
>>>>>>> </FilesMatch>
>>>>>>> </VirtualHost>
>>>>>>>
>>>>>>> and for site2.conf
>>>>>>>
>>>>>>> <VirtualHost *:80>
>>>>>>> ServerAdmin xxx
>>>>>>> ServerName x.x.x.x
>>>>>>> DocumentRoot /var/www/html/
>>>>>>> ErrorLog /var/log/httpd/site2-error.log
>>>>>>> CustomLog /var/log/httpd/site2-access.log combined
>>>>>>>
>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>> SetHandler "proxy:fcgi://localhost:9003"
>>>>>>> </FilesMatch>
>>>>>>> </VirtualHost>
>>>>>>>
>>>>>>> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
>>>>>>>
>>>>>>> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
>>>>>>>
>>>>>>> So, there must be something more I need to do?
>>>>>>>
>>>>>>> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
>>>>>>>
>>>>>> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
>>>>>>
>>>>>> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
>>>>>>
>>>>>> And I restarted httpd after each change.
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>
>>>> This is from ps aux | grep fpm:
>>>>
>>>> root 17004 0.0 0.6 339008 11244 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php70/php-fpm.conf)
>>>> apache 17005 0.0 0.3 339112 7352 ? S 01:18 0:00 php-fpm: pool www
>>>> apache 17006 0.0 0.3 339112 7356 ? S 01:18 0:00 php-fpm: pool www
>>>> apache 17007 0.0 0.4 339252 8452 ? S 01:18 0:00 php-fpm: pool www
>>>> apache 17008 0.0 0.3 339112 7360 ? S 01:18 0:00 php-fpm: pool www
>>>> apache 17009 0.0 0.3 339112 7368 ? S 01:18 0:00 php-fpm: pool www
>>>> root 17036 0.0 0.9 562800 18540 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
>>>> apache 17037 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>>>> apache 17038 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>>>> apache 17039 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>>>> apache 17040 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>>>> apache 17041 0.0 0.3 562800 6980 ? S 01:18 0:00 php-fpm: pool www
>>>>
>>>> Does this not look correct?
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>
>> You write "both versions listening to each port", I have each version listening to its port, ie php 70 to 9002 and php 72 to 9003 as confirmed by netstat -tlpn.
>>
>> By the way, here are my httpd modules:
>>
>> Loaded Modules:
>> core_module (static)
>> so_module (static)
>> http_module (static)
>> access_compat_module (shared)
>> actions_module (shared)
>> alias_module (shared)
>> allowmethods_module (shared)
>> auth_basic_module (shared)
>> auth_digest_module (shared)
>> authn_anon_module (shared)
>> authn_core_module (shared)
>> authn_dbd_module (shared)
>> authn_dbm_module (shared)
>> authn_file_module (shared)
>> authn_socache_module (shared)
>> authz_core_module (shared)
>> authz_dbd_module (shared)
>> authz_dbm_module (shared)
>> authz_groupfile_module (shared)
>> authz_host_module (shared)
>> authz_owner_module (shared)
>> authz_user_module (shared)
>> autoindex_module (shared)
>> cache_module (shared)
>> cache_disk_module (shared)
>> data_module (shared)
>> dbd_module (shared)
>> deflate_module (shared)
>> dir_module (shared)
>> dumpio_module (shared)
>> echo_module (shared)
>> env_module (shared)
>> expires_module (shared)
>> ext_filter_module (shared)
>> filter_module (shared)
>> headers_module (shared)
>> include_module (shared)
>> info_module (shared)
>> log_config_module (shared)
>> logio_module (shared)
>> mime_magic_module (shared)
>> mime_module (shared)
>> negotiation_module (shared)
>> remoteip_module (shared)
>> reqtimeout_module (shared)
>> rewrite_module (shared)
>> setenvif_module (shared)
>> slotmem_plain_module (shared)
>> slotmem_shm_module (shared)
>> socache_dbm_module (shared)
>> socache_memcache_module (shared)
>> socache_shmcb_module (shared)
>> status_module (shared)
>> substitute_module (shared)
>> suexec_module (shared)
>> unique_id_module (shared)
>> unixd_module (shared)
>> userdir_module (shared)
>> version_module (shared)
>> vhost_alias_module (shared)
>> dav_module (shared)
>> dav_fs_module (shared)
>> dav_lock_module (shared)
>> lua_module (shared)
>> mpm_prefork_module (shared)
>> proxy_module (shared)
>> lbmethod_bybusyness_module (shared)
>> lbmethod_byrequests_module (shared)
>> lbmethod_bytraffic_module (shared)
>> lbmethod_heartbeat_module (shared)
>> proxy_ajp_module (shared)
>> proxy_balancer_module (shared)
>> proxy_connect_module (shared)
>> proxy_express_module (shared)
>> proxy_fcgi_module (shared)
>> proxy_fdpass_module (shared)
>> proxy_ftp_module (shared)
>> proxy_http_module (shared)
>> proxy_scgi_module (shared)
>> proxy_wstunnel_module (shared)
>> ssl_module (shared)
>> systemd_module (shared)
>> cgi_module (shared)
>> php7_module (shared)
>>
>> Does the above look correct? Should the last one, php7_module, be loaded since I am trying to run both 7.0 and 7.2?
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
I got rid of php7_module and now have two sites loading php 7.0 and one loading 7.2... The latter is nextcloud and it must be doing something different to load 7.2. My intent was for that to use 7.2, another one to also use 7.2 and one to use 7.0. However, only nextcloud loads 7.2 and the other two load 7.0.

I have double-checked the conf files and they seem to be pointing to the correct php versions...

You mention pruning the modules and specifically getting rid of php modules. Which ones should I prune?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
No, specifically pruning everything you don´t need.

That list of modules is not normal, and there is probably lots of
configuration associated with them you are not using either. If I were
you I would end up with a quite simple config with only the modules I
really need.


El vie, 9 abr 2021 a las 18:10, H (<agents@meddatainc.com>) escribió:
>
> On 04/09/2021 11:48 AM, Daniel Ferradal wrote:
> > That´s probably it. You still have php7_module, and are probably
> > pointing to it somewhere in your config. For the looks of it you need
> > a serious and thorough cleanup of your configuration that you haven´t
> > done yet.
> >
> > Like we told you earlier, get rid of that module.
> >
> > As for your question:
> > You just need mod_proxy and mod_proxy_fcgi to reverse proxy requests
> > to php-fpm, that´s it, you are reverse proxying requests for php files
> > to another service, and php-fpm will interpret those and return the
> > dynamic content to apache.
> > PHP libs have nothing to do in your Apache if you are using/want to
> > use php-fpm, which is a good path imo. So no, no php modules of any
> > kind in apache, apache will not do any more interpretation of php
> > code.
> >
> > Also let me take the liberty to tell you that you could take the
> > chance and clean that horrendous list of modules you will never use.
> >
> > Ideally you should just load those modules you use, no more no less.
> >
> > Ideally you will use mpm_event too, not mpm_prefork, but I don´t want
> > to distract you too much, focus on ridding everything php but the
> > mod_proxy mod_proxy_fcgi and the directives we mentioned earlier.
> >
> >
> > Cheers
> >
> >
> >
> > El vie, 9 abr 2021 a las 17:36, H (<agents@meddatainc.com>) escribió:
> >> On 04/09/2021 06:03 AM, Daniel Ferradal wrote:
> >>> Looks correct yes. But still lots of things you are not showing could be wrong.
> >>>
> >>> To solve issues you have to go one thing at a time, you know for sure
> >>> apache is pointing to different ports, if you disabled mod_php. Now
> >>> you must make sure the fpm pools are correct, both versions listening
> >>> to each port, that you disabled all mod_php stuff, etc. things we
> >>> can't see because you don't show, so it is quite hard to hand-guide
> >>> you with just small bits of info.
> >>>
> >>> El vie, 9 abr 2021 a las 3:26, H (<agents@meddatainc.com>) escribió:
> >>>> On 04/08/2021 08:57 PM, Daniel Ferradal wrote:
> >>>>> There is no such thing as default php version for a site.
> >>>>>
> >>>>> You have to make sure you have really two different instances of
> >>>>> php-fpm running for the different php versions you want to use.
> >>>>>
> >>>>> Chances are you have the same php-fpm service with two pools, so both
> >>>>> may be with the same version.
> >>>>>
> >>>>> Apache doesn't care what you do from now on, since it is just reverse
> >>>>> proxying requests to the selected servers. So it is up to you and your
> >>>>> php-fpm config and how you start them now.
> >>>>>
> >>>>> El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribió:
> >>>>>> On 04/08/2021 07:34 PM, H wrote:
> >>>>>>> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
> >>>>>>>> Hello,
> >>>>>>>>
> >>>>>>>> What you must remove is all scriptalias, addhandler/action directives.
> >>>>>>>> So I'd say with a directive for each virtualhost you mentioned you
> >>>>>>>> have you just would need (and of course disable mod_php module):
> >>>>>>>>
> >>>>>>>> In one for one version pointing to 9002 port:
> >>>>>>>> <FilesMatch \.(php|phar)$>
> >>>>>>>> SetHandler "proxy:fcgi://localhost:9002"
> >>>>>>>> </FilesMatch>
> >>>>>>>>
> >>>>>>>> In the other virtualhost you want to have pointing to 9003:
> >>>>>>>> <FilesMatch \.(php|phar)$>
> >>>>>>>> SetHandler "proxy:fcgi://localhost:9003"
> >>>>>>>> </FilesMatch>
> >>>>>>>>
> >>>>>>>> Apache is really much more simple and easier than many examples out
> >>>>>>>> there try to show.
> >>>>>>>>
> >>>>>>>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
> >>>>>>>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
> >>>>>>>>>> Hello,
> >>>>>>>>>>
> >>>>>>>>>> You mention PHP is set to listen to different tcp ports, yet the
> >>>>>>>>>> config you show from apache points to a unix socket with
> >>>>>>>>>> mod_proxy_fcgi
> >>>>>>>>>>
> >>>>>>>>>> Also worth mentioning you don't need php7_module at all when pointing
> >>>>>>>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
> >>>>>>>>>> case you have some other config lying around taking precedence and
> >>>>>>>>>> causing the problems you mention.
> >>>>>>>>>>
> >>>>>>>>>> Cheers
> >>>>>>>>>>
> >>>>>>>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
> >>>>>>>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
> >>>>>>>>>>>
> >>>>>>>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
> >>>>>>>>>>>
> >>>>>>>>>>> <VirtualHost *:80>
> >>>>>>>>>>> ServerAdmin xxx
> >>>>>>>>>>> ServerName x.x.x.x/site1
> >>>>>>>>>>> DocumentRoot /var/www/html/
> >>>>>>>>>>> DirectoryIndex info.php
> >>>>>>>>>>> ErrorLog /var/log/httpd/site1-error.log
> >>>>>>>>>>> CustomLog /var/log/httpd/site1-access.log combined
> >>>>>>>>>>>
> >>>>>>>>>>> <IfModule !mod_php7.c>
> >>>>>>>>>>> <FilesMatch \.(php|phar)$>
> >>>>>>>>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
> >>>>>>>>>>> </FilesMatch>
> >>>>>>>>>>> </IfModule>
> >>>>>>>>>>> </VirtualHost>
> >>>>>>>>>>>
> >>>>>>>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
> >>>>>>>>>>>
> >>>>>>>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
> >>>>>>>>>>>
> >>>>>>>>>>> I must have missed some configuration step and would appreciate any pointers.
> >>>>>>>>>>>
> >>>>>>>>>>> Thank you.
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> ---------------------------------------------------------------------
> >>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>>>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>>>>>>>>
> >>>>>>>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
> >>>>>>>>>
> >>>>>>>>> SetHandler "proxy:fcgi://localhost:9002
> >>>>>>>>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
> >>>>>>>>> AddHandler php70-fcgi .php
> >>>>>>>>> Action php70-fcgi /cgi-bin/php70.fcgi
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> ---------------------------------------------------------------------
> >>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>>>>>>
> >>>>>>> This is what I did:
> >>>>>>>
> >>>>>>> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/librh-php70-php7.so" in the former and the equivalent in the latter.
> >>>>>>>
> >>>>>>> - For the the site1.conf I have:
> >>>>>>>
> >>>>>>> <VirtualHost *:80>
> >>>>>>> ServerAdmin xxx
> >>>>>>> ServerName x.x.x.x
> >>>>>>> DocumentRoot /var/www/html/
> >>>>>>> ErrorLog /var/log/httpd/site1-error.log
> >>>>>>> CustomLog /var/log/httpd/site1-access.log combined
> >>>>>>>
> >>>>>>> <FilesMatch \.(php|phar)$>
> >>>>>>> SetHandler "proxy:fcgi://localhost:9002"
> >>>>>>> </FilesMatch>
> >>>>>>> </VirtualHost>
> >>>>>>>
> >>>>>>> and for site2.conf
> >>>>>>>
> >>>>>>> <VirtualHost *:80>
> >>>>>>> ServerAdmin xxx
> >>>>>>> ServerName x.x.x.x
> >>>>>>> DocumentRoot /var/www/html/
> >>>>>>> ErrorLog /var/log/httpd/site2-error.log
> >>>>>>> CustomLog /var/log/httpd/site2-access.log combined
> >>>>>>>
> >>>>>>> <FilesMatch \.(php|phar)$>
> >>>>>>> SetHandler "proxy:fcgi://localhost:9003"
> >>>>>>> </FilesMatch>
> >>>>>>> </VirtualHost>
> >>>>>>>
> >>>>>>> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
> >>>>>>>
> >>>>>>> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
> >>>>>>>
> >>>>>>> So, there must be something more I need to do?
> >>>>>>>
> >>>>>>> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
> >>>>>>>
> >>>>>> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
> >>>>>>
> >>>>>> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
> >>>>>>
> >>>>>> And I restarted httpd after each change.
> >>>>>>
> >>>>>>
> >>>>>> ---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>>>
> >>>> This is from ps aux | grep fpm:
> >>>>
> >>>> root 17004 0.0 0.6 339008 11244 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php70/php-fpm.conf)
> >>>> apache 17005 0.0 0.3 339112 7352 ? S 01:18 0:00 php-fpm: pool www
> >>>> apache 17006 0.0 0.3 339112 7356 ? S 01:18 0:00 php-fpm: pool www
> >>>> apache 17007 0.0 0.4 339252 8452 ? S 01:18 0:00 php-fpm: pool www
> >>>> apache 17008 0.0 0.3 339112 7360 ? S 01:18 0:00 php-fpm: pool www
> >>>> apache 17009 0.0 0.3 339112 7368 ? S 01:18 0:00 php-fpm: pool www
> >>>> root 17036 0.0 0.9 562800 18540 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
> >>>> apache 17037 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> >>>> apache 17038 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> >>>> apache 17039 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> >>>> apache 17040 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
> >>>> apache 17041 0.0 0.3 562800 6980 ? S 01:18 0:00 php-fpm: pool www
> >>>>
> >>>> Does this not look correct?
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>>
> >> You write "both versions listening to each port", I have each version listening to its port, ie php 70 to 9002 and php 72 to 9003 as confirmed by netstat -tlpn.
> >>
> >> By the way, here are my httpd modules:
> >>
> >> Loaded Modules:
> >> core_module (static)
> >> so_module (static)
> >> http_module (static)
> >> access_compat_module (shared)
> >> actions_module (shared)
> >> alias_module (shared)
> >> allowmethods_module (shared)
> >> auth_basic_module (shared)
> >> auth_digest_module (shared)
> >> authn_anon_module (shared)
> >> authn_core_module (shared)
> >> authn_dbd_module (shared)
> >> authn_dbm_module (shared)
> >> authn_file_module (shared)
> >> authn_socache_module (shared)
> >> authz_core_module (shared)
> >> authz_dbd_module (shared)
> >> authz_dbm_module (shared)
> >> authz_groupfile_module (shared)
> >> authz_host_module (shared)
> >> authz_owner_module (shared)
> >> authz_user_module (shared)
> >> autoindex_module (shared)
> >> cache_module (shared)
> >> cache_disk_module (shared)
> >> data_module (shared)
> >> dbd_module (shared)
> >> deflate_module (shared)
> >> dir_module (shared)
> >> dumpio_module (shared)
> >> echo_module (shared)
> >> env_module (shared)
> >> expires_module (shared)
> >> ext_filter_module (shared)
> >> filter_module (shared)
> >> headers_module (shared)
> >> include_module (shared)
> >> info_module (shared)
> >> log_config_module (shared)
> >> logio_module (shared)
> >> mime_magic_module (shared)
> >> mime_module (shared)
> >> negotiation_module (shared)
> >> remoteip_module (shared)
> >> reqtimeout_module (shared)
> >> rewrite_module (shared)
> >> setenvif_module (shared)
> >> slotmem_plain_module (shared)
> >> slotmem_shm_module (shared)
> >> socache_dbm_module (shared)
> >> socache_memcache_module (shared)
> >> socache_shmcb_module (shared)
> >> status_module (shared)
> >> substitute_module (shared)
> >> suexec_module (shared)
> >> unique_id_module (shared)
> >> unixd_module (shared)
> >> userdir_module (shared)
> >> version_module (shared)
> >> vhost_alias_module (shared)
> >> dav_module (shared)
> >> dav_fs_module (shared)
> >> dav_lock_module (shared)
> >> lua_module (shared)
> >> mpm_prefork_module (shared)
> >> proxy_module (shared)
> >> lbmethod_bybusyness_module (shared)
> >> lbmethod_byrequests_module (shared)
> >> lbmethod_bytraffic_module (shared)
> >> lbmethod_heartbeat_module (shared)
> >> proxy_ajp_module (shared)
> >> proxy_balancer_module (shared)
> >> proxy_connect_module (shared)
> >> proxy_express_module (shared)
> >> proxy_fcgi_module (shared)
> >> proxy_fdpass_module (shared)
> >> proxy_ftp_module (shared)
> >> proxy_http_module (shared)
> >> proxy_scgi_module (shared)
> >> proxy_wstunnel_module (shared)
> >> ssl_module (shared)
> >> systemd_module (shared)
> >> cgi_module (shared)
> >> php7_module (shared)
> >>
> >> Does the above look correct? Should the last one, php7_module, be loaded since I am trying to run both 7.0 and 7.2?
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >> For additional commands, e-mail: users-help@httpd.apache.org
> >>
> >
> I got rid of php7_module and now have two sites loading php 7.0 and one loading 7.2... The latter is nextcloud and it must be doing something different to load 7.2. My intent was for that to use 7.2, another one to also use 7.2 and one to use 7.0. However, only nextcloud loads 7.2 and the other two load 7.0.
>
> I have double-checked the conf files and they seem to be pointing to the correct php versions...
>
> You mention pruning the modules and specifically getting rid of php modules. Which ones should I prune?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


--
Daniel Ferradal
HTTPD Project
#httpd help at Freenode

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
On 04/09/2021 12:18 PM, Daniel Ferradal wrote:
> No, specifically pruning everything you don´t need.
>
> That list of modules is not normal, and there is probably lots of
> configuration associated with them you are not using either. If I were
> you I would end up with a quite simple config with only the modules I
> really need.
>
>
> El vie, 9 abr 2021 a las 18:10, H (<agents@meddatainc.com>) escribió:
>> On 04/09/2021 11:48 AM, Daniel Ferradal wrote:
>>> That´s probably it. You still have php7_module, and are probably
>>> pointing to it somewhere in your config. For the looks of it you need
>>> a serious and thorough cleanup of your configuration that you haven´t
>>> done yet.
>>>
>>> Like we told you earlier, get rid of that module.
>>>
>>> As for your question:
>>> You just need mod_proxy and mod_proxy_fcgi to reverse proxy requests
>>> to php-fpm, that´s it, you are reverse proxying requests for php files
>>> to another service, and php-fpm will interpret those and return the
>>> dynamic content to apache.
>>> PHP libs have nothing to do in your Apache if you are using/want to
>>> use php-fpm, which is a good path imo. So no, no php modules of any
>>> kind in apache, apache will not do any more interpretation of php
>>> code.
>>>
>>> Also let me take the liberty to tell you that you could take the
>>> chance and clean that horrendous list of modules you will never use.
>>>
>>> Ideally you should just load those modules you use, no more no less.
>>>
>>> Ideally you will use mpm_event too, not mpm_prefork, but I don´t want
>>> to distract you too much, focus on ridding everything php but the
>>> mod_proxy mod_proxy_fcgi and the directives we mentioned earlier.
>>>
>>>
>>> Cheers
>>>
>>>
>>>
>>> El vie, 9 abr 2021 a las 17:36, H (<agents@meddatainc.com>) escribió:
>>>> On 04/09/2021 06:03 AM, Daniel Ferradal wrote:
>>>>> Looks correct yes. But still lots of things you are not showing could be wrong.
>>>>>
>>>>> To solve issues you have to go one thing at a time, you know for sure
>>>>> apache is pointing to different ports, if you disabled mod_php. Now
>>>>> you must make sure the fpm pools are correct, both versions listening
>>>>> to each port, that you disabled all mod_php stuff, etc. things we
>>>>> can't see because you don't show, so it is quite hard to hand-guide
>>>>> you with just small bits of info.
>>>>>
>>>>> El vie, 9 abr 2021 a las 3:26, H (<agents@meddatainc.com>) escribió:
>>>>>> On 04/08/2021 08:57 PM, Daniel Ferradal wrote:
>>>>>>> There is no such thing as default php version for a site.
>>>>>>>
>>>>>>> You have to make sure you have really two different instances of
>>>>>>> php-fpm running for the different php versions you want to use.
>>>>>>>
>>>>>>> Chances are you have the same php-fpm service with two pools, so both
>>>>>>> may be with the same version.
>>>>>>>
>>>>>>> Apache doesn't care what you do from now on, since it is just reverse
>>>>>>> proxying requests to the selected servers. So it is up to you and your
>>>>>>> php-fpm config and how you start them now.
>>>>>>>
>>>>>>> El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribió:
>>>>>>>> On 04/08/2021 07:34 PM, H wrote:
>>>>>>>>> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
>>>>>>>>>> Hello,
>>>>>>>>>>
>>>>>>>>>> What you must remove is all scriptalias, addhandler/action directives.
>>>>>>>>>> So I'd say with a directive for each virtualhost you mentioned you
>>>>>>>>>> have you just would need (and of course disable mod_php module):
>>>>>>>>>>
>>>>>>>>>> In one for one version pointing to 9002 port:
>>>>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>>>>> SetHandler "proxy:fcgi://localhost:9002"
>>>>>>>>>> </FilesMatch>
>>>>>>>>>>
>>>>>>>>>> In the other virtualhost you want to have pointing to 9003:
>>>>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>>>>> SetHandler "proxy:fcgi://localhost:9003"
>>>>>>>>>> </FilesMatch>
>>>>>>>>>>
>>>>>>>>>> Apache is really much more simple and easier than many examples out
>>>>>>>>>> there try to show.
>>>>>>>>>>
>>>>>>>>>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribió:
>>>>>>>>>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
>>>>>>>>>>>> Hello,
>>>>>>>>>>>>
>>>>>>>>>>>> You mention PHP is set to listen to different tcp ports, yet the
>>>>>>>>>>>> config you show from apache points to a unix socket with
>>>>>>>>>>>> mod_proxy_fcgi
>>>>>>>>>>>>
>>>>>>>>>>>> Also worth mentioning you don't need php7_module at all when pointing
>>>>>>>>>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
>>>>>>>>>>>> case you have some other config lying around taking precedence and
>>>>>>>>>>>> causing the problems you mention.
>>>>>>>>>>>>
>>>>>>>>>>>> Cheers
>>>>>>>>>>>>
>>>>>>>>>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribió:
>>>>>>>>>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
>>>>>>>>>>>>>
>>>>>>>>>>>>> <VirtualHost *:80>
>>>>>>>>>>>>> ServerAdmin xxx
>>>>>>>>>>>>> ServerName x.x.x.x/site1
>>>>>>>>>>>>> DocumentRoot /var/www/html/
>>>>>>>>>>>>> DirectoryIndex info.php
>>>>>>>>>>>>> ErrorLog /var/log/httpd/site1-error.log
>>>>>>>>>>>>> CustomLog /var/log/httpd/site1-access.log combined
>>>>>>>>>>>>>
>>>>>>>>>>>>> <IfModule !mod_php7.c>
>>>>>>>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>>>>>>>> SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
>>>>>>>>>>>>> </FilesMatch>
>>>>>>>>>>>>> </IfModule>
>>>>>>>>>>>>> </VirtualHost>
>>>>>>>>>>>>>
>>>>>>>>>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I must have missed some configuration step and would appreciate any pointers.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thank you.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>>>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
>>>>>>>>>>>
>>>>>>>>>>> SetHandler "proxy:fcgi://localhost:9002
>>>>>>>>>>> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
>>>>>>>>>>> AddHandler php70-fcgi .php
>>>>>>>>>>> Action php70-fcgi /cgi-bin/php70.fcgi
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>>>>>>
>>>>>>>>> This is what I did:
>>>>>>>>>
>>>>>>>>> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/librh-php70-php7.so" in the former and the equivalent in the latter.
>>>>>>>>>
>>>>>>>>> - For the the site1.conf I have:
>>>>>>>>>
>>>>>>>>> <VirtualHost *:80>
>>>>>>>>> ServerAdmin xxx
>>>>>>>>> ServerName x.x.x.x
>>>>>>>>> DocumentRoot /var/www/html/
>>>>>>>>> ErrorLog /var/log/httpd/site1-error.log
>>>>>>>>> CustomLog /var/log/httpd/site1-access.log combined
>>>>>>>>>
>>>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>>>> SetHandler "proxy:fcgi://localhost:9002"
>>>>>>>>> </FilesMatch>
>>>>>>>>> </VirtualHost>
>>>>>>>>>
>>>>>>>>> and for site2.conf
>>>>>>>>>
>>>>>>>>> <VirtualHost *:80>
>>>>>>>>> ServerAdmin xxx
>>>>>>>>> ServerName x.x.x.x
>>>>>>>>> DocumentRoot /var/www/html/
>>>>>>>>> ErrorLog /var/log/httpd/site2-error.log
>>>>>>>>> CustomLog /var/log/httpd/site2-access.log combined
>>>>>>>>>
>>>>>>>>> <FilesMatch \.(php|phar)$>
>>>>>>>>> SetHandler "proxy:fcgi://localhost:9003"
>>>>>>>>> </FilesMatch>
>>>>>>>>> </VirtualHost>
>>>>>>>>>
>>>>>>>>> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
>>>>>>>>>
>>>>>>>>> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
>>>>>>>>>
>>>>>>>>> So, there must be something more I need to do?
>>>>>>>>>
>>>>>>>>> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
>>>>>>>>>
>>>>>>>> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
>>>>>>>>
>>>>>>>> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
>>>>>>>>
>>>>>>>> And I restarted httpd after each change.
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>>>
>>>>>> This is from ps aux | grep fpm:
>>>>>>
>>>>>> root 17004 0.0 0.6 339008 11244 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php70/php-fpm.conf)
>>>>>> apache 17005 0.0 0.3 339112 7352 ? S 01:18 0:00 php-fpm: pool www
>>>>>> apache 17006 0.0 0.3 339112 7356 ? S 01:18 0:00 php-fpm: pool www
>>>>>> apache 17007 0.0 0.4 339252 8452 ? S 01:18 0:00 php-fpm: pool www
>>>>>> apache 17008 0.0 0.3 339112 7360 ? S 01:18 0:00 php-fpm: pool www
>>>>>> apache 17009 0.0 0.3 339112 7368 ? S 01:18 0:00 php-fpm: pool www
>>>>>> root 17036 0.0 0.9 562800 18540 ? Ss 01:18 0:00 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
>>>>>> apache 17037 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>>>>>> apache 17038 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>>>>>> apache 17039 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>>>>>> apache 17040 0.0 0.3 562800 6976 ? S 01:18 0:00 php-fpm: pool www
>>>>>> apache 17041 0.0 0.3 562800 6980 ? S 01:18 0:00 php-fpm: pool www
>>>>>>
>>>>>> Does this not look correct?
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>>
>>>> You write "both versions listening to each port", I have each version listening to its port, ie php 70 to 9002 and php 72 to 9003 as confirmed by netstat -tlpn.
>>>>
>>>> By the way, here are my httpd modules:
>>>>
>>>> Loaded Modules:
>>>> core_module (static)
>>>> so_module (static)
>>>> http_module (static)
>>>> access_compat_module (shared)
>>>> actions_module (shared)
>>>> alias_module (shared)
>>>> allowmethods_module (shared)
>>>> auth_basic_module (shared)
>>>> auth_digest_module (shared)
>>>> authn_anon_module (shared)
>>>> authn_core_module (shared)
>>>> authn_dbd_module (shared)
>>>> authn_dbm_module (shared)
>>>> authn_file_module (shared)
>>>> authn_socache_module (shared)
>>>> authz_core_module (shared)
>>>> authz_dbd_module (shared)
>>>> authz_dbm_module (shared)
>>>> authz_groupfile_module (shared)
>>>> authz_host_module (shared)
>>>> authz_owner_module (shared)
>>>> authz_user_module (shared)
>>>> autoindex_module (shared)
>>>> cache_module (shared)
>>>> cache_disk_module (shared)
>>>> data_module (shared)
>>>> dbd_module (shared)
>>>> deflate_module (shared)
>>>> dir_module (shared)
>>>> dumpio_module (shared)
>>>> echo_module (shared)
>>>> env_module (shared)
>>>> expires_module (shared)
>>>> ext_filter_module (shared)
>>>> filter_module (shared)
>>>> headers_module (shared)
>>>> include_module (shared)
>>>> info_module (shared)
>>>> log_config_module (shared)
>>>> logio_module (shared)
>>>> mime_magic_module (shared)
>>>> mime_module (shared)
>>>> negotiation_module (shared)
>>>> remoteip_module (shared)
>>>> reqtimeout_module (shared)
>>>> rewrite_module (shared)
>>>> setenvif_module (shared)
>>>> slotmem_plain_module (shared)
>>>> slotmem_shm_module (shared)
>>>> socache_dbm_module (shared)
>>>> socache_memcache_module (shared)
>>>> socache_shmcb_module (shared)
>>>> status_module (shared)
>>>> substitute_module (shared)
>>>> suexec_module (shared)
>>>> unique_id_module (shared)
>>>> unixd_module (shared)
>>>> userdir_module (shared)
>>>> version_module (shared)
>>>> vhost_alias_module (shared)
>>>> dav_module (shared)
>>>> dav_fs_module (shared)
>>>> dav_lock_module (shared)
>>>> lua_module (shared)
>>>> mpm_prefork_module (shared)
>>>> proxy_module (shared)
>>>> lbmethod_bybusyness_module (shared)
>>>> lbmethod_byrequests_module (shared)
>>>> lbmethod_bytraffic_module (shared)
>>>> lbmethod_heartbeat_module (shared)
>>>> proxy_ajp_module (shared)
>>>> proxy_balancer_module (shared)
>>>> proxy_connect_module (shared)
>>>> proxy_express_module (shared)
>>>> proxy_fcgi_module (shared)
>>>> proxy_fdpass_module (shared)
>>>> proxy_ftp_module (shared)
>>>> proxy_http_module (shared)
>>>> proxy_scgi_module (shared)
>>>> proxy_wstunnel_module (shared)
>>>> ssl_module (shared)
>>>> systemd_module (shared)
>>>> cgi_module (shared)
>>>> php7_module (shared)
>>>>
>>>> Does the above look correct? Should the last one, php7_module, be loaded since I am trying to run both 7.0 and 7.2?
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>
>> I got rid of php7_module and now have two sites loading php 7.0 and one loading 7.2... The latter is nextcloud and it must be doing something different to load 7.2. My intent was for that to use 7.2, another one to also use 7.2 and one to use 7.0. However, only nextcloud loads 7.2 and the other two load 7.0.
>>
>> I have double-checked the conf files and they seem to be pointing to the correct php versions...
>>
>> You mention pruning the modules and specifically getting rid of php modules. Which ones should I prune?
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
I just looked at my notes on what I have installed on this server and when. I cannot find any extraneous apache modules in my notes so it should be a vanilla installation of httpd. Since I am not an apache expert, it would be foolish of me to just start removing stuff without understanding why I am doing it.

But, surely there must be some kind of authoritative documentation on how to accomplish what I am seeking to do? As I said, I have found a number of web pages but who knows if they are correct or not?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Running php 7.0 and 7.2 for different websites with apache [ In reply to ]
On 04/09/2021 11:29 AM, H wrote:
> On 04/08/2021 09:30 PM, Bender, Charles wrote:
>> You're making this very difficult for yourself by having 2 different versions of PHP installed on 1 server box. Even if you get working maintaining will be challenging.
>>
>> Suggestion- run PHP and PHP-FPM in separate Docker containers on same server, each with specific version of PHP you need. Then have Apache proxy to these containers as required
>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>> *From:* H <agents@meddatainc.com>
>> *Sent:* Thursday, April 8, 2021 9:26 PM
>> *To:* users@httpd.apache.org <users@httpd.apache.org>
>> *Subject:* Re: [users@httpd] Running php 7.0 and 7.2 for different websites with apache
>> ?
>> On 04/08/2021 08:57 PM, Daniel Ferradal wrote:
>> > There is no such thing as default php version for a site.
>> >
>> > You have to make sure you have really two different instances of
>> > php-fpm running for the different php versions you want to use.
>> >
>> > Chances are you have the same php-fpm service with two pools, so both
>> > may be with the same version.
>> >
>> > Apache doesn't care what you do from now on, since it is just reverse
>> > proxying requests to the selected servers. So it is up to you and your
>> > php-fpm config and how you start them now.
>> >
>> > El vie, 9 abr 2021 a las 1:55, H (<agents@meddatainc.com>) escribi?:
>> >> On 04/08/2021 07:34 PM, H wrote:
>> >>> On 04/08/2021 06:05 PM, Daniel Ferradal wrote:
>> >>>> Hello,
>> >>>>
>> >>>> What you must remove is all scriptalias, addhandler/action directives.
>> >>>> So I'd say with a directive for each virtualhost you mentioned you
>> >>>> have you just would need (and of course disable mod_php module):
>> >>>>
>> >>>> In one for one version pointing to 9002 port:
>> >>>> <FilesMatch \.(php|phar)$>
>> >>>>???? SetHandler? "proxy:fcgi://localhost:9002"
>> >>>> </FilesMatch>
>> >>>>
>> >>>> In the other virtualhost you? want to have pointing to 9003:
>> >>>> <FilesMatch \.(php|phar)$>
>> >>>>???? SetHandler? "proxy:fcgi://localhost:9003"
>> >>>> </FilesMatch>
>> >>>>
>> >>>> Apache is really much more simple and easier than many examples out
>> >>>> there try to show.
>> >>>>
>> >>>> El jue, 8 abr 2021 a las 23:54, H (<agents@meddatainc.com>) escribi?:
>> >>>>> On 04/08/2021 05:06 PM, Daniel Ferradal wrote:
>> >>>>>> Hello,
>> >>>>>>
>> >>>>>> You mention PHP is set to listen to different tcp ports, yet the
>> >>>>>> config you show from apache points to a unix socket with
>> >>>>>> mod_proxy_fcgi
>> >>>>>>
>> >>>>>> Also worth mentioning you don't need php7_module at all when pointing
>> >>>>>> to FPM with mod_proxy_fcgi, so I would just unload that module asap in
>> >>>>>> case you have some other config lying around taking precedence and
>> >>>>>> causing the problems you mention.
>> >>>>>>
>> >>>>>> Cheers
>> >>>>>>
>> >>>>>> El jue, 8 abr 2021 a las 22:40, H (<agents@meddatainc.com>) escribi?:
>> >>>>>>> Using CentOS 7 and need to run two different versions of php for the websites, php 7.0 and 7.2. The set up is x.x.x.x/site1 and x.x.x.x/site2 and I am using php-fm for both php versions configuring port 9002 for php 7.0 and 9003 for php 7.2.
>> >>>>>>>
>> >>>>>>> I have a conf file for each site (this is site 1 which is supposed to run php 7.0) and called site1.conf, similar to:
>> >>>>>>>
>> >>>>>>> <VirtualHost *:80>
>> >>>>>>>???????? ServerAdmin xxx
>> >>>>>>>???????? ServerName x.x.x.x/site1
>> >>>>>>>???????? DocumentRoot /var/www/html/
>> >>>>>>>???????? DirectoryIndex info.php
>> >>>>>>>???????? ErrorLog /var/log/httpd/site1-error.log
>> >>>>>>>???????? CustomLog /var/log/httpd/site1-access.log combined
>> >>>>>>>
>> >>>>>>>???? <IfModule !mod_php7.c>
>> >>>>>>>???????? <FilesMatch \.(php|phar)$>
>> >>>>>>>???????????? SetHandler "proxy:unix:/var/opt/rh/rh-php70/run/php-fpm/www.sock|fcgi://localhost"
>> >>>>>>>???????? </FilesMatch>
>> >>>>>>>???? </IfModule>
>> >>>>>>> </VirtualHost>
>> >>>>>>>
>> >>>>>>> The other site is identical and supposed to run php 7.2 so the file obviously uses site2 instead of site1 and php72 instead of php70.
>> >>>>>>>
>> >>>>>>> I have installed both php versions and can successfully switch between them on the commandline but have run into problem getting apache to use both. I consulted https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.digitalocean.com%2fcommunity%2ftutorials%2fhow-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-7&c=E,1,nGU2QIv_y4smfnrUNnx9CDP8bkt1CgBCY00J7ykv7wIqnjBmryO1KuEik3Og-vkjZWpESUYdCo9JVJ3o77e7nOazFVuJCoH57Wvd5gM1XdQ,&typo=1 but apachectl configtest complains that "module php7_module is already loaded, skipping". I can successfully get the websites to use the same php version, either 7.0 or 7.2.
>> >>>>>>>
>> >>>>>>> I must have missed some configuration step and would appreciate any pointers.
>> >>>>>>>
>> >>>>>>> Thank you.
>> >>>>>>>
>> >>>>>>>
>> >>>>>>> ---------------------------------------------------------------------
>> >>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> >>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>> >>>>>>>
>> >>>>> Thank you for your quick reply. I am sort of dabbling with apache and am not 100% sure what I need to change but would the following change to the above conf file be what you are telling me?
>> >>>>>
>> >>>>>????? SetHandler "proxy:fcgi://localhost:9002
>> >>>>>????? ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
>> >>>>>????? AddHandler php70-fcgi .php
>> >>>>>????? Action php70-fcgi /cgi-bin/php70.fcgi
>> >>>>>
>> >>>>>
>> >>>>> ---------------------------------------------------------------------
>> >>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> >>>>> For additional commands, e-mail: users-help@httpd.apache.org
>> >>>>>
>> >>> This is what I did:
>> >>>
>> >>> - I disabled what I think are the php_mod statements in both 15-rh-php70-php.conf and 15-rh-php72-php.conf by inserting #disabled in front of "LoadModule php7_module modules/https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flibrh-php70-php7.so&c=E,1,ObjWDSRkeobJmAvtgGDv7IZhOuViBCsywRH4WTkNPs2Zia5LKubUYQ80Kog5ge58me6QKtwGLdOjH_AqFDhPNxL5rUy39Dx47NdG4foHL0fSSrc,&typo=1" in the former and the equivalent in the latter.
>> >>>
>> >>> - For the the site1.conf I have:
>> >>>
>> >>> <VirtualHost *:80>
>> >>>???????? ServerAdmin xxx
>> >>>???????? ServerName x.x.x.x
>> >>>???????? DocumentRoot /var/www/html/
>> >>>???????? ErrorLog /var/log/httpd/site1-error.log
>> >>>???????? CustomLog /var/log/httpd/site1-access.log combined
>> >>>
>> >>>???????? <FilesMatch \.(php|phar)$>
>> >>>???????????????? SetHandler "proxy:fcgi://localhost:9002"
>> >>>???????? </FilesMatch>
>> >>> </VirtualHost>
>> >>>
>> >>> and for site2.conf
>> >>>
>> >>> <VirtualHost *:80>
>> >>>???????? ServerAdmin xxx
>> >>>???????? ServerName x.x.x.x
>> >>>???????? DocumentRoot /var/www/html/
>> >>>???????? ErrorLog /var/log/httpd/site2-error.log
>> >>>???????? CustomLog /var/log/httpd/site2-access.log combined
>> >>>
>> >>>???????? <FilesMatch \.(php|phar)$>
>> >>>???????????????? SetHandler "proxy:fcgi://localhost:9003"
>> >>>???????? </FilesMatch>
>> >>> </VirtualHost>
>> >>>
>> >>> - I have checked that I have both rh-php70-php-fpm and rh-php72-php-fpm running and one is listening on port 9002 and the other on 9003.
>> >>>
>> >>> Yet, when I check the php version in a html page in each of the site directories I only see php 7.0 loading.
>> >>>
>> >>> So, there must be something more I need to do?
>> >>>
>> >>> Another question, I found that the Customlogs above catch messages from all sites, not just site1 or site2 respectively. How can I change so that each CustomLog only catches accesses for that particular site?
>> >>>
>> >> How does the system define which the "default" php version for a particular site? Or is there no default and I have to write a eg site3.conf file specifying the port for each site?
>> >>
>> >> I should have added that I access the sites like this: x.x.x.x/site1 and x.x.x.x/site2 etc.
>> >>
>> >> And I restarted httpd after each change.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> >> For additional commands, e-mail: users-help@httpd.apache.org
>> >>
>> >
>> This is from ps aux | grep fpm:
>>
>> root???? 17004? 0.0? 0.6 339008 11244 ???????? Ss?? 01:18?? 0:00 php-fpm: master process (/etc/opt/rh/rh-php70/php-fpm.conf)
>> apache?? 17005? 0.0? 0.3 339112? 7352 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>> apache?? 17006? 0.0? 0.3 339112? 7356 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>> apache?? 17007? 0.0? 0.4 339252? 8452 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>> apache?? 17008? 0.0? 0.3 339112? 7360 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>> apache?? 17009? 0.0? 0.3 339112? 7368 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>> root???? 17036? 0.0? 0.9 562800 18540 ???????? Ss?? 01:18?? 0:00 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
>> apache?? 17037? 0.0? 0.3 562800? 6976 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>> apache?? 17038? 0.0? 0.3 562800? 6976 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>> apache?? 17039? 0.0? 0.3 562800? 6976 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>> apache?? 17040? 0.0? 0.3 562800? 6976 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>> apache?? 17041? 0.0? 0.3 562800? 6980 ???????? S??? 01:18?? 0:00 php-fpm: pool www
>>
>> Does this not look correct?
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
> Possibly but there are many webpages that purportedly tell you how to configure a CentOS 7 server to serve different php versions to different sites. Some of them use serve both 7.0 and 7.2.
>
>
> Obviously there is something I have missed.
>
By the way, in my experience docker is a great tool but must be used with caution. There is often the risk of solving one set of problems by using docker yet creating another set that is related to the docker installation.