[HowTo] Nextcloud - raise PHP upload_max_filesize

In some cases it may be needed to adapt the PHP settings of the Nextcloud installed from the Univention Appcenter. For instance, you want to raise the PHP limit for uploading files from 2 to 20MB.

Whereas the majority of the nextcloud settings can be set via the files located under: /var/lib/univention-appcenter/apps/nextcloud/, some stay “hidden” inside the app container.

For smaller tests it is sufficient to connect to the container using univention-app shell nextcloud and edit the files manually, but this is not safe for future updates etc.

Therefore, we are going to extend the nextcloud docker container by attaching an extra volume with our customizations.

0. Prerequisities

It is required that nextcloud is not installed, otherwise we have to reinstall it later.

1. Create a custom php.ini

For our example, we want to create our custom files under /usr/share/nextcloud/, so first create this folder using mkdir.
Then, create your custom settings under /usr/share/nextcloud/php.ini:

[PHP]

engine = On

...

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 20M

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20

...

The ... indicate skips of unrelevant parts. Don’t just copy and paste the example above.

Now we want this file to replace the one used inside the app container…

2. Link this file as a volume to the nextcloud docker container

Now we set an UCR variable to link our file inside the (not yet existing) docker container:
ucr set appcenter/apps/nextcloud/docker/params='-v /usr/share/nextcloud/php.ini:/etc/php/7.2/apache2/php.ini:ro'
It is important to do this before the installation of the nextcloud app, otherwise the file won’t be linked.
It is also possible to link more files or whole folders, but be careful that the path inside the container is correctly and that things may change during updates.

3. Install the Nextcloud app

Now you can install the nextcloud app by univention-app install nextcloud

4. Make sure it works

To check if it works, just connect to your running nextcloud instance and check the changes in the php.ini:
univention-app shell nextcloud
cat /etc/php/7.2/apache2/php.ini | grep upload_max
Which should be 20MB

If you make changes to your custom file, just restart the container by univention-app restart nextcloud to apply your change inside the app container.

Have a successful time with your UCS system :sunflower:

3 Likes

Related: How To Edit config.php in Nextcloud App

1 Like
Mastodon