From 2b37f09ca22edd7e7b528f565d5b8eb7db593204 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 18 Jul 2017 22:52:21 +0200 Subject: [PATCH] Switch to php56 using FPM+FastCGI --- root/etc/cron.daily/pydio-indexer | 2 +- .../conf/httpd.conf/68FastCGIConfig25Pydio | 9 +++ .../etc/httpd/conf/httpd.conf/98Pydio | 49 +++++++++++++---- .../templates/etc/php-fpm.d/www.conf/25Pydio | 55 +++++++++++++++++++ .../conf.serial/plugins_configs.ser/10All | 4 +- smeserver-pydio.spec | 15 ++++- 6 files changed, 116 insertions(+), 18 deletions(-) create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/68FastCGIConfig25Pydio create mode 100644 root/etc/e-smith/templates/etc/php-fpm.d/www.conf/25Pydio diff --git a/root/etc/cron.daily/pydio-indexer b/root/etc/cron.daily/pydio-indexer index fb8d4db..50c18a3 100644 --- a/root/etc/cron.daily/pydio-indexer +++ b/root/etc/cron.daily/pydio-indexer @@ -31,7 +31,7 @@ foreach my $share ($a->get_all_by_prop(type => 'share')){ unlink if (time() - $mtime > 18000); } - system('/usr/bin/sudo -u www /usr/bin/php -d max_execution_time=3600 /usr/share/pydio/cmd.php ' . + system('/usr/bin/sudo -u www /usr/bin/php__PHP_VERSION__ -d max_execution_time=3600 /usr/share/pydio/cmd.php ' . '-u=RDiin175M40T0cYvXLARpAi+1TsSVkbksEDZ4KvwBuY= '. '-t=e71479ebc4365176d9f09fe957780024 -a=index '. '-r='.$name.' --secure_token='.$id.' --dir=/ --_method=put >/dev/null 2>&1'); diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/68FastCGIConfig25Pydio b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/68FastCGIConfig25Pydio new file mode 100644 index 0000000..5e4bcee --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/68FastCGIConfig25Pydio @@ -0,0 +1,9 @@ +{ +if ($fastcgi_mod eq 'mod_fastcgi'){ + $OUT .=<<_EOF; +Action phppydio-fastcgi /php-cgi-bin/phppydio-wrapper +Alias /php-cgi-bin/phppydio-wrapper /var/www/php-cgi-bin/phppydio-wrapper +FastCgiExternalServer /var/www/php-cgi-bin/phppydio-wrapper -socket /var/run/php-fpm/php__PHP_VERSION__-pydio.sock -pass-header Authorization -idle-timeout 120 +_EOF +} +} diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98Pydio b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98Pydio index 82c4492..7d9e5ba 100644 --- a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98Pydio +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98Pydio @@ -10,10 +10,44 @@ if (($pydio{'status'} || 'disabled') eq 'enabled'){ " AuthBasicProvider external\n" . " AuthExternal pwauth\n" . " Require valid-user\n" : ''; - my $maxsize = $pydio{'MaxUploadSize'} || '200M'; + my $maxsize = $pydio{'MaxUploadSize'} || '2048M'; my $homedir = $pydio{'HomeDir'} || 'none'; $homedir = (($homedir eq 'enabled') || ($homedir eq 'users')) ? ":/home/e-smith/files/users":""; + my $php =<<_EOF; + + AddType application/x-httpd-php .php + php_admin_value open_basedir /usr/share/pydio:/var/lib/pydio:/var/log/pydio:/etc/pydio:/var/cache/pydio:/usr/share/pear/:/usr/share/php/:/home/e-smith/files/shares$homedir + php_admin_value memory_limit 100M + php_admin_value upload_max_filesize $maxsize + php_admin_value post_max_size $maxsize + php_admin_value max_execution_time 900 + php_admin_value upload_tmp_dir /var/lib/pydio/tmp + php_admin_value session.save_path /var/lib/pydio/tmp + php_admin_flag output_buffering off + +_EOF + my $pubphp=<<_EOF; + + AddType application/x-httpd-php .php + +_EOF + + if ($fastcgi_mod eq 'mod_fastcgi'){ + $php = "AddHandler phppydio-fastcgi .php\n"; + $pubphp = $php; + } + elsif ($fastcgi_mod eq 'mod_proxy_fcgi'){ + $php =<<_EOF; + + + SetHandler "proxy:unix:/var/run/php-fpm/php__PHP_VERSION__-pydio.sock|fcgi://localhost" + + +_EOF + $pubphp = $php; + } + my $shares = ''; my $public = $pydio{'PublicShares'} || 'enabled'; @@ -22,8 +56,7 @@ if (($pydio{'status'} || 'disabled') eq 'enabled'){ Alias /ajxppub /var/lib/pydio/public Options None - AddType application/x-httpd-php .php - php_admin_value open_basedir /usr/share/pydio:/var/lib/pydio:/var/log/pydio:/etc/pydio:/var/cache/pydio:/usr/share/pear/:/usr/share/php/:/home/e-smith/files/shares$homedir + $pubphp Order deny,allow Allow from all @@ -44,16 +77,8 @@ EOF $alias - AddType application/x-httpd-php .php - php_admin_value open_basedir /usr/share/pydio:/var/lib/pydio:/var/log/pydio:/etc/pydio:/var/cache/pydio:/usr/share/pear/:/usr/share/php/:/home/e-smith/files/shares$homedir - php_admin_value memory_limit 100M - php_admin_value upload_max_filesize $maxsize - php_admin_value post_max_size $maxsize - php_admin_value max_execution_time 900 - php_admin_value upload_tmp_dir /var/lib/pydio/tmp - php_admin_value session.save_path /var/lib/pydio/tmp - php_admin_flag output_buffering off SSLRequireSSL on + $php Order deny,allow Deny from all Allow from $allow diff --git a/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/25Pydio b/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/25Pydio new file mode 100644 index 0000000..df1ca10 --- /dev/null +++ b/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/25Pydio @@ -0,0 +1,55 @@ +{ + +if ($PHP_VERSION eq '__PHP_VERSION__'){ + if (($dl{'status'} || 'disabled') eq 'enabled'){ + my $max_upload_size = $pydio{MaxUploadSize} || '4096'; + $max_upload_size .= 'M' unless ($max_upload_size =~ m/[MG]$/); + my $id = 'pydio'; + my $homedir = $pydio{'HomeDir'} || 'none'; + $homedir = (($homedir eq 'enabled') || ($homedir eq 'users')) ? ':/home/e-smith/files/users':''; + + $OUT .=<<_EOF; + +[php$PHP_VERSION-$id] +user = www +group = www +listen.owner = root +listen.group = www +listen.mode = 0660 +listen = /var/run/php-fpm/php$PHP_VERSION-$id.sock +pm = dynamic +pm.max_children = 15 +pm.start_servers = 3 +pm.min_spare_servers = 3 +pm.max_spare_servers = 4 +pm.max_requests = 1000 +php_admin_value[session.save_path] = /var/lib/php/$id/session +php_admin_value[opcache.file_cache] = /var/lib/php/$id/opcache +php_admin_value[upload_tmp_dir] = /var/lib/php/$id/tmp +php_admin_value[error_log] = /var/log/php/$id/error.log +slowlog = /var/log/php/dl/slow.log +php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f php@{ $DomainName } +php_admin_flag[display_errors] = off +php_admin_flag[log_errors] = on +php_admin_value[error_log] = syslog +php_admin_value[memory_limit] = 128M +php_admin_value[max_execution_time] = 0 +php_admin_value[post_max_size] = $max_upload_size +php_admin_value[upload_max_filesize] = $max_upload_size +php_admin_value[disable_functions] = system, show_source, symlink, exec, dl, shell_exec, passthru, phpinfo, escapeshellarg, escapeshellcmd +php_admin_value[open_basedir] = /usr/share/pydio:/var/lib/pydio:/var/log/pydio:/etc/pydio:/var/cache/pydio:/usr/share/pear/:/usr/share/php/:/home/e-smith/files/shares$homedir +php_admin_flag[allow_url_fopen] = off +php_admin_flag[file_upload] = on +php_admin_flag[session.cookie_httponly] = on +php_admin_flag[allow_url_include] = off +php_admin_value[session.save_handler] = files +php_admin_value[output_buffering] = off + +_EOF + + } + else{ + $OUT .= '; Pydio is disabled'; + } +} +} diff --git a/root/etc/e-smith/templates/var/lib/pydio/plugins/conf.serial/plugins_configs.ser/10All b/root/etc/e-smith/templates/var/lib/pydio/plugins/conf.serial/plugins_configs.ser/10All index bbad688..c66ff67 100644 --- a/root/etc/e-smith/templates/var/lib/pydio/plugins/conf.serial/plugins_configs.ser/10All +++ b/root/etc/e-smith/templates/var/lib/pydio/plugins/conf.serial/plugins_configs.ser/10All @@ -16,7 +16,7 @@ $data->{'core.ajaxplorer'}->{'AJXP_TMP_DIR'} ||= '/var/lib/pydio/tmp'; $data->{'core.ajaxplorer'}->{'DEFAULT_LANGUAGE'} ||= $pydio{'DefaultLanguage'} || 'en'; $data->{'core.ajaxplorer'}->{'APPLICATION_TITLE'} ||= $pydio{'Title'} || 'Pydio'; $data->{'core.ajaxplorer'}->{'CMDLINE_ACTIVE'} ||= '__true__'; -$data->{'core.ajaxplorer'}->{'CLI_PHP'} ||= '/usr/bin/php'; +$data->{'core.ajaxplorer'}->{'CLI_PHP'} ||= '/usr/bin/php__PHP_VERSION__'; if (($pydio{'PublicShares'} || 'enabled') eq 'enabled'){ $data->{'core.ajaxplorer'}->{'PUBLIC_DOWNLOAD_FOLDER'} ||= '/var/lib/pydio/public'; @@ -78,4 +78,4 @@ $data = serialize($data); # manually $data =~ s/s:8:"__true__";/b:1;/g; $OUT = $data; -} \ No newline at end of file +} diff --git a/smeserver-pydio.spec b/smeserver-pydio.spec index 3acfd7f..a9c4d0a 100644 --- a/smeserver-pydio.spec +++ b/smeserver-pydio.spec @@ -2,8 +2,9 @@ # Name: Daniel Berteaud %define name smeserver-pydio -%define version 0.2.11 -%define release 1 +%define version 0.3.0 +%define release 0.beta1 +%define phpversion 56 Summary: SME server integration of pydio Name: %{name} Version: %{version} @@ -177,6 +178,9 @@ This contrib works with the smeserver-shared-folders addon %build perl ./createlinks +find root/ -type f | xargs grep -l __PHP_VERSION__ | xargs sed -i -e "s/__PHP_VERSION__/%{phpversion}/g" +%{__mkdir_p} root/var/log/php/pydio +%{__mkdir_p} root/var/lib/php/pydio/{tmp,opcache,session} %install rm -rf $RPM_BUILD_ROOT @@ -186,7 +190,12 @@ rm -f %{name}-%{version}-filelist --file /etc/cron.daily/pydio-tmpwatch 'attr(0755,root,root)' \ --file /etc/cron.daily/pydio-indexer 'attr(0700,root,root)' \ --file /usr/bin/pydiopdftotext 'attr(0755,root,root)' \ - > %{name}-%{version}-filelist + --dir /var/log/php/pydio 'attr(0770,root,www)' \ + --dir /var/lib/php/pydio 'attr(0770,root,www)' \ + --dir /var/lib/php/pydio/tmp 'attr(0770,root,www)' \ + --dir /var/lib/php/pydio/opcache 'attr(0770,root,www)' \ + --dir /var/lib/php/pydio/session 'attr(0770,root,www)' \ + > %{name}-%{version}-filelist %files -f %{name}-%{version}-filelist %defattr(-,root,root)