Re: Running php 7.0 and 7.2 for different websites with apache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>) 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@xxxxxxxxxxxxxx>) 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@xxxxxxxxxxxxxx>) 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@xxxxxxxxxxxxxxxx
>>>>>>> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>>>>>>>
>>>>> 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@xxxxxxxxxxxxxxxx
>>>>> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>>>>>
>>> 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@xxxxxxxxxxxxxxxx
>> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>>
>
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@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux