Skip to content

Commit

Permalink
Remove APCu and replace with Redis instead (#2040)
Browse files Browse the repository at this point in the history
Signed-off-by: enoch85 <github@hanssonit.se>
  • Loading branch information
enoch85 authored Jul 2, 2021
1 parent 2378716 commit 13a6fe1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 74 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Server installation. Simplified. :cloud:
- PostgreSQL 12
- PHP-FPM 7.4
- Redis Memcache (latest stable version from PECL)
- APCu local cache (latest stable version from PECL)
- PHP-igbinary (latest stable version from PECL
- PHP-smbclient (latest stable version from PECL)
- Nextcloud Server Latest
Expand Down
2 changes: 1 addition & 1 deletion addons/redis-server-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sed -i "s|);||g" $NCPATH/config/config.php

# Add the needed config to Nextclouds config.php
cat <<ADD_TO_CONFIG >> $NCPATH/config/config.php
'memcache.local' => '\\OC\\Memcache\\APCu',
'memcache.local' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => true,
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
Expand Down
40 changes: 0 additions & 40 deletions nextcloud_install_production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -644,46 +644,6 @@ echo "igbinary.compact_strings=On"
restart_webserver
fi

# APCu (local cache)
if is_this_installed "php$PHPVER"-dev
then
if ! yes no | pecl install -Z apcu
then
msg_box "APCu PHP module installation failed"
exit
else
print_text_in_color "$IGreen" "APCu PHP module installation OK!"
fi
{
echo "# APCu settings for Nextcloud"
echo "apc.enabled=1"
echo "apc.max_file_size=5M"
echo "apc.shm_segments=1"
echo "apc.shm_size=128M"
echo "apc.entries_hint=4096"
echo "apc.ttl=3600"
echo "apc.gc_ttl=7200"
echo "apc.mmap_file_mask=NULL"
echo "apc.slam_defense=1"
echo "apc.enable_cli=1"
echo "apc.use_request_time=1"
echo "apc.serializer=igbinary"
echo "apc.coredump_unmap=0"
echo "apc.preload_path"
} >> "$PHP_INI"
if [ ! -f $PHP_MODS_DIR/apcu.ini ]
then
touch $PHP_MODS_DIR/apcu.ini
fi
if ! grep -qFx extension=apcu.so $PHP_MODS_DIR/apcu.ini
then
echo "# PECL apcu" > $PHP_MODS_DIR/apcu.ini
echo "extension=apcu.so" >> $PHP_MODS_DIR/apcu.ini
check_command phpenmod -v ALL apcu
fi
restart_webserver
fi

# Fix https://github.com/nextcloud/vm/issues/714
print_text_in_color "$ICyan" "Optimizing Nextcloud..."
yes | nextcloud_occ db:convert-filecache-bigint
Expand Down
70 changes: 38 additions & 32 deletions nextcloud_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ If you are sure that no update or backup is currently running, you can fix this
exit 1
fi

# Change from APCu to Redis for local cache
# https://github.com/nextcloud/vm/pull/2040
if pecl list | grep apcu >/dev/null 2>&1
then
sed -i "/memcache.local/d" "$NCPATH"/config/config.php
if pecl list | grep redis >/dev/null 2>&1
then
nextcloud_occ config:system:set memcache.local --value='\OC\Memcache\Redis'
else
nextcloud_occ config:system:delete memcache.local
fi
fi

# Create a snapshot before doing anything else
check_free_space
if ! [ -f "$SCRIPTS/nextcloud-startup-script.sh" ] && (does_snapshot_exist "NcVM-startup" \
Expand Down Expand Up @@ -324,13 +337,33 @@ then
check_command phpenmod -v ALL redis
fi

# Upgrade APCu and igbinary
#if [ "${CURRENTVERSION%%.*}" -ge "17" ]
if [ "${CURRENTVERSION%%.*}" -ge "23" ]
# Remove APCu https://github.com/nextcloud/vm/issues/2039
if is_this_installed "php$PHPVER"-dev
then
# Delete PECL APCu
if pecl list | grep -q apcu
then
if ! yes no | pecl uninstall apcu
then
msg_box "APCu PHP module removal failed! Please report this to $ISSUES"
else
print_text_in_color "$IGreen" "APCu PHP module removal OK!"
fi
# Delete everything else
check_command phpdismod -v ALL apcu
rm -f $PHP_MODS_DIR/apcu.ini
sed -i "/extension=apcu.so/d" "$PHP_INI"
sed -i "/APCu/d" "$PHP_INI"
sed -i "/apc./d" "$PHP_INI"
fi
fi

# Upgrade other PECL dependencies
if [ "${CURRENTVERSION%%.*}" -ge "17" ]
then
if [ -f "$PHP_INI" ]
then
print_text_in_color "$ICyan" "Trying to upgrade igbinary, smbclient, and APCu..."
print_text_in_color "$ICyan" "Trying to upgrade igbinary, and smbclient..."
if pecl list | grep igbinary >/dev/null 2>&1
then
yes no | pecl upgrade igbinary
Expand Down Expand Up @@ -373,35 +406,8 @@ then
sed -i "/extension=smbclient.so/d" "$PHP_INI"
fi
fi
if pecl list | grep -q apcu
then
yes no | pecl upgrade apcu
# Remove old igbinary
if grep -qFx extension=apcu.so "$PHP_INI"
then
sed -i "/extension=apcu.so/d" "$PHP_INI"
fi
# Check if apcu is enabled and create the file if not
if [ ! -f $PHP_MODS_DIR/apcu.ini ]
then
touch $PHP_MODS_DIR/apcu.ini
fi
# Enable new apcu
if ! grep -qFx extension=apcu.so $PHP_MODS_DIR/apcu.ini
then
echo "# PECL apcu" > $PHP_MODS_DIR/apcu.ini
echo "extension=apcu.so" >> $PHP_MODS_DIR/apcu.ini
check_command phpenmod -v ALL apcu
fi
# Fix https://help.nextcloud.com/t/nc-21-manual-update-issues/108693/4?$
if ! grep -qFx apc.enable_cli=1 $PHP_MODS_DIR/apcu.ini
then
echo "apc.enable_cli=1" >> $PHP_MODS_DIR/apcu.ini
check_command phpenmod -v ALL apcu
fi
fi
if pecl list | grep -q inotify
then
then
# Remove old inotify
if grep -qFx extension=inotify.so "$PHP_INI"
then
Expand Down

0 comments on commit 13a6fe1

Please sign in to comment.