本文介绍了Docker-如何在docker-compose.yml中设置Apache + PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用它来为PHP设置nginx:
I use this to set up nginx for PHP:
nginx:
image: nginx:latest
ports:
- 8080:80
volumes:
- ./code:/code
- ./site.conf:/etc/nginx/conf.d/site.conf
links:
- php
php:
image: php:7-fpm
volumes:
- ./code:/code
但是Apache呢?如何在docker-compose.yml中设置Apache + PHP?
But how about Apache? How can I set up Apache + PHP in docker-compose.yml?
遵循此指南:
version: '2'
services:
php:
build: php
ports:
- "80:80"
- "443:443"
volumes:
- ./php/www:/var/www/html
错误:
ERROR: In file './docker-compose.yml' service 'version' doesn't have any configuration options. All top level keys in your docker-compose.yml must map to a dictionary of configuration options.
有什么想法吗?我正在使用Xubuntu 16.04.
Any ideas? I'm on Xubuntu 16.04.
在设法将docker-compose升级到1.9之后,我尝试使用以下文件:
After managing to upgrade docker-compose to 1.9, I try with this file below:
version: '2'
services:
php:
build: php
expose:
- 9000
volumes:
- ./php/www:/var/www/html
apache2:
image: webdevops/apache:latest
args:
- PHP_SOCKET=php:9000
volumes:
- ./php/www:/var/www/html
ports:
- 80:80
- 443:443
links:
- php
错误:
$ sudo docker-compose up -d
Building php
ERROR: Cannot locate specified Dockerfile: Dockerfile
码头工人真痛苦!
有什么办法解决这个问题吗?
Any ideas how to fix this?
推荐答案
我会选择dockerized的webdevops apache ,因为它具有简单的配置:
I would choose webdevops dockerized apache, because it has simple configuration:
version: '2'
services:
php:
build: php
expose:
- 9000
volumes:
- ./php/www:/var/www/html
apache2:
image: webdevops/apache:latest
args:
- PHP_SOCKET=php:9000
volumes:
- ./php/www:/var/www/html
ports:
- 80:80
- 443:443
links:
- php
这篇关于Docker-如何在docker-compose.yml中设置Apache + PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!