title: How can I install mod_rewrite module for PHP in Docker container?
body: <p><strong>docker-compose.yml</strong></p>
  <pre><code>version: &quot;3.7&quot;
  services:
  
    php:
      build: './php/'
      volumes:
        - ./public_html/www/:/var/www/html/
  
    apache:
      build: './apache/'
      depends_on:
        - php
        - mysql
      ports:
        - &quot;8080:80&quot;
      volumes:
        - ./public_html/www/:/var/www/html/
        #- ./log:/var/log/apache2
  
    mysql:
      image: mysql:5.6.40
      ports:
        - &quot;3306:3306&quot;
      environment:
        - MYSQL_DATABASE=el-cigarette
        - MYSQL_ROOT_PASSWORD=root
  
    phpmyadmin:
      image: phpmyadmin/phpmyadmin
      links:
        - mysql
      environment:
        PMA_HOST: mysql
        PMA_PORT: 3306
      ports:
        - '8081:80'
  </code></pre>
  <p><strong>php/Dockerfile</strong></p>
  <pre><code>FROM php:7.0-apache
  MAINTAINER Webgriffe Srl &lt;support@webgriffe.com&gt;
  RUN docker-php-ext-install mysqli &amp;&amp; a2enmod rewrite
  </code></pre>
  <p><strong>apache/demo.apache.conf</strong></p>
  <pre><code>ServerName localhost
  
  LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so
  LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
  LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so
  
  
  
  &lt;VirtualHost *:80&gt;
      # Proxy .php requests to port 9000 of the php-fpm container
      ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/var/www/html/$1
      DocumentRoot /var/www/html/
  
      DirectoryIndex index.php
  
      &lt;Directory /var/www/html/&gt;
          Options All
              AllowOverride All
          Order allow,deny
          Allow from all
              Require all granted
      &lt;/Directory&gt;
      
      # Send apache logs to stdout and stderr
      CustomLog /var/www/1 common
      ErrorLog /var/www/2
  &lt;/VirtualHost&gt;
  </code></pre>
  <p>I inputted next commands</p>
  <pre><code>docker-compose build
  docker-compose up -d
  </code></pre>
  <p>And I get that output</p>
  <pre><code>Creating docker-local2_mysql_1 ... done
  Creating docker-local2_php_1        ... done
  Creating docker-local2_phpmyadmin_1 ... done
  Creating docker-local2_apache_1     ... done
  </code></pre>
  <p>Farther I write this</p>
  <pre><code>docker exec -it docker-local2_php_1 sh
  # php -m
  </code></pre>
  <p>But I didn't see mod_rewrite module</p>
  <pre><code>[PHP Modules]
  Core
  ctype
  curl
  date
  dom
  fileinfo
  filter
  ftp
  hash
  iconv
  json
  libxml
  mbstring
  mysqli
  mysqlnd
  openssl
  pcre
  PDO
  pdo_sqlite
  Phar
  posix
  readline
  Reflection
  session
  SimpleXML
  SPL
  sqlite3
  standard
  tokenizer
  xml
  xmlreader
  xmlwriter
  zlib
  
  [Zend Modules]
  </code></pre>
  <p>My .htaccess file doesn't work
  Where did I go wrong? And what I need do to fix this trouble?</p>