繁体   English   中英

Puppet Docker PHP Apache 设置 - 无效命令“RewriteRule”,可能拼写错误或定义

[英]Puppet Docker PHP Apache setup - Invalid command 'RewriteRule', perhaps misspelled or defined

I am using puppet docker ( https://forge.puppet.com/modules/puppetlabs/docker ) and setup PHP-Apache website using PHP docker image ( https://hub.docker.com/layers/php/library/php /7.2.34-apache/images/sha256-77e5a326252f951aa557f48829973f67e8efde9c52f81ee4e4a5473a59a217d9?context=explore )

PHP 脚本工作正常,但是当我在文件夹中添加 .htaccess 文件时,它会抛出错误

[Mon Jan 25 09:52:12.078604 2021] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.2.34 configured -- resuming normal operations
[Mon Jan 25 09:52:12.078766 2021] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
[Mon Jan 25 09:52:32.734378 2021] [autoindex:error] [pid 16] [client 172.17.0.1:50756] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
172.17.0.1 - - [25/Jan/2021:09:52:32 +0000] "GET / HTTP/1.1" 403 493 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0"
172.17.0.1 - - [25/Jan/2021:09:52:32 +0000] "GET /favicon.ico HTTP/1.1" 404 489 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Mon Jan 25 09:56:33.265445 2021] [autoindex:error] [pid 18] [client 172.17.0.1:50830] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
172.17.0.1 - - [25/Jan/2021:09:56:33 +0000] "GET / HTTP/1.1" 403 493 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Mon Jan 25 09:56:52.186711 2021] [core:alert] [pid 17] [client 172.17.0.1:50854] /var/www/html/packageContent/.htaccess: Invalid command 'RewriteRule', perhaps misspelled or defined by a module not included in the server configuration

我相信我需要像这里一样RUN a2enmod rewritehttps://stackoverflow.com/a/38064289/376702

我不知道如何使用 puppet docker 进行设置( https://forge.puppet.com/modules/puppetlabs/docker )。

谁能指导我? 这是我的木偶代码。

 docker::image { 'docker.io/php':
    image_tag => '7.2.34-apache'
  }

  docker::run { 'test123.com':
    image            => 'docker.io/php:7.2.34-apache',
    command          => 'apache2-foreground',
    expose           => ['80'],
    ports            => ['8101:80'],
    volumes          => ['/var/www/test123.com:/var/www/html'],
    hostname         => 'test123.com',
    restart_service  => true,
    before_stop      => 'echo "So Long, and Thanks for All the Fish"',
    before_start     => 'echo "Run this on the host before starting the Docker container"',
    after_stop       => 'echo "container has stopped"',
    after_start      => 'echo "container has started"',
    extra_parameters => [ '--restart=always' ],
  }

我在 Linux RedHat 中运行 docker

参考: .htaccess:无效命令“RewriteEngine”,可能拼写错误或由服务器配置中未包含的模块定义

我重建PHP apache官方镜像,配置如下

# Dockerfile

FROM docker.io/php:7.2.34-apache
RUN a2enmod rewrite

pp puppet class 中的 puppet 代码更改

      docker::image { 'php-apache7234':
        docker_file => '/tmp/Dockerfile',
        subscribe   => File['/tmp/Dockerfile'],
      }
    
      file { '/tmp/Dockerfile':
        ensure => file,
        source => 'puppet:///modules/mydocker/php_apache/Dockerfile',
      }

  docker::run { 'test123.com':
    image            => 'php-apache7234',
    command          => 'apache2-foreground',
    expose           => ['80'],
    ports            => ['8101:80'],
    volumes          => ['/var/www/test123.com:/var/www/html'],
    hostname         => 'test123.com',
    restart_service  => true,
    before_stop      => 'echo "So Long, and Thanks for All the Fish"',
    before_start     => 'echo "Run this on the host before starting the Docker container"',
    after_stop       => 'echo "container has stopped"',
    after_start      => 'echo "container has started"',
    extra_parameters => [ '--restart=always' ],
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM