[英]php and xdebug module in docker
我想用 xdebug 模塊制作一個示例 dockerized php 應用程序,我的問題是當我打開http://127.0.0.1:8080
時我收到錯誤This site can't be reached
。 我該如何解決這個問題,最好的做法是什么? 這是我的小項目的結構:
Dockerfile:
FROM php:7.4-fpm
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug \
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
默認配置:
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;
}
}
錯誤報告.ini:
error_reporting=E_ALL
xdebug.ini:
zend_extension=xdebug
[xdebug]
xdebug.mode=develop,debug
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
您在 nginx 配置中的容器名稱不正確:
fastcgi_pass app:9000;
這應該是
fastcgi_pass php:9000;
因為您已在撰寫文件中將容器命名為php
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.