Author Topic: Configure PHP 7 with NGINX in CWP  (Read 17131 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Configure PHP 7 with NGINX in CWP
« on: February 17, 2018, 08:34:01 AM »
Hi
I have compiled php 7.1 using CentOS web panel successfully and files are generated inside /opt/alt/php71. I have checked the per folder/per site configuration for multiple php version in http://wiki.centos-webpanel.com/php-selector

Since i am using NGINX, i need to configure php7-fpm as well but i have the default php-fpm from the earlier php version in /etc/php-fpm.d The phpinfo page served by NGINX still shows old php version with loaded configuration file /etc/php.ini and Scan this dir for additional .ini files in /etc/php.d. I want old php version 5.6 to be the default and the newer php 7.1 to be configured for one subdomain using NGINX/FPM.

Will appreciate if anyone guides me

Regards



Offline
*
Re: Configure PHP 7 with NGINX in CWP
« Reply #2 on: February 17, 2018, 11:05:39 AM »
Hi
I think php7-fpm can be configured manually. I had issued following commands and configured 2 files and found both original php-fpm service and new php7-fpm service are running and i can confirm the same by visiting the phpinfo page that it is actually loading php7-fpm.

$ sudo mkdir /opt/alt/php71/usr/etc/conf.d
$ sudo cp -v ./php.ini-production /opt/alt/php71/usr/lib/php.ini
$ sudo cp -v ./sapi/fpm/www.conf /opt/alt/php71/usr/etc/php-fpm.d/www.conf
$ sudo cp -v ./sapi/fpm/php-fpm.conf /opt/alt/php71/usr/etc/php7-fpm.conf



$ vi /opt/alt/php71/usr/etc/conf.d/modules.ini

# Zend OPcache
zend_extension=opcache.so

$ vi /opt/alt/php71/usr/etc/php-fpm.d/www.conf


user = nginx
group = nginx
 
listen = /var/run/php7-fpm.sock
 
listen.owner = nginx
listen.group = nginx

$ sudo ln -s /opt/alt/php71/usr/sbin/php-fpm /usr/sbin/php7-fpm

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

[Service]
Type=simple
PIDFile=/var/run/php-fpm.pid
ExecStart=/usr/sbin/php7-fpm --nodaemonize --fpm-config /opt/alt/php71/usr/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target


$ chkconfig --levels 235 php-fpm on
$ systemctl start php-fpm




Re: Configure PHP 7 with NGINX in CWP
« Reply #3 on: February 17, 2018, 11:23:30 AM »
good input! Though the switcher should save you from the manual hassle.

Here is an example of different php versions on different (sub)domains. https://blog.remirepo.net/post/2016/04/16/My-PHP-Workstation, if that is what you are looking for. Albeit for apache the principle (vhost alias) is the same for nginx

« Last Edit: February 17, 2018, 11:27:59 AM by n8v8r »