module(wp): fix it more

This commit is contained in:
Raito Bezarius 2021-11-22 21:48:45 +01:00
parent 249b3639c7
commit 3d4661578b
4 changed files with 44 additions and 6 deletions

View file

@ -6,7 +6,10 @@ let
appConfig = (import ./default-app-config.nix).extend (self: super: { });
writeableDataPath = "/var/lib/phpfpm/${appConfig.name}";
phpFpmListen = "/run/phpfpm/wordpress-pool.sock";
phpIni = import ./php-config.nix { inherit pkgs config appConfig; };
phpIni = import ./php-config.nix { inherit pkgs config appConfig;
phpPackages = pkgs.php74Packages;
phpExtensions = pkgs.php74Extensions;
};
enablePageSpeed = pkgs.stdenv.isLinux && appConfig.googlePageSpeed.enable;
app = callPackage ./app.nix {
inherit appConfig;

View file

@ -0,0 +1,34 @@
# References:
# * https://www.rfmeier.net/speed-up-wordpress-dreamhost-opcache/
# * http://us3.php.net/manual/en/opcache.installation.php
# * https://tideways.io/profiler/blog/fine-tune-your-opcache-configuration-to-avoid-caching-suprises
{ enable, maxMemoryMb, validateTimestamps, revalidateFreqSec, ... }:
''
opcache.enable=${if enable then "1" else "0"}
opcache.memory_consumption=${toString maxMemoryMb} ; MB
opcache.interned_strings_buffer=8 ; The amount of memory to store immutable strings
opcache.save_comments=1 ; Comments in code will be compiled
opcache.load_comments=0 ; Comments will not be loaded
opcache.max_file_size=2097152
opcache.fast_shutdown=0
opcache.max_accelerated_files=10000
opcache.enable_cli=1
; Make sure each cached file has a distinct path
; See http://php.net/manual/en/opcache.configuration.php#ini.opcache.revalidate-path
opcache.revalidate_path=1
; Check opcace when PHP uses file checking functions, file_exists, etc
; See http://php.net/manual/en/opcache.configuration.php#ini.opcache.enable-file-override
opcache.enable_file_override=1
; Cache expiration.
; See http://php.net/manual/en/opcache.configuration.php#ini.opcache.validate-timestamps
opcache.validate_timestamps=${if validateTimestamps then "1" else "0"}
; How long to check a file if it needs to be re-cached
; If opcache.validate_timestamps is disabled, this is ignored.
; See http://php.net/manual/en/opcache.configuration.php#ini.opcache.revalidate-freq
opcache.revalidate_freq=${toString revalidateFreqSec}
''

View file

@ -1,6 +1,8 @@
{ pkgs
, config # system configuration
, appConfig
, phpPackages
, phpExtensions
}:
assert appConfig.php.scriptMemoryLimitMb > appConfig.maxUploadMb;
@ -8,7 +10,7 @@ assert appConfig.php.scriptMemoryLimitMb > appConfig.maxUploadMb;
''
memory_limit ${toString appConfig.php.scriptMemoryLimitMb}M
extension = "${pkgs.phpPackages.imagick}/lib/php/extensions/imagick.so"
extension = "${phpExtensions.imagick}/lib/php/extensions/imagick.so"
${pkgs.lib.optionalString appConfig.opcache.enable ''
zend_extension = "${config.services.phpfpm.phpPackage}/lib/php/extensions/opcache.so"
@ -16,7 +18,7 @@ assert appConfig.php.scriptMemoryLimitMb > appConfig.maxUploadMb;
${pkgs.lib.optionalString appConfig.php.enableXDebug ''
; WARNING: Be sure to load opcache *before* xdebug (http://us3.php.net/manual/en/opcache.installation.php).
zend_extension = "${pkgs.phpPackages.xdebug}/lib/php/extensions/xdebug.so"
zend_extension = "${phpPackages.xdebug}/lib/php/extensions/xdebug.so"
''}
upload_max_filesize = ${toString appConfig.maxUploadMb}M

View file

@ -1,7 +1,6 @@
{ fetchzip, runCommand, ... }:
let
version = "4.8";
let version = "4.8";
in fetchzip {
url = "https://wordpress.org/wordpress-${version}.tar.gz";
url = "https://wordpress.org/wordpress-${version}.tar.gz";
sha256 = "1myflpa9pxcghnhjfd0ahqpsvgcwh3szk2k8w2x7qmvfll69n3j9";
}