Saya mencoba menginstal php-fpm dan nginx melalui docker dan saya memiliki masalah dengan nginx yang mengembalikan saya kesalahan Gateway buruk 502, namun ketika saya mencoba untuk pergi pada file HTML apa pun hanya ditampilkan dengan benar. Apa yang harus saya lakukan untuk file php bekerja dengan benar dengan sistem ini?
Nginx config site:
server { listen 80; server_name api.local.dev; access_log /var/log/nginx/api.access.log; error_log /var/log/nginx/api.error.log; root /www; charset utf-8; index index.php index.html index.htm; location / { index index.php index.html index.htm; } location ~ \.php$ { include fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }}
Dockerfile
FROM ubuntu:13.10# Keep upstart from complainingRUN dpkg-divert --local --rename --add /sbin/initctlRUN ln -sf /bin/true /sbin/initctl# Let the conatiner know that there is no ttyENV DEBIAN_FRONTEND noninteractiveRUN locale-gen en_US.UTF-8ENV LANG en_US.UTF-8ENV LC_ALL en_US.UTF-8RUN apt-get update && apt-get upgrade -yRUN apt-get -y install nginx php5-fpm php5-mysql php-apc pwgen python-setuptools curl git unzipRUN apt-get -y install php5-curl php5-gd php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-sqlite php5-tidy php5-xmlrpcVOLUME ["/var/log/nginx"]CMD echo "127.0.0.1 api.local.dev" >> /etc/hostsEXPOSE 80RUN mkdir /wwwRUN chown www-data:www-data -R /wwwRUN echo "<?php phpinfo() ?>" > /www/index.phpRUN cat /www/index.phpRUN mkdir /dockerADD nginx /docker/nginxRUN mkdir -p /var/log/nginxRUN chown www-data:www-data /var/log/nginxRUN sed -i -e"s/keepalive_timeout\s*65/keepalive_timeout 2/" /etc/nginx/nginx.confRUN sed -i -e"s/keepalive_timeout 2/keepalive_timeout 2;\n\tclient_max_body_size 100m/" /etc/nginx/nginx.confRUN sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php5/fpm/php.iniRUN sed -i -e "s/upload_max_filesize\s*=\s*2M/upload_max_filesize = 100M/g" /etc/php5/fpm/php.iniRUN sed -i -e "s/post_max_size\s*=\s*8M/post_max_size = 100M/g" /etc/php5/fpm/php.iniRUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.confRUN sed -i -e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" /etc/php5/fpm/pool.d/www.confRUN cat /etc/php5/fpm/pool.d/www.confRUN find /etc/php5/cli/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;\2/g' {} \;RUN echo "cgi.fix_pathinfo = 0;" >> /etc/php5/fpm/php.iniRUN cat /docker/nginx/api.local.dev > /etc/nginx/sites-available/api.local.devRUN ln -s /etc/nginx/sites-available/api/local.dev /etc/nginx/sites-enabled/api/local.devRUN echo "daemon off;" >> /etc/nginx/nginx.confCMD ["nginx"]
nginx.conf
user www-data;worker_processes 4;pid /run/nginx.pid;events { worker_connections 768; # multi_accept on;}http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; ## # nginx-naxsi config ## # Uncomment it if you installed nginx-naxsi ## #include /etc/nginx/naxsi_core.rules; ## # nginx-passenger config ## # Uncomment it if you installed nginx-passenger ## #passenger_root /usr; #passenger_ruby /usr/bin/ruby; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*;}#mail {# # See sample authentication script at:# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript# # # auth_http localhost/auth.php;# # pop3_capabilities "TOP" "USER";# # imap_capabilities "IMAP4rev1" "UIDPLUS";# # server {# listen localhost:110;# protocol pop3;# proxy on;# }# # server {# listen localhost:143;# protocol imap;# proxy on;# }#}