当我运行以下docker-compose文件时,所有服务运行正常,但是当我打开以下链接时,浏览器会下载hello-world.php 文件,而不显示其内容。
http://0.0.0.0:8080/hello-world.php
这是我的文件结构:
docker-compose.yml
site.conf
www
hello-world.php
这是我的docker-compose:
version: '3'
services:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./www:/usr/share/nginx/html/
- ./site.conf:/etc/nginx/conf.d/site.conf
links:
- php
php:
image: php:7-fpm
volumes:
- ./www:/usr/share/nginx/html/
这是我的site.conf
server {
index index.php index.html;
server_name php-docker.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /usr/share/nginx/html/;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
这是我的世界:
<?php
echo phpinfo();
?>
答案 0 :(得分:0)
我找到了具有更好的nginx配置文件的解决方案:
hotmail