[英]php and xdebug module in docker
i wanna make a sample dockerized php application with xdebug module and my problem is when i open http://127.0.0.1:8080
i get error This site can't be reached
.我想用 xdebug 模块制作一个示例 dockerized php 应用程序,我的问题是当我打开
http://127.0.0.1:8080
时我收到错误This site can't be reached
。 how can i fix this and what is best practice for this?我该如何解决这个问题,最好的做法是什么? this is my structure of my tiny project:
这是我的小项目的结构:
Dockerfile: Dockerfile:
FROM php:7.4-fpm
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug \
docker-compose.yml: docker-compose.yml:
version: '3'
services:
webserver:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./:/var/www
php:
build: ./docker/php/
expose:
- 9000
volumes:
- .:/var/www/html
- ./docker/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- ./docker/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini
default.conf:默认配置:
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
error_reporting.ini:错误报告.ini:
error_reporting=E_ALL
xdebug.ini: xdebug.ini:
zend_extension=xdebug
[xdebug]
xdebug.mode=develop,debug
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
You're container name is incorrect in nginx config:您在 nginx 配置中的容器名称不正确:
fastcgi_pass app:9000;
This should be这应该是
fastcgi_pass php:9000;
because you've named the container php
in your compose file.因为您已在撰写文件中将容器命名为
php
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.