Home>Article>Backend Development> Detailed explanation of how to configure fpm socket when upgrading Ubuntu to php7.0
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
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
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#
in pool.d is in these two lines:
listen = /run/php/php7.0-fpm.sock ; listen = 127.0.0.1:9000 ## 更改nginx conf文件 ##
nginx configuration file Mine is In
root@tb:/etc/nginx/conf.d# ls git.conf svn.conf tb.conf
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; } }
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#
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#
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
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!