Redis and Pasword in NCP Config
So I have a Redis server up and running in my stack - and wanted to implement it within NCP. Got the NCP config set up and it was working, until i rebooted NCP just for S&G. NCP hashed the password in the config file, causing Redis to not do it's thing within NCP, which then caused an internal server error and I couldn't access my NCP!
The fix? A silly script to run each time the LXC restarts and update the password in the NCP config file, duh! Here is what I did
Create the Script¶
I am keeping the script in this directory: /usr/local/bin/
#!/bin/bash
CONFIG_FILE="/var/www/nextcloud/config/config.php"
REDIS_PASS="YourRedisPassword"
if [ -f "$CONFIG_FILE" ]; then
echo "🔧 Fixing Redis password in $CONFIG_FILE..."
sed -i "s/'password' => '.*'/'password' => '$REDIS_PASS'/g" "$CONFIG_FILE"
echo "✅ Redis password updated."
else
echo "❌ $CONFIG_FILE not found!"
fi
Create The Systemd Service¶
[Unit]
Description=Fix Redis password in Nextcloud config after boot
After=network.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c "sleep 30 && /usr/local/bin/ncp-fix-redis.sh"
[Install]
WantedBy=multi-user.target
Enable The Service¶
Test Without Reboot¶
Edit your NCP config by changing the password for Redis to something wrong, then:
You should see something like this: