-
Ubuntu16.10 under PHP7.0-FPM and Nginx configuration source: qq_32457355 's blog
Problem!!! mysql-php Why Nginx is an e-lake in the rumor has long been the nginx is so read engine-x-sou-can-get-it "> installed Ubuntu16.10 after the beginning with Lemp (linux-nginx-mysql-php) , why is Nginx e? The legend of the lake in the long-awaited nginx is so read: Engine X, so ... U can get it!
Back to the point, test the environment, Papapa input 127.0.0.1, walk you ~
Then the Nginx is naughty:503Bad Gateway (invalid gateways).
Uncle to check the surveillance Oh! The old driver drove on the terminal, ran to the surveillance room:cd/var/log/nginx, watch small video:sudo vi error.log , the most red chicken plot is like this:
?
| 1 |
2016/12/25 22:45:18 [error] 13153#13153: *1 connect() failed (111: Connection refused) while connecting to upstream, client: ::1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8080" |
Nginx processing requests are implemented via the FPM management fastcgi, and Nginx and PHP-FPM can be implemented by listening on the 9000 port (default) or socket. 127.0.0.1:9000 Go Network , through the Nginx conf file, the end of PHP to 9000 port processing, PHP-FPM (fastcgi process Manager) Select and connect to a fastcgi child process, The environment variables and standard inputs are sent to the fastcgi child process, and the request response is processed continuously. socket file does not go network, is socket .
CONFLICT!!! A lot of obsessive-compulsive friends hand shake, Papapa from UBUNTU15, upgrade to 16, and then just run a good program, suddenly broke down, and then a toss, dead and alive can not find where the anchor.
PHP7 Default is the socket, according to the previous Nginx conf file, two words: no problem, just strange. (See you in the café, but you ran to the Grove)
The old driver is going to dive:
?
| 1234567891011 |
cd /etc/php/7.0/fpm sudo vim php-fpm.conf发现最后:include=/etc/php/7.0/fpm/pool.d/*.conf按照上面的线索继续找cd /etc/php/7.0/fpm/pool.dll之后发现只有一个www.confsudo vim www.conf找了一下发现listen = /run/php/php7.0-fpm.sock; listen = 127.0.0.1:9000 |
Resolve!!! It's time to go to Nginx's config file.
sudo vim/etc/nginx/sites-available/default
note Fastcgi_pass 127.0.0.1:9000;
Replace with Fastcgi_pass Unix:/run/php/php7.0-fpm.sock;?
| 1234567891011121314151617181920212223242526 |
server { listen 8080; listen [::]:8080; server_name localhost; root /home/moma/vien/learn/php/demo01/; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri =404; include fastcgi.conf; # fastcgi_pass 127.0.0.1:9000; # 换成socket fastcgi_pass unix:/run/php/php7.0-fpm.sock; #change by me fastcgi_index index.php; fastcgi_intercept_errors on; #fastcgi_param SCRIPT_FILENAME /home/gittest/$fastcgi_script_name; include fastcgi_params; }} |
Ok
Reload Nginx and PHP-FPM
sudo service nginx reload
sudo service php7.0-fpm
Then 127.0.0.1:8080 walk you ~
Ubuntu PHP7 Nginx