Nextcloud Optimization on Shared Hosting with PHP-FPM and Redis
Learn how to maximize Nextcloud on shared hosting with PHP-FPM and Redis caching. Tips for best performance configuration.
Why Optimize Nextcloud on Shared Hosting?
Nextcloud is a powerful cloud solution that often suffers from resource scarcity on shared hosting. However, with the right configuration of PHP-FPM and Redis caching, you can get the most out of it. In this article, we show you how to make your Nextcloud instance fast even on shared servers.
Configuring PHP-FPM Correctly
PHP-FPM (FastCGI Process Manager) is essential for performance. Adjust the following parameters in your php.ini or php-fpm.conf:
- memory_limit: Set at least 512 MB, preferably 1024 MB for Nextcloud.
- upload_max_filesize and post_max_size: Increase to 2 GB for large files.
- max_execution_time: 3600 seconds for background tasks.
- pm.max_children: Adjust to available resources (e.g., 5–10).
Also optimize the pm (Process Manager) to ondemand to save memory. This way, processes are only started when needed.
Enabling Redis Caching
Redis significantly speeds up Nextcloud by keeping cache data in memory. Here's how to set it up:
- Install Redis on your server (many shared hosting providers offer it).
- Add the following lines to the
config.phpof Nextcloud:'memcache.local' => '\OC\Memcache\Redis', 'memcache.distributed' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => [ 'host' => 'localhost', 'port' => 6379, 'timeout' => 0.0, ], - Ensure Redis is running and accessible from your Nextcloud instance.
With Redis, loading times drop drastically, especially with many users.
Further Optimizations for Shared Hosting
Optimize Database
Use MariaDB or MySQL with InnoDB. Enable Query Cache and set innodb_buffer_pool_size to 25% of available RAM. Regular maintenance with mysqlcheck helps.
Enable PHP OpCache
OpCache stores compiled PHP scripts. Set in php.ini:
opcache.enable=1 opcache.memory_consumption=128 opcache.max_accelerated_files=10000 opcache.revalidate_freq=2
Adjust Background Jobs
In Nextcloud settings, set Cron as the background job (AJAX is too slow). Set up a real cron job that runs php cron.php every 5 minutes.
Conclusion
With these adjustments, Nextcloud runs smoothly even on shared hosting. Remember to perform regular updates and check logs. If you're looking for a reliable hosting partner, check out our Webhosting packages – ideal for Nextcloud with PHP-FPM and Redis support.