Skip to content

Commit 13a6fe1

Browse files
authored
Remove APCu and replace with Redis instead (#2040)
Signed-off-by: enoch85 <[email protected]>
1 parent 2378716 commit 13a6fe1

4 files changed

+39
-74
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Server installation. Simplified. :cloud:
2424
- PostgreSQL 12
2525
- PHP-FPM 7.4
2626
- Redis Memcache (latest stable version from PECL)
27-
- APCu local cache (latest stable version from PECL)
2827
- PHP-igbinary (latest stable version from PECL
2928
- PHP-smbclient (latest stable version from PECL)
3029
- Nextcloud Server Latest

addons/redis-server-ubuntu.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ sed -i "s|);||g" $NCPATH/config/config.php
6161

6262
# Add the needed config to Nextclouds config.php
6363
cat <<ADD_TO_CONFIG >> $NCPATH/config/config.php
64-
'memcache.local' => '\\OC\\Memcache\\APCu',
64+
'memcache.local' => '\\OC\\Memcache\\Redis',
6565
'filelocking.enabled' => true,
6666
'memcache.distributed' => '\\OC\\Memcache\\Redis',
6767
'memcache.locking' => '\\OC\\Memcache\\Redis',

nextcloud_install_production.sh

-40
Original file line numberDiff line numberDiff line change
@@ -644,46 +644,6 @@ echo "igbinary.compact_strings=On"
644644
restart_webserver
645645
fi
646646

647-
# APCu (local cache)
648-
if is_this_installed "php$PHPVER"-dev
649-
then
650-
if ! yes no | pecl install -Z apcu
651-
then
652-
msg_box "APCu PHP module installation failed"
653-
exit
654-
else
655-
print_text_in_color "$IGreen" "APCu PHP module installation OK!"
656-
fi
657-
{
658-
echo "# APCu settings for Nextcloud"
659-
echo "apc.enabled=1"
660-
echo "apc.max_file_size=5M"
661-
echo "apc.shm_segments=1"
662-
echo "apc.shm_size=128M"
663-
echo "apc.entries_hint=4096"
664-
echo "apc.ttl=3600"
665-
echo "apc.gc_ttl=7200"
666-
echo "apc.mmap_file_mask=NULL"
667-
echo "apc.slam_defense=1"
668-
echo "apc.enable_cli=1"
669-
echo "apc.use_request_time=1"
670-
echo "apc.serializer=igbinary"
671-
echo "apc.coredump_unmap=0"
672-
echo "apc.preload_path"
673-
} >> "$PHP_INI"
674-
if [ ! -f $PHP_MODS_DIR/apcu.ini ]
675-
then
676-
touch $PHP_MODS_DIR/apcu.ini
677-
fi
678-
if ! grep -qFx extension=apcu.so $PHP_MODS_DIR/apcu.ini
679-
then
680-
echo "# PECL apcu" > $PHP_MODS_DIR/apcu.ini
681-
echo "extension=apcu.so" >> $PHP_MODS_DIR/apcu.ini
682-
check_command phpenmod -v ALL apcu
683-
fi
684-
restart_webserver
685-
fi
686-
687647
# Fix https://github.com/nextcloud/vm/issues/714
688648
print_text_in_color "$ICyan" "Optimizing Nextcloud..."
689649
yes | nextcloud_occ db:convert-filecache-bigint

nextcloud_update.sh

+38-32
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ If you are sure that no update or backup is currently running, you can fix this
5555
exit 1
5656
fi
5757

58+
# Change from APCu to Redis for local cache
59+
# https://github.com/nextcloud/vm/pull/2040
60+
if pecl list | grep apcu >/dev/null 2>&1
61+
then
62+
sed -i "/memcache.local/d" "$NCPATH"/config/config.php
63+
if pecl list | grep redis >/dev/null 2>&1
64+
then
65+
nextcloud_occ config:system:set memcache.local --value='\OC\Memcache\Redis'
66+
else
67+
nextcloud_occ config:system:delete memcache.local
68+
fi
69+
fi
70+
5871
# Create a snapshot before doing anything else
5972
check_free_space
6073
if ! [ -f "$SCRIPTS/nextcloud-startup-script.sh" ] && (does_snapshot_exist "NcVM-startup" \
@@ -324,13 +337,33 @@ then
324337
check_command phpenmod -v ALL redis
325338
fi
326339

327-
# Upgrade APCu and igbinary
328-
#if [ "${CURRENTVERSION%%.*}" -ge "17" ]
329-
if [ "${CURRENTVERSION%%.*}" -ge "23" ]
340+
# Remove APCu https://github.com/nextcloud/vm/issues/2039
341+
if is_this_installed "php$PHPVER"-dev
342+
then
343+
# Delete PECL APCu
344+
if pecl list | grep -q apcu
345+
then
346+
if ! yes no | pecl uninstall apcu
347+
then
348+
msg_box "APCu PHP module removal failed! Please report this to $ISSUES"
349+
else
350+
print_text_in_color "$IGreen" "APCu PHP module removal OK!"
351+
fi
352+
# Delete everything else
353+
check_command phpdismod -v ALL apcu
354+
rm -f $PHP_MODS_DIR/apcu.ini
355+
sed -i "/extension=apcu.so/d" "$PHP_INI"
356+
sed -i "/APCu/d" "$PHP_INI"
357+
sed -i "/apc./d" "$PHP_INI"
358+
fi
359+
fi
360+
361+
# Upgrade other PECL dependencies
362+
if [ "${CURRENTVERSION%%.*}" -ge "17" ]
330363
then
331364
if [ -f "$PHP_INI" ]
332365
then
333-
print_text_in_color "$ICyan" "Trying to upgrade igbinary, smbclient, and APCu..."
366+
print_text_in_color "$ICyan" "Trying to upgrade igbinary, and smbclient..."
334367
if pecl list | grep igbinary >/dev/null 2>&1
335368
then
336369
yes no | pecl upgrade igbinary
@@ -373,35 +406,8 @@ then
373406
sed -i "/extension=smbclient.so/d" "$PHP_INI"
374407
fi
375408
fi
376-
if pecl list | grep -q apcu
377-
then
378-
yes no | pecl upgrade apcu
379-
# Remove old igbinary
380-
if grep -qFx extension=apcu.so "$PHP_INI"
381-
then
382-
sed -i "/extension=apcu.so/d" "$PHP_INI"
383-
fi
384-
# Check if apcu is enabled and create the file if not
385-
if [ ! -f $PHP_MODS_DIR/apcu.ini ]
386-
then
387-
touch $PHP_MODS_DIR/apcu.ini
388-
fi
389-
# Enable new apcu
390-
if ! grep -qFx extension=apcu.so $PHP_MODS_DIR/apcu.ini
391-
then
392-
echo "# PECL apcu" > $PHP_MODS_DIR/apcu.ini
393-
echo "extension=apcu.so" >> $PHP_MODS_DIR/apcu.ini
394-
check_command phpenmod -v ALL apcu
395-
fi
396-
# Fix https://help.nextcloud.com/t/nc-21-manual-update-issues/108693/4?$
397-
if ! grep -qFx apc.enable_cli=1 $PHP_MODS_DIR/apcu.ini
398-
then
399-
echo "apc.enable_cli=1" >> $PHP_MODS_DIR/apcu.ini
400-
check_command phpenmod -v ALL apcu
401-
fi
402-
fi
403409
if pecl list | grep -q inotify
404-
then
410+
then
405411
# Remove old inotify
406412
if grep -qFx extension=inotify.so "$PHP_INI"
407413
then

0 commit comments

Comments
 (0)