Home > Backend Development > PHP7 > body text

Detailed explanation of how to configure fpm socket when upgrading Ubuntu to php7.0

藏色散人
Release: 2023-02-17 14:16:02
forward
3476 people have browsed it

Simply put

(That’s all I know), nginx handles requests through fpm (to manage fastcgi) to implement requests and responses.

nginx and php-fpm can be implemented by listening to port 9000 (default) or socket.

The format of 9000 is 127.0.0.1:9000, which is over the network. Through the ngxin conf file, everything ending in .php is handed over to port 9000 for processing. php-fpm (fastggi's process manager) selects and connects to a fastcgi sub-process, and sends environment variables and standard input to the fastcgi sub-process. Then continuously process the request and response

The socket file does not go through the network, it is a socket.

Okay, as for speed comparison and optimized configuration, let’s not talk about it for now.

Let’s talk about the ubuntu (14.10 lts) upgrade firstphp7

sudo add-apt-repository ppa:ondrej/php-7.0
sudo apt-get update
sudo apt-get install php7.0-fpm
Copy after login

After the upgrade is completed, the previous fpm file is still there. You can refer to or delete as appropriate

php -v
PHP 7.0.1-4+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, 
    by Zend     Technologies
Copy after login

Change the phpfpm listening port 9000 to socket (the default is socket)

php7 defaults to socket, so if According to the previous nginx -conf file, php file processing will report a 502 error.

The default sock is in the php configuration file. www.conf

root@tb:/etc/php/7.0/fpm# pwd
/etc/php/7.0/fpm
root@tb:/etc/php/7.0/fpm# ls
conf.d  php-fpm.conf  php.ini  pool.d
root@tb:/etc/php/7.0/fpm#
Copy after login

in pool.d is in these two lines:

listen = /run/php/php7.0-fpm.sock
; listen = 127.0.0.1:9000
## 更改nginx conf文件 ##
Copy after login

nginx configuration file Mine is In

  root@tb:/etc/nginx/conf.d# ls
  git.conf  svn.conf  tb.conf
Copy after login

modify the git.conf as follows

 server{
    listen 80;
    server_name git.com ;
    root /home/gittest/;
    autoindex on;
  location ~ \.php$ {
    root           /home/gittest;
    #fastcgi_pass   127.0.0.1:9000;
    fastcgi_pass    unix:/run/php/php7.0-fpm.sock;
    fastcgi_index  index.php;
    fastcgi_intercept_errors        on;
    fastcgi_param  SCRIPT_FILENAME  /home/gittest/$fastcgi_script_name;
    include        fastcgi_params;
    }
}
Copy after login

Restart php-fpm and nginx

    root@tb:/etc/nginx/conf.d# service nginx reload
     * Reloading nginx configuration nginx                                                                           [ OK ] 
     
    root@tb:/etc/nginx/conf.d# service php7-fpm status
     * php-fpm7.0 is running
    root@tb:/etc/nginx/conf.d# service php7-fpm reload
     * Reloading PHP 7.0 FastCGI Process Manager php-fpm7.0[ OK ] 
    root@tb:/etc/nginx/conf.d#
Copy after login

Please note that it is OK. The specific nginx and fpm script execution files (can be modified by yourself) are at:

    root@tb:/etc/init.d# ls /etc/init.d/ |grep php7
    php7-fpm
    root@tb:/etc/init.d# ls /etc/init.d/ |grep nginx
    nginx
    root@tb:/etc/init.d#
Copy after login

Additional: If you want to change back to the previous version through apt-get

sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
Copy after login

Then just install it

The above is the detailed content of Detailed explanation of how to configure fpm socket when upgrading Ubuntu to php7.0. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template