【发布时间】:2019-05-21 22:01:48
【问题描述】:
我正在尝试部署一个 docker 容器,虽然我尝试了几个选项,但它总是崩溃。在本地工作正常,在端口 8080 上。
现在,我正在使用 PHP + Apache。
我的文件夹层次结构如下所示:
docker-compose.yml
Dockerfile
www
.htaccess
index.php
我的 Dockerfile 是这个:
FROM php:7.1-apache
COPY www /var/www/html
RUN a2enmod rewrite
RUN a2enmod lbmethod_byrequests
RUN service apache2 restart
EXPOSE 80
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
我的 docker-composer.yml:
version: '3'
services:
web:
build:
context: .
dockerfile: ./Dockerfile
image: myproject
ports:
- 8080:80
还有.htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
当我检查 Heroku 日志 (heroku logs --tail) 时,我看到的是:
Starting process with command `/usr/sbin/apache2ctl -D FOREGROUND`
State changed from starting to crashed
Process exited with status 1
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action '-D FOREGROUND' failed.
【问题讨论】:
标签: php apache docker heroku deployment