nginx的基本配置文件如下 server { listen 80; server_name www.mydoman.com; root /www/web/project; # 确保这里指向的目录正确 是项目在系统的路径 index index.php; access_log /www/log/nginx_log/www.mydoman.com/access.log ; # 处理静态资源文件(如 .txt、.jpg 等) location ~* \.(txt|jpg|jpeg|png|gif|css|js|ico|html|json|xml)$ { try_files $uri $uri/ =404; # 如果文件存在,返回文件;否则返回 404 错误 } # 默认页面:如果请求的文件或目录不存在,则转发给 index.php location / { try_files $uri $uri/ /index.php?$args; } # 处理 PHP 文件 location ~ \.php$ { fastcgi_pass 172.17.0.2:9000; # PHP 容器的 IP 地址和端口 fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; # 这里指向的是宿主机路径 docker里面的路径 fastcgi_index index.php; include fastcgi_params; } }