php-nginx - Configure nginx + php + spwan-fcgi, error 502 Bad Gateway and php-fcgi cannot be started.
黄舟
黄舟 2017-05-16 17:23:13
0
4
677

First I have configured nginx

Use the command service nginx start in Linux to start, and log in to localhost to see the welcome page.

Then modify the default file according to the online tutorial

During the modification process, I added index.php to the server,
root is still /usr/share/nginx/html, no changes have been made.

I changed /usr/share/nginx/html/index.html to index.php

When I open localhost, a 502 bad gateway error is reported.

Start php-fcgi and display child exited with: 127

According to what is said on the Internet, I have tested whether the cache is not enough or the threads are not enough. It should not be a problem with php-fpm. I'm wondering if it's because php-fcgi is not started?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(4)
迷茫

I’ll ask myself some questions and tell you my solution.
The answer on the first floor is correct, but starting php-cgi didn't work on my machine for some reason, so I downloaded spwan-fcgi, which is a software for managing php-cgi.
After successful installation, enter the command spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi (the bold words should be modified according to your location. ) after starting.
I still don't know why php-fpm cannot start. . .

漂亮男人

php-cgi has not been started yet, it definitely won’t work. The solution is to start php-cgi

仅有的幸福

PHP-FPM is an independent program that does not depend on PHP-CGI.
The main process of PHP-FPM can manage its own work process, so spwan-fcgi is not needed.
Installation method on Ubuntu/Debian:

sudo apt-get install nginx php5-fpm php5-mysqlnd mysql-server
服务管理:
sudo /etc/init.d/nginx start|stop|restart
sudo /etc/init.d/php5-fpm start|stop|restart
sudo /etc/init.d/mysql start|stop|restart
配置目录:
Nginx:   /etc/nginx/
PHP-FPM: /etc/php5/fpm

For configuration methods, please refer to:
http://huoding.com/2013/10/23/290

server {
    listen 80;
    server_name foo.com;

    root /path;
    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;
    }
}
洪涛

PHP under nginx needs to use php-fpm. Add

when compiling php.

--enable-fpm

,
Then you need to create the php-fpm configuration file php-fpm.conf in the etc directory of php (configuration reference: http://qiananhua.com/22#title-4)
Then you can start php-fpm

/usr/local/php/sbin/php-fpm -t

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template