Nginx, PHP-FPM, MySQL and Symfony using Docker : Nginx 502 Bad Gateway and Symfony No route found exception -


this post quite long, make sure have drink near you.

basically, want use docker make nginx container, php-fpm container, mysql container , symfony container contain code of symfony app.

i've been trying make things work whole week, been reading things, unfortunately nothing worked.

i made docker-compose.yml, uses dockerfiles nginx, php-fpm , symfony. mysql based on image hosted on dockerhub.

i installed , finally, after week of work still encounter 2 types of error :

nginx gives me "502 bad getaway" randomly. it's because of port error if nginx fastcgi_pass parameter wasn't set @ right value, is, don't quite understand problem.

then, symfony gives me "no route found /" don't understand why, since website works on production , colleagues. suspicious database since when it's empty give me error. took dump database didn't give concluent.

here files want

  • docker-compose.yml

     version:'2'  services:   symfony:     build: symfony/     volumes:       - ./symfony/code/:/var/www:rw       - ./symfony/code/app/logs/symfony:/var/www/project/app/logs/symfony:rw       - ./symfony/code/app/logs/nginx:/var/www/project/app/logs/nginx:rw    nginx:     build: nginx/     ports:     - 8080:80     links:     - fpm     volumes_from:     - symfony     environment:         <app_server_name>: dev-machine    fpm:     build: php-fpm/     links:     - mysql     volumes_from:     - symfony     environment:       app_server_name: dev-machine    mysql:     image: mysql     ports:     - 3306:3306     volumes:     - ./.data/db:/var/lib/mysql:rw     environment:     - "mysql_root_password=root"     - "mysql_user=root"     - "mysql_password=root"     - "mysql_database=databasename" 
  • nginx dockerfile

    from ubuntu:14.04  env debian_frontend noninteractive  run apt-get update && apt-get install -y \ nginx  add nginx.conf /etc/nginx/nginx.conf  add vhost.conf /etc/nginx/sites-enabled/default  add start.sh /start.sh  expose 80  entrypoint ["/start.sh"] 
  • my nginx.conf file has this

    proxy_buffer_size   128k; proxy_buffers   4 256k; proxy_busy_buffers_size   256k;  fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; 
  • vhost.conf

    server {     listen       80;      server_name  project.dev;     access_log   /var/log/nginx/symfony-access.log;     error_log    /var/log/nginx/symfony-error.log;      #server_name  dev-machine;     #access_log   /dev/stdout;     #error_log    /dev/stdout info;      root /var/www/web;     index app_dev.php;      location / {             try_files $uri $uri/ /app_dev.php?$query_string;     }      location ~ ^/(app|app_dev)\.php(/|$) {             fastcgi_pass fpm:9000;             include fastcgi_params;             fastcgi_param https off;             try_files $uri =404;             fastcgi_param  script_filename    $document_root$fastcgi_script_name;             fastcgi_split_path_info ^(.+\.php)(/.*)$;             fastcgi_index app_dev.php;     } } 
  • php-fpm dockerfile

    from ubuntu:14.04  env debian_frontend noninteractive  run apt-get update && apt-get install -y \     git \     nano \     curl \     php5-cli \     php5-fpm \     php5-json \     php5-intl \     php5-gd \     php5-mysql  # set timezone run rm /etc/localtime run ln -s /usr/share/zoneinfo/europe/paris /etc/localtime run "date"  # install composer run curl -ss https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer run composer --version  add start.sh /start.sh add symfony_environment.sh /etc/profile.d/symfony_environment.sh  expose 9000  workdir /var/www  entrypoint ["/start.sh"] 
  • symfony dockerfile

    from ubuntu:14.04  env debian_frontend noninteractive  run apt-get update && apt-get install -y \     git \     curl \     php5-cli \     php5-json \     php5-intl \     php5-gd  run curl -ss https://getcomposer.org/installer | php run mv composer.phar /usr/local/bin/composer  add entrypoint.sh /entrypoint.sh add ./code /var/www add symfony_environment.sh /etc/profile.d/symfony_environment.sh  workdir /var/www  entrypoint ["/entrypoint.sh"] cmd ["echo", "hello"] 

i loaded dump in database , parameters.yml :

    database_driver: pdo_mysql         database_host: mysql         database_port: 3306         database_name: <databasename>         database_user: root         database_password: root 

i don't know do, clue welcome , think helpful lot of people in future.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -