2 votes

Nginx + PHP-FPM sur Centos 6.5 me donne 502 Bad Gateway (fpm error : unable to read what child say : Bad file descriptor)

Je suis en train de mettre en place une pile LEMP standard. Ma configuration actuelle me donne l'erreur suivante :

502 Bad Gateway

C'est ce qui est actuellement installé sur mon serveur :

enter image description here

Voici les configurations que j'ai créées/mises à jour jusqu'à présent. Quelqu'un peut-il jeter un œil à ce qui suit et voir où se situe l'erreur ? J'ai déjà vérifié mes journaux, il n'y a rien dedans ( http://i.imgur.com/iRq3ksb.png ). Et j'ai vu ce qui suit dans /var/log/php-fpm/error.log fichier.

Note complémentaire : le nginx et le php-fpm ont été configurés pour fonctionner sous un compte local appelé www-data et les dossiers suivants sortent sur le serveur

enter image description here

nginx.conf configuration globale de nginx

user                    www-data;
worker_processes        6;
worker_rlimit_nofile    100000;
error_log               /var/log/nginx/error.log crit;
pid                     /var/run/nginx.pid;

events {
    worker_connections 2048;
    use epoll;
    multi_accept on;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    # cache informations about FDs, frequently accessed files can boost performance
    open_file_cache max=200000 inactive=20s; 
    open_file_cache_valid 30s; 
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    # to boost IO on HDD we can disable access logs
    access_log off;

    # copies data between one FD and other from within the kernel
    # faster then read() + write()
    sendfile on;

    # send headers in one peace, its better then sending them one by one 
    tcp_nopush on;

    # don't buffer data sent, good for small data bursts in real time
    tcp_nodelay on;

    # server will close connection after this time
    keepalive_timeout 60;

    # number of requests client can make over keep-alive -- for testing
    keepalive_requests 100000;

    # allow the server to close connection on non responding client, this will free up memory
    reset_timedout_connection on;

    # request timed out -- default 60
    client_body_timeout 60;

    # if client stop responding, free up memory -- default 60
    send_timeout 60;

    # reduce the data that needs to be sent over network
    gzip on;
    gzip_min_length 10240;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
    gzip_disable "MSIE [1-6]\.";

    # Load vHosts
    include /etc/nginx/conf.d/*.conf;
}

conf.d/www.domain.com.conf mon entrée vhost

## Nginx php-fpm Upstream
upstream wwwdomaincom {
    server unix:/var/run/php-fcgi-www-data.sock;
}

## Global Config
client_max_body_size            10M;
server_names_hash_bucket_size   64;

## Web Server Config
server
{
    ## Server Info
    listen 80;
    server_name domain.com *.domain.com;
    root /home/www-data/public_html;
    index index.html index.php;

    ## Error log
    error_log /home/www-data/logs/nginx-errors.log;

    ## DocumentRoot setup
    location / {
        try_files $uri $uri/ @handler;
        expires 30d;
    }

    ## These locations would be hidden by .htaccess normally
    #location /app/                       { deny all; }

    ## Disable .htaccess and other hidden files
    location  /. {
        return 404;
    }

    ## Magento uses a common front handler
    location @handler {
        rewrite / /index.php;
    }

    ## Forward paths like /js/index.php/x.js to relevant handler
    location ~ .php/ {
        rewrite ^(.*.php)/ $1 last;
    }

    ## Execute PHP scripts
    location ~ \.php$ {
        try_files $uri =404;
        expires        off;
        fastcgi_read_timeout 900;
        fastcgi_pass   wwwdomaincom;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    ## GZip Compression
    gzip on;
    gzip_comp_level 8;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_types text/plain application/xml text/css text/js application/x-javascript;
}

/etc/php-fpm.d/www-data.conf ma configuration du pool php-fpm

## Nginx php-fpm Upstream
upstream wwwdomaincom {
    server unix:/var/run/php-fcgi-www-data.sock;
}

## Global Config
client_max_body_size            10M;
server_names_hash_bucket_size   64;

## Web Server Config
server
{
    ## Server Info
    listen 80;
    server_name domain.com *.domain.com;
    root /home/www-data/public_html;
    index index.html index.php;

    ## Error log
    error_log /home/www-data/logs/nginx-errors.log;

    ## DocumentRoot setup
    location / {
        try_files $uri $uri/ @handler;
        expires 30d;
    }

    ## These locations would be hidden by .htaccess normally
    #location /app/                       { deny all; }

    ## Disable .htaccess and other hidden files
    location  /. {
        return 404;
    }

    ## Magento uses a common front handler
    location @handler {
        rewrite / /index.php;
    }

    ## Forward paths like /js/index.php/x.js to relevant handler
    location ~ .php/ {
        rewrite ^(.*.php)/ $1 last;
    }

    ## Execute PHP scripts
    location ~ \.php$ {
        try_files $uri =404;
        expires        off;
        fastcgi_read_timeout 900;
        fastcgi_pass   wwwdomaincom;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    ## GZip Compression
    gzip on;
    gzip_comp_level 8;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_types text/plain application/xml text/css text/js application/x-javascript;
}

J'ai un fichier dans /home/www-data/public_html/index.php avec le code <?php phpinfo(); ?> (fichier téléchargé en tant qu'utilisateur www-data ).

1voto

nandoP Points 1961

Le répertoire tmp de nginx n'est pas accessible en écriture par l'utilisateur sous lequel nginx est exécuté, dans votre cas "www-data".

/var/lib/nginx/tmp/fastcgi/2/00/0000000002" a échoué (13 : Permission refusée)

essayez "chown -cR www-data. /var/lib/nginx"

SistemesEz.com

SystemesEZ est une communauté de sysadmins où vous pouvez résoudre vos problèmes et vos doutes. Vous pouvez consulter les questions des autres sysadmins, poser vos propres questions ou résoudre celles des autres.

Powered by:

X