Secondary php for nginx

Issues related to applications and software problems
RaZoR92
Posts: 6
Joined: 2017/10/19 10:08:03

Secondary php for nginx

Post by RaZoR92 » 2017/10/19 10:21:04

Hello everyone!
In my centos 7 i have running project "RadiusDesk", which work with php5.4.16
Now i wont to upload laravel project to this server which requires php>5.6.4
Is it a way to install second php version and keep running my old project?
Before writing here i read many topics and tried many examples in my VM but without success
Any recomendation for how to do it?
Thanks!

User avatar
TrevorH
Site Admin
Posts: 33220
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Secondary php for nginx

Post by TrevorH » 2017/10/19 10:42:02

Sounds like exactly what SCLs are designed for - parallel installation of multiple copies of php. You'll need to use php-fpm for nginx in any case. Use yum install centos-release-scl to add the SCL repos then use yum list \*php\* to see all the possibles (there'll be lots, might want to pipe that into a pager).
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
remirepo
Posts: 447
Joined: 2014/09/21 09:07:12
Location: France
Contact:

Re: Secondary php for nginx

Post by remirepo » 2017/10/19 15:18:24

2 tips

1/ you need to change the listen port for the second FPM instance (e.g. listen directive in /etc/opt/rh/rh-php56/php-fpm.d/www.conf

2/ you have to set port SElinux mode to allow connection (only default port 9000 is allowed)

# semanage port -a -t http_port_t -p tcp 9056

Or, only use Unix Domain Socket.
Remi's Repository - Forum - Blog

RaZoR92
Posts: 6
Joined: 2017/10/19 10:08:03

Re: Secondary php for nginx

Post by RaZoR92 » 2017/10/20 08:14:52

i installed rh-php70 using scl. What is next?
can anyone write more detail about how to do it.
i tried to switch to php70 but without success
in /etc/opt/rh/rh-php56/ doesnt exist php-fpm.d folder
i installed php70 with this command
yum install rh-php70 rh-php70-php-fpm rh-php70-php-cli

User avatar
remirepo
Posts: 447
Joined: 2014/09/21 09:07:12
Location: France
Contact:

Re: Secondary php for nginx

Post by remirepo » 2017/10/20 11:23:15

> in /etc/opt/rh/rh-php56/ doesnt exist php-fpm.d folder

Of course... if you install rh-php70-php-fpm..... /etc/opt/rh/rh-php70/
Remi's Repository - Forum - Blog

RaZoR92
Posts: 6
Joined: 2017/10/19 10:08:03

Re: Secondary php for nginx

Post by RaZoR92 » 2017/10/23 02:52:28

Sorry, i wrote with error
/etc/opt/rh/rh-php70/ in this path php-fpm.d folder doesn't exist and file www.conf too
can anyone write more details about how to do it

User avatar
remirepo
Posts: 447
Joined: 2014/09/21 09:07:12
Location: France
Contact:

Re: Secondary php for nginx

Post by remirepo » 2017/10/23 03:54:15

Check you have installed the package...

Code: Select all

# rpm -q --configfiles rh-php70-php-fpm
/etc/logrotate.d/rh-php70-php-fpm
/etc/opt/rh/rh-php70/php-fpm.conf
/etc/opt/rh/rh-php70/php-fpm.d/www.conf
/etc/opt/rh/rh-php70/sysconfig/php-fpm
Remi's Repository - Forum - Blog

RaZoR92
Posts: 6
Joined: 2017/10/19 10:08:03

Re: Secondary php for nginx

Post by RaZoR92 » 2017/10/23 06:30:01

Thanks for reply! remirepo!
I checked with your command and result was like as yours.
Next step a must to create virtualhosts?
I googled posts for this problem end finded some info like
https://www.sitepoint.com/run-multiple- ... ne-server/]
in this post two projects configured in nginx.conf

second way is to create 2 virtualhost? if this is the right way: how in virtualhost show the needed php version

User avatar
remirepo
Posts: 447
Joined: 2014/09/21 09:07:12
Location: France
Contact:

Re: Secondary php for nginx

Post by remirepo » 2017/10/23 06:35:20

I'm not a nginx experrt, but you simply have to use the right fastcgi_pass directive in each vhost configuration, to be able to choose the PHP version used by this vhost.

Code: Select all

      fastcgi_pass   127.0.0.1:90##;


P.S. can probably be done per directory / project, not requiring vhost (at least this is possible with Apache httpd)
Remi's Repository - Forum - Blog

RaZoR92
Posts: 6
Joined: 2017/10/19 10:08:03

Re: Secondary php for nginx

Post by RaZoR92 » 2017/10/24 06:25:17

Now i went one step further. now i have two php versions and two running php fpm. Now i need to handle requests to right php version
my nginx.conf look like this:

Code: Select all

 server {
    listen       80;
    server_name  php4.localhost;

    root   /usr/share/nginx/html/php4;

    location / {
      index  index.php;
    }

    location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
    }
  }

  server {
    listen       80;
    server_name  php7.localhost;

    root   /usr/share/nginx/html/php7;

    location / {
      index  index.php;
    }

    location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9002;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
    }
  }
my rh-php70-php-fpm listens
listen 127.0.0.1:9002
But when i trying to open test file in php4 and php7 folders phpinfo() shows me identical version 5.4.16
what's wrong in my settings?

Post Reply