Browse Source

Added opcache options.

Jindrich Skacel 5 years ago
parent
commit
b1f6d8b0ba
1 changed files with 11 additions and 1 deletions
  1. 11 1
      php7/Dockerfile

+ 11 - 1
php7/Dockerfile

@@ -43,6 +43,8 @@ RUN 	addgroup -g 6662 php && adduser -u 6662 -H -s /sbin/nologin -G php -D php &
 											php7-posix && \
 											rm -rf /var/cache/apk/*
 
+# set recommended PHP.ini settings
+# see https://secure.php.net/manual/en/opcache.installation.php
 RUN set -xe && \
 	cd /etc/php7/ && \
 	sed 's/;include=/include=/g' php-fpm.conf > php-fpm.conf.bak && \
@@ -52,7 +54,15 @@ RUN set -xe && \
 	sed 's/;env/env/g' www.conf.bak > www.conf && \
 	sed 's/;access.log = log\/php7\/$pool.access.log/access.log = \/proc\/self\/fd\/2/g' www.conf > www.conf.bak && \
 	mv www.conf.bak www.conf && \
-	chown -R php:php /var/log/php7
+	chown -R php:php /var/log/php7 && \
+	echo 'opcache.memory_consumption=128' >> /etc/php7/conf.d/opcache-recommended.ini && \
+	echo 'opcache.interned_strings_buffer=8' >> /etc/php7/conf.d/opcache-recommended.ini && \
+	echo 'opcache.max_accelerated_files=10000' >> /etc/php7/conf.d/opcache-recommended.ini && \
+	echo 'opcache.revalidate_freq=1' >> /etc/php7/conf.d/opcache-recommended.ini && \
+	echo 'opcache.fast_shutdown=1' >> /etc/php7/conf.d/opcache-recommended.ini && \
+	echo 'opcache.enable_cli=1' >> /etc/php7/conf.d/opcache-recommended.ini && \
+	echo 'opcache.enable=1' >> /etc/php7/conf.d/opcache-recommended.ini && \
+	echo 'opcache.save_comments=1' >> /etc/php7/conf.d/opcache-recommended.ini
 
 USER php