Multiple versions of PHP-FPM, installing and configuring…?

南楼画角 提交于 2021-01-28 09:00:52

问题


I should have asked here days ago - i've been trying to get multiple versions of PHP-FPM running under different virtual hosts.

System: Centos 7 w/ Centos Web Panel (CWP), PHP 5.6/7.0/7.1/7.2, Apache 2.4

I have my versions of PHP under /opt/alt/phpXX/usr i.e. /opt/alt/php72/usr

Example virtual host contents (website runs under PHP7.2):-

<Directory "/home/bbb/public_html">
    AddHandler application/x-httpd-php72 .php
    AllowOverride All
</Directory>

What i've tried so far is adding this to the virtual host...

<IfModule proxy_fcgi_module>
    <FilesMatch \.(phtml|php[0-9]*)$>
        SetHandler proxy:unix:/opt/alt/php72/usr/var/run/php-fpm/bbb.sock|fcgi://bbb
    </FilesMatch>
</IfModule>

But the PHP-FPM service running on the server is the default package installed via yum (version 5.4.16). Its binary runs from /usr/sbin and reads from /etc/php-fpm.d/xxx.conf and /etc/php.ini.

Question..

How do I start/run the actual PHP-FPM executable located in the appropriate PHP installation i.e. /opt/alt/php72/usr/sbin/php-fpm?

Many thanks


回答1:


Think i've sorted it...wish I'd posted this question yesterday...you always figure it out right after posting...!

I basically set up my own systemd service pointing to the php-fpm executable, following this guide - https://scottlinux.com/2014/12/08/how-to-create-a-systemd-service-in-linux-centos-7/

I copied the contents of another php-fpm service on the system, created a new service in /usr/lib/systemd/system/php72-phpfpm.service, and this is what I came up with...

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
#PIDFile=/usr/local/cwp/php71/var/run/cwp-php-fpm.pid
ExecStart=/opt/alt/php72/usr/sbin/php-fpm --nodaemonize --fpm-config /opt/alt/php72/usr/etc/php-fpm.conf -R
ExecReload=/bin/kill -USR2 $MAINPID
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Then just start, enable, restart the service as normal with systemctl.

Hope that helps others...



来源:https://stackoverflow.com/questions/48709936/multiple-versions-of-php-fpm-installing-and-configuring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!