apachedockerpagespeedmod-pagespeedapache-modules

How to install mod_pagespeed in docker apache httpd


I have a docker based apache httpd server. I need to install mod_pagespeed into that.

The flavour I am using is debian based not alpine based for now - for some reasons.

Following is the list of commands required to install the module in debian/ubuntu dist - from the official site

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb
sudo dpkg -i mod-pagespeed-*.deb
sudo apt-get -f install

This is giving error

dpkg: dependency problems prevent configuration of mod-pagespeed-stable:
 mod-pagespeed-stable depends on apache2; however:
  Package apache2 is not installed.

This is obvious because there is no apache2 service installed, only httpd command works.

Even the folder structure is different then regular debian/ubuntu installation.

I don't find any .so file anywhere, otherwise I can put it in some directory and do a LoadModule.

I guess I need to do a custom build from source, is there any easy way?


Solution

  • You may use the following Dockerfile as a base:

    FROM debian:stretch
    
    ENV APACHE_RUN_USER www-data
    ENV APACHE_RUN_GROUP www-data
    ENV APACHE_PID_FILE /var/run/apache2/apache2.pid
    ENV APACHE_RUN_DIR /var/run/apache2
    ENV APACHE_LOCK_DIR /var/lock/apache2
    ENV APACHE_LOG_DIR /var/log/apache2
    ENV LANG C
    
    RUN apt-get update \
        && DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 wget \
        && wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb -O /tmp/modpagespeed.deb \
        && dpkg -i /tmp/modpagespeed.deb
    
    RUN mkdir -p /var/log/apache2 /var/run/apache2 /var/lock/apache2 \
        && chown www-data:www-data /var/log/apache2 /var/run/apache2 /var/lock/apache2
    
    CMD ["apache2", "-DFOREGROUND"]
    
    EXPOSE 80
    

    Build the image and launch a container, you'll get a response header similar to X-Mod-Pagespeed: 1.13.35.2-0.

    Hope this helps!