Skip to content

Commit 0b94412

Browse files
committed
WebUI: Add support for removing/installing php packages
Increase Hestia nginx/php timeouts so install scripts have enough time to finish
1 parent 46873a3 commit 0b94412

File tree

5 files changed

+96
-8
lines changed

5 files changed

+96
-8
lines changed

bin/v-delete-web-php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ if [[ ! $version =~ ^[0-9]\.[0-9]+ ]]; then
3232
exit
3333
fi
3434

35+
# Remove backend template
36+
[ -f $HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl ] && rm -f $HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl
37+
3538
# Check if php version exists
3639
if [ ! -f "$php_fpm" ] && [ ! -f "$HESTIA/data/templates/$WEB_SYSTEM/PHP-$version.sh" ]; then
3740
echo "Version is not installed..."
@@ -75,8 +78,6 @@ if [ -f "$php_fpm" ]; then
7578
echo "apt-get purge $mph"
7679
fi
7780

78-
# Remove backend template
79-
rm -f $HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl
8081

8182
#----------------------------------------------------------#
8283
# Hestia #

src/deb/nginx/nginx.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ http {
1717
sendfile on;
1818
tcp_nopush on;
1919
tcp_nodelay on;
20-
client_header_timeout 180s;
21-
client_body_timeout 180s;
20+
client_header_timeout 600s;
21+
client_body_timeout 600s;
2222
client_header_buffer_size 2k;
2323
client_body_buffer_size 256k;
2424
client_max_body_size 256m;
2525
large_client_header_buffers 4 8k;
26-
send_timeout 60s;
26+
send_timeout 600s;
2727
keepalive_timeout 30s;
2828
keepalive_requests 100000;
2929
reset_timedout_connection on;
@@ -39,8 +39,8 @@ http {
3939
fastcgi_busy_buffers_size 256k;
4040
fastcgi_temp_file_write_size 256k;
4141
fastcgi_connect_timeout 30s;
42-
fastcgi_read_timeout 300s;
43-
fastcgi_send_timeout 180s;
42+
fastcgi_read_timeout 600s;
43+
fastcgi_send_timeout 600s;
4444

4545
# Proxy settings
4646
proxy_redirect off;

src/deb/php/php.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ expose_php = Off
382382
; Maximum execution time of each script, in seconds
383383
; http://php.net/max-execution-time
384384
; Note: This directive is hardcoded to 0 for the CLI SAPI
385-
max_execution_time = 60
385+
max_execution_time = 600
386386

387387
; Maximum amount of time each script may spend parsing request data. It's a good
388388
; idea to limit this time on productions servers in order to eliminate unexpectedly

web/edit/server/index.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,44 @@
3333
if ($v_timezone == 'America/Puerto_Rico' ) $v_timezone = 'AST';
3434
if ($v_timezone == 'America/Halifax' ) $v_timezone = 'ADT';
3535

36+
// List supported php versions
37+
exec (HESTIA_CMD."v-list-web-templates-backend json", $output, $return_var);
38+
$backend_templates = json_decode(implode('', $output), true);
39+
unset($output);
40+
41+
$v_php_versions = [
42+
'php-5.6',
43+
'php-7.0',
44+
'php-7.1',
45+
'php-7.2',
46+
'php-7.3',
47+
];
48+
sort($v_php_versions);
49+
50+
$v_php_versions = array_map(function($php_version) use ($backend_templates, $v_php_versions) {
51+
// Mark installed php versions
52+
53+
if(stripos($php_version,'php') !== 0)
54+
return false;
55+
56+
$phpinfo = (object) [
57+
"name" => $php_version,
58+
"tpl" => strtoupper(str_replace('.', '_', $php_version)),
59+
"version" => str_ireplace('php-', '', $php_version)
60+
];
61+
62+
if(in_array($phpinfo->tpl, $backend_templates)) {
63+
$phpinfo->installed = true;
64+
}
65+
66+
if(array_search($phpinfo->name, array_reverse($v_php_versions, true)) == array_key_last($v_php_versions)) {
67+
// Prevent default php version to be removed
68+
$phpinfo->protected = true;
69+
}
70+
71+
return $phpinfo;
72+
}, $v_php_versions);
73+
3674
// List supported languages
3775
exec (HESTIA_CMD."v-list-sys-languages json", $output, $return_var);
3876
$languages = json_decode(implode('', $output), true);
@@ -115,6 +153,36 @@
115153
$v_hostname = $_POST['v_hostname'];
116154
}
117155

156+
// Install/remove php versions
157+
if (empty($_SESSION['error_msg'])) {
158+
if(!empty($v_php_versions) && count($_POST['v_php_versions'] != count($v_php_versions))) {
159+
$post_php = $_POST['v_php_versions'];
160+
161+
array_map(function($php_version) use ($post_php) {
162+
163+
if(array_key_exists($php_version->tpl, $post_php)) {
164+
if(!$php_version->installed) {
165+
exec (HESTIA_CMD . "v-add-web-php " . escapeshellarg($php_version->version), $output, $return_var);
166+
check_return_code($return_var, $output);
167+
unset($output);
168+
if(empty($_SESSION['error_msg']))
169+
$php_version->installed = true;
170+
}
171+
} else {
172+
if($php_version->installed && !$php_version->protected) {
173+
exec (HESTIA_CMD . "v-delete-web-php " . escapeshellarg($php_version->version), $output, $return_var);
174+
check_return_code($return_var, $output);
175+
unset($output);
176+
if(empty($_SESSION['error_msg']))
177+
$php_version->installed = false;
178+
}
179+
}
180+
181+
return $php_version;
182+
}, $v_php_versions);
183+
}
184+
}
185+
118186
// Change timezone
119187
if (empty($_SESSION['error_msg'])) {
120188
if (!empty($_POST['v_timezone'])) {

web/templates/admin/edit_server.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,25 @@
243243
</tr>
244244

245245
<?php } ?>
246+
<?php if(count($v_php_versions)): ?>
247+
<tr>
248+
<td class="vst-text">
249+
<?php print __('Enabled multi PHP versions') ?>
250+
</td>
251+
</tr>
252+
<?php foreach($v_php_versions as $php_version): ?>
253+
<tr>
254+
<td class="vst-text input-label">
255+
<input type="checkbox" size="20" class="vst-checkbox"
256+
<?=$php_version->installed?'checked':''; ?>
257+
<?=$php_version->protected?'disabled':''; ?>
258+
id="<?=$php_version->name?>"
259+
name="v_php_versions[<?=$php_version->tpl?>]">
260+
<label for="<?=$php_version->name?>"><?=$php_version->name?></label>
261+
</td>
262+
</tr>
263+
<?php endforeach; ?>
264+
<?php endif; ?>
246265
</table>
247266
</td>
248267
</tr>

0 commit comments

Comments
 (0)