0

I am trying to update from PHP 5.6 to PHP 7.3

I installed:

  • php7.0-fpm
  • php7.0-mysql

and I have the 2 services raised but Nginx only recognizes PHP 5.6. If I stop the service, I get the error 502 Bad Gateway.

I have changed in /etc/nginx/sites-enabled/default the line /var/run/php5-fpm.sock to /var/run/php/php7.0-fpm.sock

The problem is that I have the configuration in each subdomain and each subdomain uses its own socket:

fastcgi_pass unix:/var/run/php/subdomain1.sock;
fastcgi_pass unix:/var/run/php/subdomain2.sock;
...

So I do not know how to tell nginx to use PHP 7.3

enter image description here enter image description here enter image description here enter image description here enter image description here

Isaac Palacio
  • 149
  • 4
  • 12
  • 3
    I see a little confusion. You're asking about `php 7.3`, then you said you installed `php 7.0`, then your `php -v` shows version `7.1` but your `phpinfo()` page tells it loaded `5.6`. Have you restarted all your services (`nginx` **and** `php-fpm`)? – Daniele Santi Oct 18 '18 at 14:31
  • 2
    Your question says PHP 7.3. Your commands say PHP 7.0. Your `php -v` says PHP 7.1. PHP 7.3 [isn't even out yet](http://php.net/supported-versions.php). **Which one are you actually trying to install?** – ceejayoz Oct 18 '18 at 14:38
  • @MrShunz Yes, I have restarted the services and added information in the question – Isaac Palacio Oct 18 '18 at 14:40
  • @ceejayoz You're right I'd really like to install the most recent one, but I'll settle for 7.1 – Isaac Palacio Oct 18 '18 at 14:41
  • Where is the configuration of your FPM services? You configure a socket for the FPM, you configure the same socket in nginx, done. – Gerald Schneider Oct 18 '18 at 14:43
  • 2
    And please, don't post screenshots of your console window. This is text. It can be copied and pasted. – Gerald Schneider Oct 18 '18 at 14:44
  • @GeraldSchneider the configuration of the FPM services is in /etc/php/5.6/fpm/pool/ but I have copied the fpm directory to /etc/php/7.3 I think I should copy it in /etc/php/7.1 The * .sock files, I have them in / var / run / – Isaac Palacio Oct 18 '18 at 14:46
  • 2
    I don't want to know where it is located on your server. If you want help with your configuration, share it, along with your nginx configuration. – Gerald Schneider Oct 18 '18 at 14:48
  • @GeraldSchneider I put the catches to make it look clearer and better understood. – Isaac Palacio Oct 18 '18 at 14:48
  • @GeraldSchneider Sorry, it was you who asked where I have the files – Isaac Palacio Oct 18 '18 at 14:51
  • Installing and updating software should be done using your distribution's package manager. You haven't told us which distribution you are using or which commands you ran with package manager. – kasperd Oct 18 '18 at 15:43
  • @kasperd Trisquel 7 based on Ubuntu 14.0 package manager.: apt-get – Isaac Palacio Oct 18 '18 at 16:41

1 Answers1

1

It looks like you installed multiple PHP version from Ondřej Surý's PHP repository. The PHP packages from this repository can be run simultaneously and therefor should all create their own socket file that you can use in your web server (nginx) configuration.

By default, the PHP 7.3 socket should be installed under /var/run/php/php7.3-fpm.sock. Given that:

  • The php7.3-fpm service is successfully running
  • The socket file is readable by your web server user (usually www-data)

You should be able to forward the PHP requests for the desired (sub)domain to the PHP 7.3 socket with the line:

fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

So your overall nginx vhost configuration should look something like this:

server {
  server_name some.domain.example.com;
  listen 80;
  listen 443 ssl;

  ssl_certificate /etc/ssl/certs/subdomain.crt;
  ssl_certificate_key /etc/ssl/certs/subdomain.key;

  location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}
Oldskool
  • 2,025
  • 1
  • 16
  • 27
  • Not, i have location ~ \.php$ { fastcgi_pass unix:/var/run/php/domain1.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } You see my firts message – Isaac Palacio Oct 18 '18 at 15:21
  • 1
    And where does this `/var/run/php/domain1.sock` come from? Because it looks like this is created by the PHP 5.6 service. You should use a socket that connects to the PHP 7.3 service instead. – Oldskool Oct 18 '18 at 15:28