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

  • 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)? Oct 18, 2018 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. Which one are you actually trying to install?
    – ceejayoz
    Oct 18, 2018 at 14:38
  • @MrShunz Yes, I have restarted the services and added information in the question Oct 18, 2018 at 14:40
  • 2
    And please, don't post screenshots of your console window. This is text. It can be copied and pasted. Oct 18, 2018 at 14:44
  • 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. Oct 18, 2018 at 14:48

1 Answer 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;
  • 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 Oct 18, 2018 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, 2018 at 15:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.