I’m having trouble with the 7.3-fpm image for Docker. I take it that it isn’t a turnkey solution and requires some work. I build and up the image with the following docker-compose YAML:
FROM yiisoftware/yii2-php:7.3-fpm
COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
I try my application at the address on port 8080, and 8443, but it gives a connection refused error.
I’m using Docker Virtualbox on Windows 10 Home with the following ports forwarded through the interface:
FROM yiisoftware/yii2-php:7.3-fpm
COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
COPY www.conf /usr/local/etc/php-fpm.d/www.conf
RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
Everything builds and ups fine, but I am still getting a connection refused when I try to access the server on 8080. I’m attempting to access on 192.168.99.100, which is the default IP for VBox Docker. I confirm this by being able to connect just fine to my MySql instance that is also upped as part of this docker-compose file.
This is my nginx configuration file that is included in the volumes:
events {
}
http {
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name 192.168.99.100;
root /app/web;
index index.php;
access_log /app/runtime/logs/access.log;
error_log /app/runtime/logs/error.log;
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php$is_args$args;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
# deny accessing php files for the /assets directory
location ~ ^/assets/.*\.php$ {
deny all;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri =404;
}
location ~* /\. {
deny all;
}
}
}
The fastcgi_pass should be php:9000(same as the php-fpm service name and port in docker-compose.yml).
Additionally, change server_name as default_server(not sure).
Btw, you can follow these steps for troubleshooting:
Check whether all services are set up successfully.
Enter the nginx container, and check nginx error.log and /app/runtime/logs/error.log, access.log is an important clue for determining whether nginx receives requests.