Heroku上的Docker PHP + Apache部署崩溃 [英] Docker PHP + Apache deployment on Heroku crashes

查看:64
本文介绍了Heroku上的Docker PHP + Apache部署崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试部署docker容器,尽管我尝试了几种选择,但它总是崩溃.在本地运行正常,在端口8080上.

I am trying to deploy a docker container and although I have tried several options, it always crashes. On local in works fine, on port 8080.

现在,我正在使用PHP + Apache.

Right now, I am using PHP + Apache.

我的文件夹层次结构如下:

My folder herarchy looks like this:

docker-compose.yml
Dockerfile 
www
   .htaccess
   index.php

我的Dockerfile是这个文件:

My Dockerfile is this one:

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:

My docker-composer.yml:

version: '3'
services:
  web:
    build:
      context: .
      dockerfile: ./Dockerfile
    image: myproject
    ports:
      - 8080:80

.htaccess:

And the .htaccess:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

当我检查Heroku日志(heroku日志--tail)时,这就是我看到的:

When I check the Heroku logs (heroku logs --tail), this is what I see:

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.

推荐答案

我最近亲自

I recently solved this issue myself here in case you ever want to try Heroku again :)

本质上,我使用Docker CMD 语句在运行时更改apache端口配置.

Essentially, I used the Docker CMD statement to change the apache port configs at runtime.

CMD sed -i "s/80/$PORT/g" /etc/apache2/sites-enabled/000-default.conf /etc/apache2/ports.conf && docker-php-entrypoint apache2-foreground

这篇关于Heroku上的Docker PHP + Apache部署崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆