diff --git a/Dockerfile b/Dockerfile index 986a4bc..d602226 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,40 +42,48 @@ RUN apk add --no-cache \ shadow # Configure to use php fpm and don't use /var/www to store everything (modules and logs) -RUN sed -i 's/LoadModule mpm_prefork_module/#LoadModule mpm_prefork_module/g' /etc/apache2/httpd.conf && \ +RUN \ + # Disable mpm_prefork + sed -i 's/LoadModule mpm_prefork_module/#LoadModule mpm_prefork_module/g' /etc/apache2/httpd.conf && \ + # Enable mpm_event sed -i 's/#LoadModule mpm_event_module/LoadModule mpm_event_module/g' /etc/apache2/httpd.conf && \ + # Enable rewrite mod sed -i 's/#LoadModule rewrite_module/LoadModule rewrite_module/g' /etc/apache2/httpd.conf && \ # Remove useless module bundled with proxy sed -i 's/LoadModule lbmethod/#LoadModule lbmethod/g' /etc/apache2/conf.d/proxy.conf && \ - # Enable deflate + # Enable deflate mod sed -i 's/#LoadModule deflate_module/LoadModule deflate_module/g' /etc/apache2/httpd.conf && \ + # Enable expires mod sed -i 's/#LoadModule expires_module/LoadModule expires_module/g' /etc/apache2/httpd.conf && \ + # Enable session mod sed -i 's/#LoadModule session_module/LoadModule session_module/g' /etc/apache2/httpd.conf && \ - # Disable some configs - sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php7/php.ini && \ + # Do not expose PHP version to the world sed -i 's/expose_php = On/expose_php = Off/g' /etc/php7/php.ini && \ - # Change DocumentRoot + # Disable APC - it has been replaced by APCu and opcache in PHP7 - https://pecl.php.net/package/apc + echo 'apc.enabled = Off' >> /etc/php7/php.ini && \ + # Change DocumentRoot to /var/www sed -i 's/var\/www\/localhost\/htdocs/var\/www\/html/g' /etc/apache2/httpd.conf && \ - # Change ServerRoot + # Change ServerRoot to /usr/local/apache sed -i 's/ServerRoot \/var\/www/ServerRoot \/usr\/local\/apache/g' /etc/apache2/httpd.conf && \ # Make sure PHP-FPM executes as apache user sed -i 's/user = nobody/user = apache/g' /etc/php7/php-fpm.d/www.conf && \ sed -i 's/group = nobody/group = apache/g' /etc/php7/php-fpm.d/www.conf && \ - # Prepare env + # Prepare Apache log dir mkdir -p /var/log/apache2 && \ - # Clean base directory and create required ones + # Clean base directory rm -rf /var/www/* && \ # Apache configs in one place mkdir -p /usr/local/apache && \ ln -s /usr/lib/apache2 /usr/local/apache/modules && \ ln -s /var/log/apache2 /usr/local/apache/logs -# PHP-FPM config +# PHP-FPM vhost config COPY vhost.conf /etc/apache2/conf.d/vhost.conf # Make sure apache can read&right to logs and docroot RUN chown -R apache:apache /var/log/apache2 /var/www -### Execute as Apache user ### + +### Continue execution as Apache user ### USER apache # Define Grav specific version of Grav or use latest stable diff --git a/run.sh b/run.sh index 65b0b79..b8835e7 100644 --- a/run.sh +++ b/run.sh @@ -1,10 +1,7 @@ #!/bin/sh -# Make sure apache can read&right to /var/www -chown -R apache:apache /var/log/apache2 /var/www - # Create cron job for Grav maintenance scripts -(crontab -l; echo "* * * * * cd /var/www/html;/usr/local/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab - +exec (crontab -l; echo "* * * * * cd /var/www/html;/usr/local/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab - # Start PHP-FPM and Apache exec /usr/sbin/httpd -D FOREGROUND -f /etc/apache2/httpd.conf &