docker nginx,php what';怎么了?
我用PHP创建了nginx服务器,但它不工作 这是我的docker-compose.yml:docker nginx,php what';怎么了?,nginx,docker-compose,Nginx,Docker Compose,我用PHP创建了nginx服务器,但它不工作 这是我的docker-compose.yml: web: image: nginx:latest ports: - 127.0.0.1:8080:80 volumes: - ./docs:/docs - ./site.conf:/etc/nginx/conf.d/site.conf links: - php php: image: php:late
web:
image: nginx:latest
ports:
- 127.0.0.1:8080:80
volumes:
- ./docs:/docs
- ./site.conf:/etc/nginx/conf.d/site.conf
links:
- php
php:
image: php:latest
volumes:
- ./docs:/docs
site.conf:
server {
listen 80;
index index.php;
server_name php.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /docs;
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;
}
}
/etc/主持人
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 php.local
Docker在终端中运行时没有错误:
sudo docker-compose up -d
Starting php_php_1
Starting php_web_1
当我输入浏览器127:0:0:1:8080或php.local:8080时,连接被拒绝了为什么?这不是端口转发的正确语法
- 127.0.0.1:8080:80
用一个简单的
- 8080:80
docker composer IP不是您的本地主机。要了解您的docker compose IP,您需要调用docker machine IP default
,(例如,如果您正在起诉OSX)…阅读此处的更多信息
通常IP类似于
192.168.99.100
,因此如果您调用,docker compose容器上的服务器应该可以访问我使用Fedora。根据教程,我不需要docker机器。它应该在本地主机上工作。。。呼叫停止工作。