Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6125

how to resolve php-fpm 502 bad gateway error

$
0
0

I am new to Docker and created an image using images nginx:alpine and php:fpm-alpine (follwed this article).I went through different answers here but could not understand.I didnt find /etc/php5/fpm/pool.d/www.conf and seems that I am missing something basic. These are two containers and connected them via internal network bridge. Here is my docker-compose.yml file

version: "3"services:  nginx:    build:      context: .      dockerfile: nginx/Dockerfile    ports:       - "8080:80"    networks:      - internal    volumes:      - ./data/:/var/www/html/      - ./logs/nginx:/var/log/nginx/  php:    image: php:fpm-alpine    networks:      - internal    volumes:      - ./data/:/var/www/html/      - ./logs/php.log:/var/log/fpm-php.www.lognetworks:  internal:    driver: bridge

Now, I composed up this yml file and can see containers up and running.I saved, shut down the containers and loaded the php image and then tried to access the index page, I get 502 bad gateway error.this is default.conf file where I am configuring the port

server {    listen 0.0.0.0:80;    root /var/www/html;    location / {        index index.php index.html;    }    location ~ \.php$ {        include fastcgi_params;         fastcgi_pass php:9000;        fastcgi_index index.php;        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;    }}

docker-compose.yml file for the loaded image.

version: "3"services:  nginx:    image: php_with_nginx_nginx:latest    ports:       - "8080:80"    networks:      - internal    volumes:      - ./data/:/var/www/html/      - ./logs/nginx:/var/log/nginx/  php:    image: phpnginxload:latest    networks:      - internal    volumes:      - ./data/:/var/www/html/      - ./logs/php.log:/var/log/fpm-php.www.log    ports:      - "9000:9000"networks:  internal:    driver: bridge

When checked logs, there is no php service in the container

7020:~/php_with_nginx$ docker exec -it php_with_nginx_php_1 sh/ # netstat -tulnActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address           Foreign Address         State       tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      tcp        0      0 127.0.0.11:38961        0.0.0.0:*               LISTEN      udp        0      0 127.0.0.11:33901        0.0.0.0:*                    

there is no port 9000 here...

/usr/sbin # php-fpm -Fsh: php-fpm: not found/usr/sbin # php -vsh: php: not found/usr/sbin # 

Folder structure:

- php_with_nginx-- data--- index.php- logs--nginx --access.log --error.log--php.log- nginx-- default.conf-- Dockerfile-- Dockerfile- docker-compose.yml- docker-compose-save.yml

any pointers would be highly appreciated.


Viewing all articles
Browse latest Browse all 6125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>